@blackcode_sa/metaestetics-api 1.15.16 → 1.15.17-staging.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/index.d.mts +377 -222
- package/dist/admin/index.d.ts +377 -222
- package/dist/admin/index.js +625 -206
- package/dist/admin/index.mjs +624 -206
- package/dist/backoffice/index.d.mts +24 -0
- package/dist/backoffice/index.d.ts +24 -0
- package/dist/index.d.mts +292 -4
- package/dist/index.d.ts +292 -4
- package/dist/index.js +1142 -630
- package/dist/index.mjs +1137 -617
- package/package.json +2 -1
- package/src/__mocks__/firstore.ts +10 -10
- package/src/admin/aggregation/README.md +79 -79
- package/src/admin/aggregation/appointment/README.md +151 -129
- package/src/admin/aggregation/appointment/appointment.aggregation.service.ts +2137 -2091
- package/src/admin/aggregation/appointment/index.ts +1 -1
- package/src/admin/aggregation/clinic/README.md +52 -52
- package/src/admin/aggregation/clinic/clinic.aggregation.service.ts +966 -966
- package/src/admin/aggregation/clinic/index.ts +1 -1
- package/src/admin/aggregation/forms/README.md +13 -13
- package/src/admin/aggregation/forms/filled-forms.aggregation.service.ts +322 -322
- package/src/admin/aggregation/forms/index.ts +1 -1
- package/src/admin/aggregation/index.ts +8 -8
- package/src/admin/aggregation/patient/README.md +27 -27
- package/src/admin/aggregation/patient/index.ts +1 -1
- package/src/admin/aggregation/patient/patient.aggregation.service.ts +141 -141
- package/src/admin/aggregation/practitioner/README.md +42 -42
- package/src/admin/aggregation/practitioner/index.ts +1 -1
- package/src/admin/aggregation/practitioner/practitioner.aggregation.service.ts +433 -433
- package/src/admin/aggregation/practitioner-invite/index.ts +1 -1
- package/src/admin/aggregation/practitioner-invite/practitioner-invite.aggregation.service.ts +961 -961
- package/src/admin/aggregation/procedure/README.md +43 -43
- package/src/admin/aggregation/procedure/index.ts +1 -1
- package/src/admin/aggregation/procedure/procedure.aggregation.service.ts +702 -702
- package/src/admin/aggregation/reviews/index.ts +1 -1
- package/src/admin/aggregation/reviews/reviews.aggregation.service.ts +689 -689
- package/src/admin/analytics/analytics.admin.service.ts +278 -278
- package/src/admin/analytics/index.ts +2 -2
- package/src/admin/booking/README.md +184 -125
- package/src/admin/booking/booking.admin.ts +1330 -1073
- package/src/admin/booking/booking.calculator.ts +850 -712
- package/src/admin/booking/booking.types.ts +76 -59
- package/src/admin/booking/index.ts +3 -3
- package/src/admin/booking/timezones-problem.md +185 -185
- package/src/admin/calendar/README.md +62 -7
- package/src/admin/calendar/calendar.admin.service.ts +345 -345
- package/src/admin/calendar/index.ts +2 -1
- package/src/admin/calendar/resource-calendar.admin.ts +198 -0
- package/src/admin/documentation-templates/document-manager.admin.ts +260 -260
- package/src/admin/documentation-templates/index.ts +1 -1
- package/src/admin/free-consultation/free-consultation-utils.admin.ts +148 -148
- package/src/admin/free-consultation/index.ts +1 -1
- package/src/admin/index.ts +83 -83
- package/src/admin/logger/index.ts +78 -78
- package/src/admin/mailing/README.md +139 -139
- package/src/admin/mailing/appointment/appointment.mailing.service.ts +1253 -1253
- package/src/admin/mailing/appointment/index.ts +1 -1
- package/src/admin/mailing/appointment/templates/patient/appointment-confirmed.html +40 -40
- package/src/admin/mailing/base.mailing.service.ts +208 -208
- package/src/admin/mailing/clinicWelcome/clinicWelcome.mailing.ts +292 -292
- package/src/admin/mailing/clinicWelcome/index.ts +1 -1
- package/src/admin/mailing/clinicWelcome/templates/welcome.template.ts +225 -225
- package/src/admin/mailing/index.ts +5 -5
- package/src/admin/mailing/patientInvite/index.ts +2 -2
- package/src/admin/mailing/patientInvite/patientInvite.mailing.ts +415 -415
- package/src/admin/mailing/patientInvite/templates/invitation.template.ts +105 -105
- package/src/admin/mailing/practitionerInvite/existing-practitioner-invite.mailing.ts +611 -611
- package/src/admin/mailing/practitionerInvite/index.ts +2 -2
- package/src/admin/mailing/practitionerInvite/practitionerInvite.mailing.ts +395 -395
- package/src/admin/mailing/practitionerInvite/templates/existing-practitioner-invitation.template.ts +155 -155
- package/src/admin/mailing/practitionerInvite/templates/invitation.template.ts +101 -101
- package/src/admin/mailing/practitionerInvite/templates/invite-accepted-notification.template.ts +228 -228
- package/src/admin/mailing/practitionerInvite/templates/invite-rejected-notification.template.ts +242 -242
- package/src/admin/notifications/index.ts +1 -1
- package/src/admin/notifications/notifications.admin.ts +818 -818
- package/src/admin/requirements/README.md +128 -128
- package/src/admin/requirements/index.ts +1 -1
- package/src/admin/requirements/patient-requirements.admin.service.ts +475 -475
- package/src/admin/users/index.ts +1 -1
- package/src/admin/users/user-profile.admin.ts +405 -405
- package/src/backoffice/constants/certification.constants.ts +13 -13
- package/src/backoffice/constants/index.ts +1 -1
- package/src/backoffice/errors/backoffice.errors.ts +181 -181
- package/src/backoffice/errors/index.ts +1 -1
- package/src/backoffice/expo-safe/README.md +26 -26
- package/src/backoffice/expo-safe/index.ts +41 -41
- package/src/backoffice/index.ts +5 -5
- package/src/backoffice/services/FIXES_README.md +102 -102
- package/src/backoffice/services/README.md +57 -57
- package/src/backoffice/services/analytics.service.proposal.md +863 -863
- package/src/backoffice/services/analytics.service.summary.md +143 -143
- package/src/backoffice/services/brand.service.ts +260 -260
- package/src/backoffice/services/category.service.ts +384 -384
- package/src/backoffice/services/constants.service.ts +385 -385
- package/src/backoffice/services/documentation-template.service.ts +202 -202
- package/src/backoffice/services/index.ts +10 -10
- package/src/backoffice/services/migrate-products.ts +116 -116
- package/src/backoffice/services/product.service.ts +557 -557
- package/src/backoffice/services/requirement.service.ts +235 -235
- package/src/backoffice/services/subcategory.service.ts +461 -461
- package/src/backoffice/services/technology.service.ts +1153 -1153
- package/src/backoffice/types/README.md +12 -12
- package/src/backoffice/types/admin-constants.types.ts +69 -69
- package/src/backoffice/types/brand.types.ts +29 -29
- package/src/backoffice/types/category.types.ts +67 -67
- package/src/backoffice/types/documentation-templates.types.ts +28 -28
- package/src/backoffice/types/index.ts +10 -10
- package/src/backoffice/types/procedure-product.types.ts +38 -38
- package/src/backoffice/types/product.types.ts +239 -239
- package/src/backoffice/types/requirement.types.ts +63 -63
- package/src/backoffice/types/static/README.md +18 -18
- package/src/backoffice/types/static/blocking-condition.types.ts +21 -21
- package/src/backoffice/types/static/certification.types.ts +37 -37
- package/src/backoffice/types/static/contraindication.types.ts +19 -19
- package/src/backoffice/types/static/index.ts +6 -6
- package/src/backoffice/types/static/pricing.types.ts +16 -16
- package/src/backoffice/types/static/procedure-family.types.ts +14 -14
- package/src/backoffice/types/static/treatment-benefit.types.ts +22 -22
- package/src/backoffice/types/subcategory.types.ts +34 -34
- package/src/backoffice/types/technology.types.ts +168 -168
- package/src/backoffice/validations/index.ts +1 -1
- package/src/backoffice/validations/schemas.ts +164 -164
- package/src/config/__mocks__/firebase.ts +99 -99
- package/src/config/firebase.ts +78 -78
- package/src/config/index.ts +17 -17
- package/src/config/tiers.config.ts +255 -229
- package/src/errors/auth.error.ts +6 -6
- package/src/errors/auth.errors.ts +211 -211
- package/src/errors/clinic.errors.ts +32 -32
- package/src/errors/firebase.errors.ts +47 -47
- package/src/errors/user.errors.ts +99 -99
- package/src/index.backup.ts +407 -407
- package/src/index.ts +6 -6
- package/src/locales/en.ts +31 -31
- package/src/recommender/admin/index.ts +1 -1
- package/src/recommender/admin/services/recommender.service.admin.ts +5 -5
- package/src/recommender/front/index.ts +1 -1
- package/src/recommender/front/services/onboarding.service.ts +5 -5
- package/src/recommender/front/services/recommender.service.ts +3 -3
- package/src/recommender/index.ts +1 -1
- package/src/services/PATIENTAUTH.MD +197 -197
- package/src/services/README.md +106 -106
- package/src/services/__tests__/auth/auth.mock.test.ts +17 -17
- package/src/services/__tests__/auth/auth.setup.ts +298 -298
- package/src/services/__tests__/auth.service.test.ts +310 -310
- package/src/services/__tests__/base.service.test.ts +36 -36
- package/src/services/__tests__/user.service.test.ts +530 -530
- package/src/services/analytics/ARCHITECTURE.md +199 -199
- package/src/services/analytics/CLOUD_FUNCTIONS.md +225 -225
- package/src/services/analytics/GROUPED_ANALYTICS.md +501 -501
- package/src/services/analytics/QUICK_START.md +393 -393
- package/src/services/analytics/README.md +304 -304
- package/src/services/analytics/SUMMARY.md +141 -141
- package/src/services/analytics/TRENDS.md +380 -380
- package/src/services/analytics/USAGE_GUIDE.md +518 -518
- package/src/services/analytics/analytics-cloud.service.ts +222 -222
- package/src/services/analytics/analytics.service.ts +2148 -2148
- package/src/services/analytics/index.ts +4 -4
- package/src/services/analytics/review-analytics.service.ts +941 -941
- package/src/services/analytics/utils/appointment-filtering.utils.ts +138 -138
- package/src/services/analytics/utils/cost-calculation.utils.ts +182 -182
- package/src/services/analytics/utils/grouping.utils.ts +434 -434
- package/src/services/analytics/utils/stored-analytics.utils.ts +347 -347
- package/src/services/analytics/utils/time-calculation.utils.ts +186 -186
- package/src/services/analytics/utils/trend-calculation.utils.ts +200 -200
- package/src/services/appointment/README.md +17 -17
- package/src/services/appointment/appointment.service.ts +2943 -2941
- package/src/services/appointment/index.ts +1 -1
- package/src/services/appointment/utils/appointment.utils.ts +620 -620
- package/src/services/appointment/utils/extended-procedure.utils.ts +354 -354
- package/src/services/appointment/utils/form-initialization.utils.ts +516 -516
- package/src/services/appointment/utils/recommended-procedure.utils.ts +195 -195
- package/src/services/appointment/utils/zone-management.utils.ts +468 -468
- package/src/services/appointment/utils/zone-photo.utils.ts +302 -302
- package/src/services/auth/auth.service.ts +1435 -1435
- package/src/services/auth/auth.v2.service.ts +961 -961
- package/src/services/auth/index.ts +7 -7
- package/src/services/auth/utils/error.utils.ts +90 -90
- package/src/services/auth/utils/firebase.utils.ts +49 -49
- package/src/services/auth/utils/index.ts +21 -21
- package/src/services/auth/utils/practitioner.utils.ts +125 -125
- package/src/services/base.service.ts +41 -41
- package/src/services/calendar/calendar.service.ts +1077 -1077
- package/src/services/calendar/calendar.v2.service.ts +1693 -1693
- package/src/services/calendar/calendar.v3.service.ts +313 -313
- package/src/services/calendar/externalCalendar.service.ts +178 -178
- package/src/services/calendar/index.ts +5 -5
- package/src/services/calendar/synced-calendars.service.ts +743 -743
- package/src/services/calendar/utils/appointment.utils.ts +265 -265
- package/src/services/calendar/utils/calendar-event.utils.ts +676 -676
- package/src/services/calendar/utils/clinic.utils.ts +237 -237
- package/src/services/calendar/utils/docs.utils.ts +157 -157
- package/src/services/calendar/utils/google-calendar.utils.ts +697 -697
- package/src/services/calendar/utils/index.ts +8 -8
- package/src/services/calendar/utils/patient.utils.ts +198 -198
- package/src/services/calendar/utils/practitioner.utils.ts +221 -221
- package/src/services/calendar/utils/synced-calendar.utils.ts +472 -472
- package/src/services/clinic/README.md +204 -204
- package/src/services/clinic/__tests__/clinic-admin.service.test.ts +265 -265
- package/src/services/clinic/__tests__/clinic-group.service.test.ts +222 -222
- package/src/services/clinic/__tests__/clinic.service.test.ts +302 -302
- package/src/services/clinic/billing-transactions.service.ts +217 -217
- package/src/services/clinic/clinic-admin.service.ts +202 -202
- package/src/services/clinic/clinic-group.service.ts +310 -310
- package/src/services/clinic/clinic.service.ts +720 -720
- package/src/services/clinic/index.ts +5 -5
- package/src/services/clinic/practitioner-invite.service.ts +519 -519
- package/src/services/clinic/utils/admin.utils.ts +551 -551
- package/src/services/clinic/utils/clinic-group.utils.ts +646 -646
- package/src/services/clinic/utils/clinic.utils.ts +1023 -1023
- package/src/services/clinic/utils/filter.utils.d.ts +23 -23
- package/src/services/clinic/utils/filter.utils.ts +462 -462
- package/src/services/clinic/utils/index.ts +10 -10
- package/src/services/clinic/utils/photos.utils.ts +188 -188
- package/src/services/clinic/utils/search.utils.ts +83 -83
- package/src/services/clinic/utils/tag.utils.ts +124 -124
- package/src/services/documentation-templates/documentation-template.service.ts +537 -537
- package/src/services/documentation-templates/filled-document.service.ts +597 -597
- package/src/services/documentation-templates/index.ts +2 -2
- package/src/services/index.ts +16 -15
- package/src/services/media/index.ts +1 -1
- package/src/services/media/media.service.ts +418 -418
- package/src/services/notifications/__tests__/notification.service.test.ts +242 -242
- package/src/services/notifications/index.ts +1 -1
- package/src/services/notifications/notification.service.ts +215 -215
- package/src/services/patient/README.md +48 -48
- package/src/services/patient/To-Do.md +43 -43
- package/src/services/patient/__tests__/patient.service.test.ts +286 -286
- package/src/services/patient/index.ts +2 -2
- package/src/services/patient/patient.service.ts +1021 -1021
- package/src/services/patient/patientRequirements.service.ts +309 -309
- package/src/services/patient/utils/aesthetic-analysis.utils.ts +176 -176
- package/src/services/patient/utils/body-assessment.utils.ts +159 -159
- package/src/services/patient/utils/clinic.utils.ts +159 -159
- package/src/services/patient/utils/docs.utils.ts +142 -142
- package/src/services/patient/utils/hair-scalp-assessment.utils.ts +158 -158
- package/src/services/patient/utils/index.ts +9 -9
- package/src/services/patient/utils/location.utils.ts +126 -126
- package/src/services/patient/utils/medical-stuff.utils.ts +143 -143
- package/src/services/patient/utils/medical.utils.ts +458 -458
- package/src/services/patient/utils/practitioner.utils.ts +260 -260
- package/src/services/patient/utils/pre-surgical-assessment.utils.ts +161 -161
- package/src/services/patient/utils/profile.utils.ts +510 -510
- package/src/services/patient/utils/sensitive.utils.ts +260 -260
- package/src/services/patient/utils/skin-quality-assessment.utils.ts +160 -160
- package/src/services/patient/utils/token.utils.ts +211 -211
- package/src/services/practitioner/README.md +145 -145
- package/src/services/practitioner/index.ts +1 -1
- package/src/services/practitioner/practitioner.service.ts +2355 -2354
- package/src/services/procedure/README.md +163 -163
- package/src/services/procedure/index.ts +1 -1
- package/src/services/procedure/procedure.service.ts +2521 -2521
- package/src/services/resource/README.md +119 -0
- package/src/services/resource/index.ts +1 -0
- package/src/services/resource/resource.service.ts +555 -0
- package/src/services/reviews/index.ts +1 -1
- package/src/services/reviews/reviews.service.ts +745 -745
- package/src/services/tier-enforcement.ts +240 -240
- package/src/services/user/index.ts +1 -1
- package/src/services/user/user.service.ts +533 -533
- package/src/services/user/user.v2.service.ts +467 -467
- package/src/types/analytics/analytics.types.ts +597 -597
- package/src/types/analytics/grouped-analytics.types.ts +173 -173
- package/src/types/analytics/index.ts +4 -4
- package/src/types/analytics/stored-analytics.types.ts +137 -137
- package/src/types/appointment/index.ts +524 -517
- package/src/types/calendar/index.ts +261 -260
- package/src/types/calendar/synced-calendar.types.ts +66 -66
- package/src/types/clinic/index.ts +530 -529
- package/src/types/clinic/practitioner-invite.types.ts +91 -91
- package/src/types/clinic/preferences.types.ts +159 -159
- package/src/types/clinic/rbac.types.ts +64 -63
- package/src/types/clinic/to-do +3 -3
- package/src/types/documentation-templates/index.ts +308 -308
- package/src/types/index.ts +50 -47
- package/src/types/notifications/README.md +77 -77
- package/src/types/notifications/index.ts +300 -300
- package/src/types/patient/aesthetic-analysis.types.ts +66 -66
- package/src/types/patient/allergies.ts +58 -58
- package/src/types/patient/body-assessment.types.ts +93 -93
- package/src/types/patient/hair-scalp-assessment.types.ts +98 -98
- package/src/types/patient/index.ts +279 -279
- package/src/types/patient/medical-info.types.ts +152 -152
- package/src/types/patient/patient-requirements.ts +92 -92
- package/src/types/patient/pre-surgical-assessment.types.ts +95 -95
- package/src/types/patient/skin-quality-assessment.types.ts +105 -105
- package/src/types/patient/token.types.ts +61 -61
- package/src/types/practitioner/index.ts +208 -208
- package/src/types/procedure/index.ts +189 -183
- package/src/types/profile/index.ts +39 -39
- package/src/types/resource/README.md +153 -0
- package/src/types/resource/index.ts +199 -0
- package/src/types/reviews/index.ts +132 -132
- package/src/types/tz-lookup.d.ts +4 -4
- package/src/types/user/index.ts +60 -60
- package/src/utils/TIMESTAMPS.md +176 -176
- package/src/utils/TimestampUtils.ts +241 -241
- package/src/utils/index.ts +1 -1
- package/src/validations/README.md +94 -0
- package/src/validations/appointment.schema.ts +589 -589
- package/src/validations/calendar.schema.ts +225 -225
- package/src/validations/clinic.schema.ts +494 -494
- package/src/validations/common.schema.ts +25 -25
- package/src/validations/documentation-templates/index.ts +1 -1
- package/src/validations/documentation-templates/template.schema.ts +220 -220
- package/src/validations/documentation-templates.schema.ts +10 -10
- package/src/validations/index.ts +21 -20
- package/src/validations/media.schema.ts +10 -10
- package/src/validations/notification.schema.ts +90 -90
- package/src/validations/patient/aesthetic-analysis.schema.ts +55 -55
- package/src/validations/patient/body-assessment.schema.ts +82 -82
- package/src/validations/patient/hair-scalp-assessment.schema.ts +70 -70
- package/src/validations/patient/medical-info.schema.ts +177 -177
- package/src/validations/patient/patient-requirements.schema.ts +84 -84
- package/src/validations/patient/pre-surgical-assessment.schema.ts +78 -78
- package/src/validations/patient/skin-quality-assessment.schema.ts +70 -70
- package/src/validations/patient/token.schema.ts +29 -29
- package/src/validations/patient.schema.ts +217 -217
- package/src/validations/practitioner.schema.ts +224 -224
- package/src/validations/procedure-product.schema.ts +41 -41
- package/src/validations/procedure.schema.ts +136 -124
- package/src/validations/profile-info.schema.ts +41 -41
- package/src/validations/resource.schema.ts +57 -0
- package/src/validations/reviews.schema.ts +195 -195
- package/src/validations/schemas.ts +109 -109
- package/src/validations/shared.schema.ts +78 -78
|
@@ -1,1253 +1,1253 @@
|
|
|
1
|
-
import * as admin from 'firebase-admin';
|
|
2
|
-
import { DateTime } from 'luxon';
|
|
3
|
-
import { BaseMailingService, NewMailgunClient } from '../base.mailing.service';
|
|
4
|
-
import { Logger } from '../../logger';
|
|
5
|
-
import { Appointment } from '../../../types/appointment';
|
|
6
|
-
import { PatientProfile } from '../../../types/patient';
|
|
7
|
-
import { Practitioner } from '../../../types/practitioner';
|
|
8
|
-
import { Clinic } from '../../../types/clinic';
|
|
9
|
-
import { UserRole } from '../../../types';
|
|
10
|
-
import { PractitionerProfileInfo, PatientProfileInfo, ClinicInfo } from '../../../types/profile';
|
|
11
|
-
|
|
12
|
-
// Simple string literals for placeholders, to be replaced by file loading later
|
|
13
|
-
const patientAppointmentConfirmedTemplate = `
|
|
14
|
-
<!DOCTYPE html>
|
|
15
|
-
<html lang="en">
|
|
16
|
-
<head>
|
|
17
|
-
<meta charset="UTF-8">
|
|
18
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
19
|
-
<title>Appointment Confirmed</title>
|
|
20
|
-
<!--[if mso]>
|
|
21
|
-
<noscript>
|
|
22
|
-
<xml>
|
|
23
|
-
<o:OfficeDocumentSettings>
|
|
24
|
-
<o:PixelsPerInch>96</o:PixelsPerInch>
|
|
25
|
-
</o:OfficeDocumentSettings>
|
|
26
|
-
</xml>
|
|
27
|
-
</noscript>
|
|
28
|
-
<![endif]-->
|
|
29
|
-
</head>
|
|
30
|
-
<body style="margin: 0; padding: 0; background-color: #f8f6f5; font-family: Georgia, 'Times New Roman', serif;">
|
|
31
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #f8f6f5;">
|
|
32
|
-
<tr>
|
|
33
|
-
<td align="center" style="padding: 40px 20px;">
|
|
34
|
-
<table role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" style="max-width: 600px; background-color: #ffffff; border-radius: 2px; box-shadow: 0 1px 3px rgba(103, 87, 74, 0.08);">
|
|
35
|
-
|
|
36
|
-
<!-- Header -->
|
|
37
|
-
<tr>
|
|
38
|
-
<td style="padding: 48px 48px 32px 48px; border-bottom: 1px solid #f0ebe6;">
|
|
39
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
40
|
-
<tr>
|
|
41
|
-
<td>
|
|
42
|
-
<h1 style="margin: 0; font-size: 24px; font-weight: 400; color: #67574A; letter-spacing: 2px; text-transform: uppercase; font-family: Georgia, 'Times New Roman', serif;">Metaesthetics</h1>
|
|
43
|
-
</td>
|
|
44
|
-
</tr>
|
|
45
|
-
</table>
|
|
46
|
-
</td>
|
|
47
|
-
</tr>
|
|
48
|
-
|
|
49
|
-
<!-- Confirmed Banner -->
|
|
50
|
-
<tr>
|
|
51
|
-
<td style="padding: 0;">
|
|
52
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #00BB38;">
|
|
53
|
-
<tr>
|
|
54
|
-
<td style="padding: 20px 48px;">
|
|
55
|
-
<p style="margin: 0; font-size: 13px; font-weight: 600; color: #ffffff; letter-spacing: 1.5px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Appointment Confirmed</p>
|
|
56
|
-
</td>
|
|
57
|
-
</tr>
|
|
58
|
-
</table>
|
|
59
|
-
</td>
|
|
60
|
-
</tr>
|
|
61
|
-
|
|
62
|
-
<!-- Main Content -->
|
|
63
|
-
<tr>
|
|
64
|
-
<td style="padding: 40px 48px;">
|
|
65
|
-
|
|
66
|
-
<!-- Greeting -->
|
|
67
|
-
<p style="margin: 0 0 24px 0; font-size: 17px; color: #333333; line-height: 1.6; font-family: Georgia, 'Times New Roman', serif;">
|
|
68
|
-
Dear {{patientName}},
|
|
69
|
-
</p>
|
|
70
|
-
|
|
71
|
-
<p style="margin: 0 0 32px 0; font-size: 16px; color: #555555; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
72
|
-
Your appointment has been confirmed. We look forward to seeing you.
|
|
73
|
-
</p>
|
|
74
|
-
|
|
75
|
-
<!-- Appointment Details Card -->
|
|
76
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px; background-color: #faf9f7; border-left: 3px solid #00BB38;">
|
|
77
|
-
<tr>
|
|
78
|
-
<td style="padding: 24px;">
|
|
79
|
-
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #868686; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Procedure</p>
|
|
80
|
-
<p style="margin: 0 0 20px 0; font-size: 18px; color: #67574A; font-weight: 500; font-family: Georgia, 'Times New Roman', serif;">{{procedureName}}</p>
|
|
81
|
-
|
|
82
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
83
|
-
<tr>
|
|
84
|
-
<td style="padding-bottom: 16px;">
|
|
85
|
-
<p style="margin: 0 0 2px 0; font-size: 11px; color: #868686; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Date & Time</p>
|
|
86
|
-
<p style="margin: 0; font-size: 15px; color: #333333; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{appointmentDate}}</p>
|
|
87
|
-
<p style="margin: 4px 0 0 0; font-size: 14px; color: #67574A; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{appointmentTime}}</p>
|
|
88
|
-
</td>
|
|
89
|
-
</tr>
|
|
90
|
-
<tr>
|
|
91
|
-
<td style="padding-bottom: 16px;">
|
|
92
|
-
<p style="margin: 0 0 2px 0; font-size: 11px; color: #868686; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Practitioner</p>
|
|
93
|
-
<p style="margin: 0; font-size: 15px; color: #333333; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{practitionerName}}</p>
|
|
94
|
-
</td>
|
|
95
|
-
</tr>
|
|
96
|
-
<tr>
|
|
97
|
-
<td>
|
|
98
|
-
<p style="margin: 0 0 2px 0; font-size: 11px; color: #868686; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Location</p>
|
|
99
|
-
<p style="margin: 0; font-size: 15px; color: #333333; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{clinicName}}</p>
|
|
100
|
-
<p style="margin: 4px 0 0 0; font-size: 13px; color: #555555; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{clinicAddress}}</p>
|
|
101
|
-
</td>
|
|
102
|
-
</tr>
|
|
103
|
-
</table>
|
|
104
|
-
</td>
|
|
105
|
-
</tr>
|
|
106
|
-
</table>
|
|
107
|
-
|
|
108
|
-
<!-- Divider -->
|
|
109
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
|
|
110
|
-
<tr>
|
|
111
|
-
<td style="height: 1px; background-color: #e8e4df;"></td>
|
|
112
|
-
</tr>
|
|
113
|
-
</table>
|
|
114
|
-
|
|
115
|
-
<!-- Important Notice -->
|
|
116
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 24px;">
|
|
117
|
-
<tr>
|
|
118
|
-
<td style="padding: 20px 24px; background-color: #faf9f7; border-left: 3px solid #a48a76;">
|
|
119
|
-
<p style="margin: 0 0 8px 0; font-size: 13px; font-weight: 600; color: #67574A; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Before Your Visit</p>
|
|
120
|
-
<p style="margin: 0; font-size: 14px; color: #555555; line-height: 1.6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
121
|
-
Please arrive 15 minutes early. If you need to reschedule or cancel, contact us through the Metaesthetics app.
|
|
122
|
-
</p>
|
|
123
|
-
</td>
|
|
124
|
-
</tr>
|
|
125
|
-
</table>
|
|
126
|
-
|
|
127
|
-
<!-- Thank You -->
|
|
128
|
-
<p style="margin: 0; font-size: 14px; color: #868686; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
129
|
-
Thank you for choosing {{clinicName}}. We look forward to providing you with exceptional care.
|
|
130
|
-
</p>
|
|
131
|
-
|
|
132
|
-
</td>
|
|
133
|
-
</tr>
|
|
134
|
-
|
|
135
|
-
<!-- Footer -->
|
|
136
|
-
<tr>
|
|
137
|
-
<td style="padding: 32px 48px; background-color: #faf9f7; border-top: 1px solid #f0ebe6;">
|
|
138
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
139
|
-
<tr>
|
|
140
|
-
<td>
|
|
141
|
-
<p style="margin: 0 0 8px 0; font-size: 14px; font-weight: 500; color: #67574A; font-family: Georgia, 'Times New Roman', serif;">{{clinicName}}</p>
|
|
142
|
-
<p style="margin: 0 0 16px 0; font-size: 13px; color: #868686; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Premium Aesthetic Services</p>
|
|
143
|
-
<p style="margin: 0; font-size: 11px; color: #aaaaaa; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">This is an automated message from Metaesthetics. Please do not reply directly to this email.</p>
|
|
144
|
-
</td>
|
|
145
|
-
</tr>
|
|
146
|
-
</table>
|
|
147
|
-
</td>
|
|
148
|
-
</tr>
|
|
149
|
-
|
|
150
|
-
</table>
|
|
151
|
-
</td>
|
|
152
|
-
</tr>
|
|
153
|
-
</table>
|
|
154
|
-
</body>
|
|
155
|
-
</html>
|
|
156
|
-
`;
|
|
157
|
-
const clinicAppointmentRequestedTemplate = `
|
|
158
|
-
<!DOCTYPE html>
|
|
159
|
-
<html lang="en">
|
|
160
|
-
<head>
|
|
161
|
-
<meta charset="UTF-8">
|
|
162
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
163
|
-
<title>New Appointment Request</title>
|
|
164
|
-
<style>
|
|
165
|
-
body {
|
|
166
|
-
margin: 0;
|
|
167
|
-
padding: 0;
|
|
168
|
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
169
|
-
background: linear-gradient(135deg, #a48a76 0%, #67574A 100%);
|
|
170
|
-
min-height: 100vh;
|
|
171
|
-
}
|
|
172
|
-
.email-container {
|
|
173
|
-
max-width: 600px;
|
|
174
|
-
margin: 0 auto;
|
|
175
|
-
background: #ffffff;
|
|
176
|
-
border-radius: 20px;
|
|
177
|
-
overflow: hidden;
|
|
178
|
-
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
|
|
179
|
-
margin-top: 40px;
|
|
180
|
-
margin-bottom: 40px;
|
|
181
|
-
}
|
|
182
|
-
.header {
|
|
183
|
-
background: linear-gradient(135deg, #a48a76 0%, #67574A 100%);
|
|
184
|
-
padding: 40px 30px;
|
|
185
|
-
text-align: center;
|
|
186
|
-
color: white;
|
|
187
|
-
}
|
|
188
|
-
.header h1 {
|
|
189
|
-
margin: 0;
|
|
190
|
-
font-size: 28px;
|
|
191
|
-
font-weight: 300;
|
|
192
|
-
letter-spacing: 1px;
|
|
193
|
-
}
|
|
194
|
-
.header .subtitle {
|
|
195
|
-
margin: 10px 0 0 0;
|
|
196
|
-
font-size: 16px;
|
|
197
|
-
opacity: 0.9;
|
|
198
|
-
font-weight: 300;
|
|
199
|
-
}
|
|
200
|
-
.content {
|
|
201
|
-
padding: 40px 30px;
|
|
202
|
-
}
|
|
203
|
-
.greeting {
|
|
204
|
-
font-size: 18px;
|
|
205
|
-
color: #333;
|
|
206
|
-
margin-bottom: 25px;
|
|
207
|
-
font-weight: 400;
|
|
208
|
-
}
|
|
209
|
-
.appointment-card {
|
|
210
|
-
background: linear-gradient(135deg, #f8f6f5 0%, #f5f3f2 100%);
|
|
211
|
-
border-radius: 15px;
|
|
212
|
-
padding: 30px;
|
|
213
|
-
margin: 25px 0;
|
|
214
|
-
border-left: 5px solid #a48a76;
|
|
215
|
-
}
|
|
216
|
-
.appointment-title {
|
|
217
|
-
font-size: 20px;
|
|
218
|
-
color: #a48a76;
|
|
219
|
-
margin-bottom: 20px;
|
|
220
|
-
font-weight: 600;
|
|
221
|
-
}
|
|
222
|
-
.appointment-details {
|
|
223
|
-
display: grid;
|
|
224
|
-
gap: 15px;
|
|
225
|
-
}
|
|
226
|
-
.detail-row {
|
|
227
|
-
display: flex;
|
|
228
|
-
align-items: center;
|
|
229
|
-
padding: 8px 0;
|
|
230
|
-
}
|
|
231
|
-
.detail-label {
|
|
232
|
-
font-weight: 600;
|
|
233
|
-
color: #555;
|
|
234
|
-
min-width: 120px;
|
|
235
|
-
font-size: 14px;
|
|
236
|
-
}
|
|
237
|
-
.detail-value {
|
|
238
|
-
color: #333;
|
|
239
|
-
font-size: 16px;
|
|
240
|
-
font-weight: 500;
|
|
241
|
-
}
|
|
242
|
-
.patient-name {
|
|
243
|
-
color: #a48a76;
|
|
244
|
-
font-weight: 600;
|
|
245
|
-
}
|
|
246
|
-
.procedure-name {
|
|
247
|
-
color: #67574A;
|
|
248
|
-
font-weight: 600;
|
|
249
|
-
}
|
|
250
|
-
.cta-section {
|
|
251
|
-
text-align: center;
|
|
252
|
-
margin: 35px 0;
|
|
253
|
-
}
|
|
254
|
-
.cta-button {
|
|
255
|
-
display: inline-block;
|
|
256
|
-
background: linear-gradient(135deg, #a48a76 0%, #67574A 100%);
|
|
257
|
-
color: white;
|
|
258
|
-
text-decoration: none;
|
|
259
|
-
padding: 15px 35px;
|
|
260
|
-
border-radius: 50px;
|
|
261
|
-
font-weight: 600;
|
|
262
|
-
font-size: 16px;
|
|
263
|
-
letter-spacing: 0.5px;
|
|
264
|
-
transition: transform 0.3s ease;
|
|
265
|
-
box-shadow: 0 8px 25px rgba(164, 138, 118, 0.3);
|
|
266
|
-
}
|
|
267
|
-
.cta-button:hover {
|
|
268
|
-
transform: translateY(-2px);
|
|
269
|
-
}
|
|
270
|
-
.footer {
|
|
271
|
-
background: #f8f9fa;
|
|
272
|
-
padding: 25px 30px;
|
|
273
|
-
text-align: center;
|
|
274
|
-
color: #666;
|
|
275
|
-
font-size: 14px;
|
|
276
|
-
border-top: 1px solid #eee;
|
|
277
|
-
}
|
|
278
|
-
.logo {
|
|
279
|
-
font-size: 24px;
|
|
280
|
-
font-weight: 700;
|
|
281
|
-
color: white;
|
|
282
|
-
margin-bottom: 5px;
|
|
283
|
-
}
|
|
284
|
-
.divider {
|
|
285
|
-
height: 2px;
|
|
286
|
-
background: linear-gradient(90deg, #a48a76, #67574A);
|
|
287
|
-
margin: 25px 0;
|
|
288
|
-
border-radius: 1px;
|
|
289
|
-
}
|
|
290
|
-
</style>
|
|
291
|
-
</head>
|
|
292
|
-
<body>
|
|
293
|
-
<div class="email-container">
|
|
294
|
-
<div class="header">
|
|
295
|
-
<div class="logo">Metaesthetics</div>
|
|
296
|
-
<h1>New Appointment Request</h1>
|
|
297
|
-
<div class="subtitle">Requires Your Attention</div>
|
|
298
|
-
</div>
|
|
299
|
-
|
|
300
|
-
<div class="content">
|
|
301
|
-
<div class="greeting">
|
|
302
|
-
Dear <strong>{{clinicName}}</strong> Team,
|
|
303
|
-
</div>
|
|
304
|
-
|
|
305
|
-
<p style="color: #555; font-size: 16px; line-height: 1.6; margin-bottom: 25px;">
|
|
306
|
-
We hope this message finds you well. You have received a new appointment request that requires your review and confirmation.
|
|
307
|
-
</p>
|
|
308
|
-
|
|
309
|
-
<div class="appointment-card">
|
|
310
|
-
<div class="appointment-title">📅 Appointment Details</div>
|
|
311
|
-
<div class="appointment-details">
|
|
312
|
-
<div class="detail-row">
|
|
313
|
-
<div class="detail-label">Patient:</div>
|
|
314
|
-
<div class="detail-value patient-name">{{patientName}}</div>
|
|
315
|
-
</div>
|
|
316
|
-
<div class="detail-row">
|
|
317
|
-
<div class="detail-label">Procedure:</div>
|
|
318
|
-
<div class="detail-value procedure-name">{{procedureName}}</div>
|
|
319
|
-
</div>
|
|
320
|
-
<div class="detail-row">
|
|
321
|
-
<div class="detail-label">Date:</div>
|
|
322
|
-
<div class="detail-value">{{appointmentDate}}</div>
|
|
323
|
-
</div>
|
|
324
|
-
<div class="detail-row">
|
|
325
|
-
<div class="detail-label">Time:</div>
|
|
326
|
-
<div class="detail-value">{{appointmentTime}}</div>
|
|
327
|
-
</div>
|
|
328
|
-
<div class="detail-row">
|
|
329
|
-
<div class="detail-label">Practitioner:</div>
|
|
330
|
-
<div class="detail-value">{{practitionerName}}</div>
|
|
331
|
-
</div>
|
|
332
|
-
</div>
|
|
333
|
-
</div>
|
|
334
|
-
|
|
335
|
-
<div class="divider"></div>
|
|
336
|
-
|
|
337
|
-
<p style="color: #555; font-size: 16px; line-height: 1.6; margin-bottom: 30px;">
|
|
338
|
-
Please review this appointment request and confirm availability in your admin panel. The patient is waiting for your confirmation to finalize their booking.
|
|
339
|
-
</p>
|
|
340
|
-
|
|
341
|
-
<div class="cta-section">
|
|
342
|
-
<a href="#" class="cta-button">Review & Confirm Appointment</a>
|
|
343
|
-
</div>
|
|
344
|
-
</div>
|
|
345
|
-
|
|
346
|
-
<div class="footer">
|
|
347
|
-
<p style="margin: 0 0 10px 0;">
|
|
348
|
-
<strong>Metaesthetics</strong> - Premium Aesthetic Services
|
|
349
|
-
</p>
|
|
350
|
-
<p style="margin: 0; font-size: 12px; color: #999;">
|
|
351
|
-
This is an automated message. Please do not reply to this email.
|
|
352
|
-
</p>
|
|
353
|
-
</div>
|
|
354
|
-
</div>
|
|
355
|
-
</body>
|
|
356
|
-
</html>
|
|
357
|
-
`;
|
|
358
|
-
|
|
359
|
-
const appointmentCancelledTemplate = `
|
|
360
|
-
<!DOCTYPE html>
|
|
361
|
-
<html lang="en">
|
|
362
|
-
<head>
|
|
363
|
-
<meta charset="UTF-8">
|
|
364
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
365
|
-
<title>Appointment Cancelled</title>
|
|
366
|
-
<!--[if mso]>
|
|
367
|
-
<noscript>
|
|
368
|
-
<xml>
|
|
369
|
-
<o:OfficeDocumentSettings>
|
|
370
|
-
<o:PixelsPerInch>96</o:PixelsPerInch>
|
|
371
|
-
</o:OfficeDocumentSettings>
|
|
372
|
-
</xml>
|
|
373
|
-
</noscript>
|
|
374
|
-
<![endif]-->
|
|
375
|
-
</head>
|
|
376
|
-
<body style="margin: 0; padding: 0; background-color: #f8f6f5; font-family: Georgia, 'Times New Roman', serif;">
|
|
377
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #f8f6f5;">
|
|
378
|
-
<tr>
|
|
379
|
-
<td align="center" style="padding: 40px 20px;">
|
|
380
|
-
<table role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" style="max-width: 600px; background-color: #ffffff; border-radius: 2px; box-shadow: 0 1px 3px rgba(103, 87, 74, 0.08);">
|
|
381
|
-
|
|
382
|
-
<!-- Header -->
|
|
383
|
-
<tr>
|
|
384
|
-
<td style="padding: 48px 48px 32px 48px; border-bottom: 1px solid #f0ebe6;">
|
|
385
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
386
|
-
<tr>
|
|
387
|
-
<td>
|
|
388
|
-
<h1 style="margin: 0; font-size: 24px; font-weight: 400; color: #67574A; letter-spacing: 2px; text-transform: uppercase; font-family: Georgia, 'Times New Roman', serif;">Metaesthetics</h1>
|
|
389
|
-
</td>
|
|
390
|
-
</tr>
|
|
391
|
-
</table>
|
|
392
|
-
</td>
|
|
393
|
-
</tr>
|
|
394
|
-
|
|
395
|
-
<!-- Cancellation Banner -->
|
|
396
|
-
<tr>
|
|
397
|
-
<td style="padding: 0;">
|
|
398
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #fa003f;">
|
|
399
|
-
<tr>
|
|
400
|
-
<td style="padding: 20px 48px;">
|
|
401
|
-
<p style="margin: 0; font-size: 13px; font-weight: 600; color: #ffffff; letter-spacing: 1.5px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Appointment Cancelled</p>
|
|
402
|
-
</td>
|
|
403
|
-
</tr>
|
|
404
|
-
</table>
|
|
405
|
-
</td>
|
|
406
|
-
</tr>
|
|
407
|
-
|
|
408
|
-
<!-- Main Content -->
|
|
409
|
-
<tr>
|
|
410
|
-
<td style="padding: 40px 48px;">
|
|
411
|
-
|
|
412
|
-
<!-- Greeting -->
|
|
413
|
-
<p style="margin: 0 0 24px 0; font-size: 17px; color: #333333; line-height: 1.6; font-family: Georgia, 'Times New Roman', serif;">
|
|
414
|
-
Dear {{recipientName}},
|
|
415
|
-
</p>
|
|
416
|
-
|
|
417
|
-
<p style="margin: 0 0 32px 0; font-size: 16px; color: #555555; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
418
|
-
We regret to inform you that your appointment has been cancelled. Please see the details below.
|
|
419
|
-
</p>
|
|
420
|
-
|
|
421
|
-
<!-- Cancelled By Info -->
|
|
422
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 24px;">
|
|
423
|
-
<tr>
|
|
424
|
-
<td style="padding: 16px 20px; background-color: #fef2f2; border-left: 3px solid #fa003f;">
|
|
425
|
-
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #868686; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Cancelled By</p>
|
|
426
|
-
<p style="margin: 0; font-size: 15px; color: #333333; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{cancelledByDisplay}}</p>
|
|
427
|
-
</td>
|
|
428
|
-
</tr>
|
|
429
|
-
</table>
|
|
430
|
-
|
|
431
|
-
{{#if cancellationReason}}
|
|
432
|
-
<!-- Cancellation Reason -->
|
|
433
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
|
|
434
|
-
<tr>
|
|
435
|
-
<td style="padding: 20px 24px; background-color: #faf9f7; border-left: 3px solid #a48a76;">
|
|
436
|
-
<p style="margin: 0 0 8px 0; font-size: 11px; font-weight: 600; color: #868686; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Reason</p>
|
|
437
|
-
<p style="margin: 0; font-size: 15px; color: #555555; line-height: 1.6; font-style: italic; font-family: Georgia, 'Times New Roman', serif;">"{{cancellationReason}}"</p>
|
|
438
|
-
</td>
|
|
439
|
-
</tr>
|
|
440
|
-
</table>
|
|
441
|
-
{{/if}}
|
|
442
|
-
|
|
443
|
-
<!-- Cancelled Appointment Details -->
|
|
444
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px; background-color: #f5f5f5; border-left: 3px solid #cccccc;">
|
|
445
|
-
<tr>
|
|
446
|
-
<td style="padding: 24px;">
|
|
447
|
-
<p style="margin: 0 0 16px 0; font-size: 12px; font-weight: 600; color: #999999; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Cancelled Appointment</p>
|
|
448
|
-
|
|
449
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
450
|
-
<tr>
|
|
451
|
-
<td style="padding-bottom: 12px;">
|
|
452
|
-
<p style="margin: 0 0 2px 0; font-size: 11px; color: #999999; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Procedure</p>
|
|
453
|
-
<p style="margin: 0; font-size: 15px; color: #888888; text-decoration: line-through; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{procedureName}}</p>
|
|
454
|
-
</td>
|
|
455
|
-
</tr>
|
|
456
|
-
<tr>
|
|
457
|
-
<td style="padding-bottom: 12px;">
|
|
458
|
-
<p style="margin: 0 0 2px 0; font-size: 11px; color: #999999; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Date & Time</p>
|
|
459
|
-
<p style="margin: 0; font-size: 15px; color: #888888; text-decoration: line-through; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{appointmentDate}} at {{appointmentTime}}</p>
|
|
460
|
-
</td>
|
|
461
|
-
</tr>
|
|
462
|
-
<tr>
|
|
463
|
-
<td style="padding-bottom: 12px;">
|
|
464
|
-
<p style="margin: 0 0 2px 0; font-size: 11px; color: #999999; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Practitioner</p>
|
|
465
|
-
<p style="margin: 0; font-size: 15px; color: #888888; text-decoration: line-through; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{practitionerName}}</p>
|
|
466
|
-
</td>
|
|
467
|
-
</tr>
|
|
468
|
-
<tr>
|
|
469
|
-
<td>
|
|
470
|
-
<p style="margin: 0 0 2px 0; font-size: 11px; color: #999999; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Location</p>
|
|
471
|
-
<p style="margin: 0; font-size: 15px; color: #888888; text-decoration: line-through; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{clinicName}}</p>
|
|
472
|
-
<p style="margin: 4px 0 0 0; font-size: 13px; color: #999999; text-decoration: line-through; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{clinicAddress}}</p>
|
|
473
|
-
</td>
|
|
474
|
-
</tr>
|
|
475
|
-
</table>
|
|
476
|
-
</td>
|
|
477
|
-
</tr>
|
|
478
|
-
</table>
|
|
479
|
-
|
|
480
|
-
<!-- Divider -->
|
|
481
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
|
|
482
|
-
<tr>
|
|
483
|
-
<td style="height: 1px; background-color: #e8e4df;"></td>
|
|
484
|
-
</tr>
|
|
485
|
-
</table>
|
|
486
|
-
|
|
487
|
-
<!-- Rebook Section -->
|
|
488
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 24px; background-color: #f0faf4; border-left: 3px solid #00BB38;">
|
|
489
|
-
<tr>
|
|
490
|
-
<td style="padding: 24px;">
|
|
491
|
-
<p style="margin: 0 0 8px 0; font-size: 14px; font-weight: 600; color: #00BB38; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Book a New Appointment</p>
|
|
492
|
-
<p style="margin: 0; font-size: 14px; color: #555555; line-height: 1.6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
493
|
-
We'd love to see you again. Open the Metaesthetics app to browse available times and book a new appointment.
|
|
494
|
-
</p>
|
|
495
|
-
</td>
|
|
496
|
-
</tr>
|
|
497
|
-
</table>
|
|
498
|
-
|
|
499
|
-
<!-- Support Info -->
|
|
500
|
-
<p style="margin: 0; font-size: 13px; color: #868686; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
501
|
-
If you have any questions about this cancellation, please contact {{clinicName}} through the Metaesthetics app.
|
|
502
|
-
</p>
|
|
503
|
-
|
|
504
|
-
</td>
|
|
505
|
-
</tr>
|
|
506
|
-
|
|
507
|
-
<!-- Footer -->
|
|
508
|
-
<tr>
|
|
509
|
-
<td style="padding: 32px 48px; background-color: #faf9f7; border-top: 1px solid #f0ebe6;">
|
|
510
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
511
|
-
<tr>
|
|
512
|
-
<td>
|
|
513
|
-
<p style="margin: 0 0 8px 0; font-size: 14px; font-weight: 500; color: #67574A; font-family: Georgia, 'Times New Roman', serif;">{{clinicName}}</p>
|
|
514
|
-
<p style="margin: 0 0 16px 0; font-size: 13px; color: #868686; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Premium Aesthetic Services</p>
|
|
515
|
-
<p style="margin: 0; font-size: 11px; color: #aaaaaa; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">This is an automated message from Metaesthetics. Please do not reply directly to this email.</p>
|
|
516
|
-
</td>
|
|
517
|
-
</tr>
|
|
518
|
-
</table>
|
|
519
|
-
</td>
|
|
520
|
-
</tr>
|
|
521
|
-
|
|
522
|
-
</table>
|
|
523
|
-
</td>
|
|
524
|
-
</tr>
|
|
525
|
-
</table>
|
|
526
|
-
</body>
|
|
527
|
-
</html>
|
|
528
|
-
`;
|
|
529
|
-
|
|
530
|
-
const appointmentRescheduledProposalTemplate = `
|
|
531
|
-
<!DOCTYPE html>
|
|
532
|
-
<html lang="en">
|
|
533
|
-
<head>
|
|
534
|
-
<meta charset="UTF-8">
|
|
535
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
536
|
-
<title>Appointment Reschedule Request</title>
|
|
537
|
-
<!--[if mso]>
|
|
538
|
-
<noscript>
|
|
539
|
-
<xml>
|
|
540
|
-
<o:OfficeDocumentSettings>
|
|
541
|
-
<o:PixelsPerInch>96</o:PixelsPerInch>
|
|
542
|
-
</o:OfficeDocumentSettings>
|
|
543
|
-
</xml>
|
|
544
|
-
</noscript>
|
|
545
|
-
<![endif]-->
|
|
546
|
-
</head>
|
|
547
|
-
<body style="margin: 0; padding: 0; background-color: #f8f6f5; font-family: Georgia, 'Times New Roman', serif;">
|
|
548
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #f8f6f5;">
|
|
549
|
-
<tr>
|
|
550
|
-
<td align="center" style="padding: 40px 20px;">
|
|
551
|
-
<table role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" style="max-width: 600px; background-color: #ffffff; border-radius: 2px; box-shadow: 0 1px 3px rgba(103, 87, 74, 0.08);">
|
|
552
|
-
|
|
553
|
-
<!-- Header -->
|
|
554
|
-
<tr>
|
|
555
|
-
<td style="padding: 48px 48px 32px 48px; border-bottom: 1px solid #f0ebe6;">
|
|
556
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
557
|
-
<tr>
|
|
558
|
-
<td>
|
|
559
|
-
<h1 style="margin: 0; font-size: 24px; font-weight: 400; color: #67574A; letter-spacing: 2px; text-transform: uppercase; font-family: Georgia, 'Times New Roman', serif;">Metaesthetics</h1>
|
|
560
|
-
</td>
|
|
561
|
-
</tr>
|
|
562
|
-
</table>
|
|
563
|
-
</td>
|
|
564
|
-
</tr>
|
|
565
|
-
|
|
566
|
-
<!-- Action Required Banner -->
|
|
567
|
-
<tr>
|
|
568
|
-
<td style="padding: 0;">
|
|
569
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #a48a76;">
|
|
570
|
-
<tr>
|
|
571
|
-
<td style="padding: 20px 48px;">
|
|
572
|
-
<p style="margin: 0; font-size: 13px; font-weight: 600; color: #ffffff; letter-spacing: 1.5px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Action Required</p>
|
|
573
|
-
</td>
|
|
574
|
-
</tr>
|
|
575
|
-
</table>
|
|
576
|
-
</td>
|
|
577
|
-
</tr>
|
|
578
|
-
|
|
579
|
-
<!-- Main Content -->
|
|
580
|
-
<tr>
|
|
581
|
-
<td style="padding: 40px 48px;">
|
|
582
|
-
|
|
583
|
-
<!-- Greeting -->
|
|
584
|
-
<p style="margin: 0 0 24px 0; font-size: 17px; color: #333333; line-height: 1.6; font-family: Georgia, 'Times New Roman', serif;">
|
|
585
|
-
Dear {{patientName}},
|
|
586
|
-
</p>
|
|
587
|
-
|
|
588
|
-
<p style="margin: 0 0 32px 0; font-size: 16px; color: #555555; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
589
|
-
{{clinicName}} has proposed a new time for your upcoming appointment. Please review the details below and respond at your earliest convenience.
|
|
590
|
-
</p>
|
|
591
|
-
|
|
592
|
-
<!-- Appointment Info Card -->
|
|
593
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px; background-color: #faf9f7; border-left: 3px solid #a48a76;">
|
|
594
|
-
<tr>
|
|
595
|
-
<td style="padding: 24px;">
|
|
596
|
-
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #868686; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Procedure</p>
|
|
597
|
-
<p style="margin: 0 0 16px 0; font-size: 18px; color: #67574A; font-weight: 500; font-family: Georgia, 'Times New Roman', serif;">{{procedureName}}</p>
|
|
598
|
-
|
|
599
|
-
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #868686; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Practitioner</p>
|
|
600
|
-
<p style="margin: 0; font-size: 15px; color: #333333; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{practitionerName}}</p>
|
|
601
|
-
</td>
|
|
602
|
-
</tr>
|
|
603
|
-
</table>
|
|
604
|
-
|
|
605
|
-
<!-- Time Comparison -->
|
|
606
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
|
|
607
|
-
<!-- Original Time (Strikethrough) -->
|
|
608
|
-
<tr>
|
|
609
|
-
<td style="padding: 20px 24px; background-color: #f5f5f5; border-left: 3px solid #cccccc;">
|
|
610
|
-
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #999999; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Original Appointment</p>
|
|
611
|
-
<p style="margin: 0; font-size: 16px; color: #999999; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; text-decoration: line-through;">{{previousDate}}</p>
|
|
612
|
-
<p style="margin: 4px 0 0 0; font-size: 14px; color: #999999; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; text-decoration: line-through;">{{previousTime}}</p>
|
|
613
|
-
</td>
|
|
614
|
-
</tr>
|
|
615
|
-
|
|
616
|
-
<!-- Spacer -->
|
|
617
|
-
<tr>
|
|
618
|
-
<td style="height: 12px;"></td>
|
|
619
|
-
</tr>
|
|
620
|
-
|
|
621
|
-
<!-- New Proposed Time -->
|
|
622
|
-
<tr>
|
|
623
|
-
<td style="padding: 24px; background-color: #f8f6f5; border-left: 3px solid #00BB38;">
|
|
624
|
-
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #00BB38; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Proposed New Time</p>
|
|
625
|
-
<p style="margin: 0; font-size: 18px; color: #333333; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{newDate}}</p>
|
|
626
|
-
<p style="margin: 4px 0 0 0; font-size: 15px; color: #67574A; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{newTime}}</p>
|
|
627
|
-
</td>
|
|
628
|
-
</tr>
|
|
629
|
-
</table>
|
|
630
|
-
|
|
631
|
-
<!-- Divider -->
|
|
632
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
|
|
633
|
-
<tr>
|
|
634
|
-
<td style="height: 1px; background-color: #e8e4df;"></td>
|
|
635
|
-
</tr>
|
|
636
|
-
</table>
|
|
637
|
-
|
|
638
|
-
<!-- Response Instructions -->
|
|
639
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px; background-color: #faf9f7;">
|
|
640
|
-
<tr>
|
|
641
|
-
<td style="padding: 28px;">
|
|
642
|
-
<p style="margin: 0 0 8px 0; font-size: 14px; font-weight: 600; color: #67574A; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">How to Respond</p>
|
|
643
|
-
<p style="margin: 0; font-size: 14px; color: #555555; line-height: 1.6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
644
|
-
Open the Metaesthetics app to accept or decline this reschedule request. Your appointment will remain pending until you respond.
|
|
645
|
-
</p>
|
|
646
|
-
</td>
|
|
647
|
-
</tr>
|
|
648
|
-
</table>
|
|
649
|
-
|
|
650
|
-
<!-- Response Notice -->
|
|
651
|
-
<p style="margin: 0; font-size: 13px; color: #868686; line-height: 1.6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
652
|
-
Please respond at your earliest convenience so we can finalize your appointment. If you have questions, contact {{clinicName}} through the app.
|
|
653
|
-
</p>
|
|
654
|
-
|
|
655
|
-
</td>
|
|
656
|
-
</tr>
|
|
657
|
-
|
|
658
|
-
<!-- Footer -->
|
|
659
|
-
<tr>
|
|
660
|
-
<td style="padding: 32px 48px; background-color: #faf9f7; border-top: 1px solid #f0ebe6;">
|
|
661
|
-
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
662
|
-
<tr>
|
|
663
|
-
<td>
|
|
664
|
-
<p style="margin: 0 0 8px 0; font-size: 14px; font-weight: 500; color: #67574A; font-family: Georgia, 'Times New Roman', serif;">{{clinicName}}</p>
|
|
665
|
-
<p style="margin: 0 0 16px 0; font-size: 13px; color: #868686; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Premium Aesthetic Services</p>
|
|
666
|
-
<p style="margin: 0; font-size: 11px; color: #aaaaaa; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">This is an automated message from Metaesthetics. Please do not reply directly to this email.</p>
|
|
667
|
-
</td>
|
|
668
|
-
</tr>
|
|
669
|
-
</table>
|
|
670
|
-
</td>
|
|
671
|
-
</tr>
|
|
672
|
-
|
|
673
|
-
</table>
|
|
674
|
-
</td>
|
|
675
|
-
</tr>
|
|
676
|
-
</table>
|
|
677
|
-
</body>
|
|
678
|
-
</html>
|
|
679
|
-
`;
|
|
680
|
-
|
|
681
|
-
// --- Interface Definitions for Email Data ---
|
|
682
|
-
|
|
683
|
-
export interface AppointmentEmailDataBase {
|
|
684
|
-
appointment: Appointment;
|
|
685
|
-
options?: {
|
|
686
|
-
customSubject?: string;
|
|
687
|
-
fromAddress?: string;
|
|
688
|
-
mailgunDomain?: string;
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
export interface AppointmentConfirmationEmailData extends AppointmentEmailDataBase {
|
|
693
|
-
recipientProfile: PatientProfileInfo | PractitionerProfileInfo;
|
|
694
|
-
recipientRole: 'patient' | 'practitioner';
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
export interface AppointmentRequestedEmailData extends AppointmentEmailDataBase {
|
|
698
|
-
clinicProfile: ClinicInfo;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
export interface AppointmentCancellationEmailData extends AppointmentEmailDataBase {
|
|
702
|
-
recipientProfile: PatientProfileInfo | PractitionerProfileInfo;
|
|
703
|
-
recipientRole: 'patient' | 'practitioner';
|
|
704
|
-
cancellationReason?: string;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
export interface AppointmentRescheduledProposalEmailData extends AppointmentEmailDataBase {
|
|
708
|
-
patientProfile: PatientProfileInfo;
|
|
709
|
-
previousStartTime: admin.firestore.Timestamp;
|
|
710
|
-
previousEndTime: admin.firestore.Timestamp;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
export interface ReviewRequestEmailData extends AppointmentEmailDataBase {
|
|
714
|
-
patientProfile: PatientProfileInfo;
|
|
715
|
-
reviewLink: string;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
export interface ReviewAddedEmailData extends AppointmentEmailDataBase {
|
|
719
|
-
recipientProfile: PractitionerProfileInfo | ClinicInfo;
|
|
720
|
-
recipientRole: 'practitioner' | 'clinic';
|
|
721
|
-
reviewerName: string;
|
|
722
|
-
reviewRating: number;
|
|
723
|
-
reviewComment?: string;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/**
|
|
727
|
-
* Service for sending appointment-related emails.
|
|
728
|
-
*/
|
|
729
|
-
export class AppointmentMailingService extends BaseMailingService {
|
|
730
|
-
private readonly DEFAULT_MAILGUN_DOMAIN = 'mg.metaesthetics.net';
|
|
731
|
-
|
|
732
|
-
constructor(firestore: admin.firestore.Firestore, mailgunClient: NewMailgunClient) {
|
|
733
|
-
super(firestore, mailgunClient);
|
|
734
|
-
Logger.info('[AppointmentMailingService] Initialized.');
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
/**
|
|
738
|
-
* Formats a Firestore Timestamp in the clinic's timezone
|
|
739
|
-
* @param timestamp - Firestore Timestamp (UTC)
|
|
740
|
-
* @param clinicTimezone - IANA timezone string (e.g., "Europe/Zurich")
|
|
741
|
-
* @param format - Format type: 'date', 'time', or 'datetime'
|
|
742
|
-
* @returns Formatted string in clinic's local timezone
|
|
743
|
-
*/
|
|
744
|
-
private formatTimestampInClinicTimezone(
|
|
745
|
-
timestamp: admin.firestore.Timestamp,
|
|
746
|
-
clinicTimezone: string,
|
|
747
|
-
format: 'date' | 'time' | 'datetime' = 'datetime',
|
|
748
|
-
): string {
|
|
749
|
-
try {
|
|
750
|
-
// Convert UTC timestamp to clinic's timezone
|
|
751
|
-
const dateTimeInClinicTz = DateTime.fromMillis(timestamp.toMillis(), {
|
|
752
|
-
zone: clinicTimezone,
|
|
753
|
-
});
|
|
754
|
-
|
|
755
|
-
// Format based on requested type
|
|
756
|
-
switch (format) {
|
|
757
|
-
case 'date':
|
|
758
|
-
// Format: "Monday, November 5, 2025"
|
|
759
|
-
return dateTimeInClinicTz.toLocaleString(DateTime.DATE_FULL);
|
|
760
|
-
case 'time':
|
|
761
|
-
// Format: "2:30 PM"
|
|
762
|
-
return dateTimeInClinicTz.toLocaleString(DateTime.TIME_SIMPLE);
|
|
763
|
-
case 'datetime':
|
|
764
|
-
// Format: "Monday, November 5, 2025 at 2:30 PM"
|
|
765
|
-
return dateTimeInClinicTz.toLocaleString(DateTime.DATETIME_FULL);
|
|
766
|
-
default:
|
|
767
|
-
return dateTimeInClinicTz.toLocaleString(DateTime.DATETIME_FULL);
|
|
768
|
-
}
|
|
769
|
-
} catch (error) {
|
|
770
|
-
Logger.error('[AppointmentMailingService] Error formatting timestamp in clinic timezone:', {
|
|
771
|
-
error: error instanceof Error ? error.message : String(error),
|
|
772
|
-
clinicTimezone,
|
|
773
|
-
});
|
|
774
|
-
// Fallback to UTC formatting if timezone conversion fails
|
|
775
|
-
return timestamp.toDate().toLocaleString();
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
/**
|
|
780
|
-
* Gets a user-friendly display name for a timezone
|
|
781
|
-
* @param timezone - IANA timezone string (e.g., "Europe/Zurich")
|
|
782
|
-
* @returns User-friendly timezone name (e.g., "Clinic Time - Europe/Zurich")
|
|
783
|
-
*/
|
|
784
|
-
private getTimezoneDisplayName(timezone: string): string {
|
|
785
|
-
try {
|
|
786
|
-
// For common timezones, provide a more readable format
|
|
787
|
-
const timezoneMap: Record<string, string> = {
|
|
788
|
-
'Europe/Zurich': 'Clinic Time - Central European Time',
|
|
789
|
-
'Europe/London': 'Clinic Time - GMT/BST',
|
|
790
|
-
'America/New_York': 'Clinic Time - Eastern Time',
|
|
791
|
-
'America/Los_Angeles': 'Clinic Time - Pacific Time',
|
|
792
|
-
'Asia/Dubai': 'Clinic Time - Gulf Standard Time',
|
|
793
|
-
'Asia/Karachi': 'Clinic Time - Pakistan Standard Time',
|
|
794
|
-
'Asia/Kolkata': 'Clinic Time - India Standard Time',
|
|
795
|
-
'Australia/Sydney': 'Clinic Time - Australian Eastern Time',
|
|
796
|
-
};
|
|
797
|
-
|
|
798
|
-
// Return mapped name if available, otherwise use the IANA timezone
|
|
799
|
-
return timezoneMap[timezone] || `Clinic Time - ${timezone}`;
|
|
800
|
-
} catch (error) {
|
|
801
|
-
Logger.error('[AppointmentMailingService] Error getting timezone display name:', {
|
|
802
|
-
error: error instanceof Error ? error.message : String(error),
|
|
803
|
-
timezone,
|
|
804
|
-
});
|
|
805
|
-
return `Clinic Time - ${timezone}`;
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
private formatClinicAddress(appointment: Appointment): string {
|
|
810
|
-
const loc = appointment.clinicInfo?.location;
|
|
811
|
-
if (!loc) return '';
|
|
812
|
-
const parts = [loc.address, loc.postalCode, loc.city, loc.country].filter(Boolean);
|
|
813
|
-
return parts.join(', ');
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
async sendAppointmentConfirmedEmail(data: AppointmentConfirmationEmailData): Promise<any> {
|
|
817
|
-
Logger.info(
|
|
818
|
-
`[AppointmentMailingService] Preparing to send appointment confirmation email to ${data.recipientRole}: ${data.recipientProfile.id}`,
|
|
819
|
-
);
|
|
820
|
-
|
|
821
|
-
const recipientEmail = data.recipientProfile.email;
|
|
822
|
-
|
|
823
|
-
if (!recipientEmail) {
|
|
824
|
-
Logger.error('[AppointmentMailingService] Recipient email not found for confirmation.', {
|
|
825
|
-
recipientId: data.recipientProfile.id,
|
|
826
|
-
role: data.recipientRole,
|
|
827
|
-
});
|
|
828
|
-
throw new Error('Recipient email address is missing.');
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
// Get clinic timezone from appointment data, default to UTC if not available
|
|
832
|
-
const clinicTimezone = data.appointment.clinic_tz || 'UTC';
|
|
833
|
-
|
|
834
|
-
Logger.debug('[AppointmentMailingService] Formatting appointment time', {
|
|
835
|
-
clinicTimezone,
|
|
836
|
-
utcTime: data.appointment.appointmentStartTime.toDate().toISOString(),
|
|
837
|
-
});
|
|
838
|
-
|
|
839
|
-
// Format time with timezone label for clarity
|
|
840
|
-
const formattedTime = this.formatTimestampInClinicTimezone(
|
|
841
|
-
data.appointment.appointmentStartTime,
|
|
842
|
-
clinicTimezone,
|
|
843
|
-
'time',
|
|
844
|
-
);
|
|
845
|
-
const timezoneName = this.getTimezoneDisplayName(clinicTimezone);
|
|
846
|
-
|
|
847
|
-
const templateVariables = {
|
|
848
|
-
patientName: data.appointment.patientInfo.fullName,
|
|
849
|
-
procedureName: data.appointment.procedureInfo.name,
|
|
850
|
-
appointmentDate: this.formatTimestampInClinicTimezone(
|
|
851
|
-
data.appointment.appointmentStartTime,
|
|
852
|
-
clinicTimezone,
|
|
853
|
-
'date',
|
|
854
|
-
),
|
|
855
|
-
appointmentTime: `${formattedTime} (${timezoneName})`,
|
|
856
|
-
practitionerName: data.appointment.practitionerInfo.name,
|
|
857
|
-
clinicName: data.appointment.clinicInfo.name,
|
|
858
|
-
clinicAddress: this.formatClinicAddress(data.appointment),
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
const html = this.renderTemplate(patientAppointmentConfirmedTemplate, templateVariables);
|
|
862
|
-
const subject = data.options?.customSubject || 'Your Appointment is Confirmed!';
|
|
863
|
-
const fromAddress =
|
|
864
|
-
data.options?.fromAddress ||
|
|
865
|
-
`Metaesthetics <no-reply@${data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN}>`;
|
|
866
|
-
const domainToSendFrom = data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN;
|
|
867
|
-
|
|
868
|
-
const mailgunSendData = {
|
|
869
|
-
to: recipientEmail,
|
|
870
|
-
from: fromAddress,
|
|
871
|
-
subject,
|
|
872
|
-
html,
|
|
873
|
-
};
|
|
874
|
-
|
|
875
|
-
try {
|
|
876
|
-
const result = await this.sendEmail(domainToSendFrom, mailgunSendData);
|
|
877
|
-
await this.logEmailAttempt(
|
|
878
|
-
{ to: recipientEmail, subject, templateName: 'appointment_confirmed' },
|
|
879
|
-
true,
|
|
880
|
-
);
|
|
881
|
-
return result;
|
|
882
|
-
} catch (error) {
|
|
883
|
-
await this.logEmailAttempt(
|
|
884
|
-
{
|
|
885
|
-
to: recipientEmail,
|
|
886
|
-
subject: data.options?.customSubject || 'Your Appointment is Confirmed!',
|
|
887
|
-
templateName: 'appointment_confirmed',
|
|
888
|
-
},
|
|
889
|
-
false,
|
|
890
|
-
error,
|
|
891
|
-
);
|
|
892
|
-
throw error;
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
async sendAppointmentRequestedEmailToClinic(data: AppointmentRequestedEmailData): Promise<any> {
|
|
897
|
-
Logger.info(
|
|
898
|
-
`[AppointmentMailingService] Preparing to send appointment requested email to clinic: ${data.clinicProfile.id}`,
|
|
899
|
-
);
|
|
900
|
-
|
|
901
|
-
const clinicEmail = data.clinicProfile.contactInfo?.email;
|
|
902
|
-
if (!clinicEmail) {
|
|
903
|
-
Logger.error(
|
|
904
|
-
'[AppointmentMailingService] Clinic contact email not found for request notification.',
|
|
905
|
-
{ clinicId: data.clinicProfile.id },
|
|
906
|
-
);
|
|
907
|
-
throw new Error('Clinic contact email address is missing.');
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
// Get clinic timezone from appointment data, default to UTC if not available
|
|
911
|
-
const clinicTimezone = data.appointment.clinic_tz || 'UTC';
|
|
912
|
-
|
|
913
|
-
Logger.debug('[AppointmentMailingService] Formatting appointment time for clinic', {
|
|
914
|
-
clinicTimezone,
|
|
915
|
-
utcTime: data.appointment.appointmentStartTime.toDate().toISOString(),
|
|
916
|
-
});
|
|
917
|
-
|
|
918
|
-
// Format time with timezone label for clarity
|
|
919
|
-
const formattedTime = this.formatTimestampInClinicTimezone(
|
|
920
|
-
data.appointment.appointmentStartTime,
|
|
921
|
-
clinicTimezone,
|
|
922
|
-
'time',
|
|
923
|
-
);
|
|
924
|
-
const timezoneName = this.getTimezoneDisplayName(clinicTimezone);
|
|
925
|
-
|
|
926
|
-
const templateVariables = {
|
|
927
|
-
clinicName: data.clinicProfile.name,
|
|
928
|
-
patientName: data.appointment.patientInfo.fullName,
|
|
929
|
-
procedureName: data.appointment.procedureInfo.name,
|
|
930
|
-
appointmentDate: this.formatTimestampInClinicTimezone(
|
|
931
|
-
data.appointment.appointmentStartTime,
|
|
932
|
-
clinicTimezone,
|
|
933
|
-
'date',
|
|
934
|
-
),
|
|
935
|
-
appointmentTime: `${formattedTime} (${timezoneName})`,
|
|
936
|
-
practitionerName: data.appointment.practitionerInfo.name,
|
|
937
|
-
};
|
|
938
|
-
|
|
939
|
-
const html = this.renderTemplate(clinicAppointmentRequestedTemplate, templateVariables);
|
|
940
|
-
const subject = data.options?.customSubject || 'New Appointment Request Received';
|
|
941
|
-
const fromAddress =
|
|
942
|
-
data.options?.fromAddress ||
|
|
943
|
-
`Metaesthetics <no-reply@${data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN}>`;
|
|
944
|
-
const domainToSendFrom = data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN;
|
|
945
|
-
|
|
946
|
-
const mailgunSendData = {
|
|
947
|
-
to: clinicEmail,
|
|
948
|
-
from: fromAddress,
|
|
949
|
-
subject,
|
|
950
|
-
html,
|
|
951
|
-
};
|
|
952
|
-
|
|
953
|
-
try {
|
|
954
|
-
const result = await this.sendEmail(domainToSendFrom, mailgunSendData);
|
|
955
|
-
await this.logEmailAttempt(
|
|
956
|
-
{
|
|
957
|
-
to: clinicEmail,
|
|
958
|
-
subject,
|
|
959
|
-
templateName: 'appointment_requested_clinic',
|
|
960
|
-
},
|
|
961
|
-
true,
|
|
962
|
-
);
|
|
963
|
-
return result;
|
|
964
|
-
} catch (error) {
|
|
965
|
-
await this.logEmailAttempt(
|
|
966
|
-
{
|
|
967
|
-
to: clinicEmail,
|
|
968
|
-
subject: data.options?.customSubject || 'New Appointment Request Received',
|
|
969
|
-
templateName: 'appointment_requested_clinic',
|
|
970
|
-
},
|
|
971
|
-
false,
|
|
972
|
-
error,
|
|
973
|
-
);
|
|
974
|
-
throw error;
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* Gets a user-friendly display text for who cancelled the appointment
|
|
980
|
-
* @param cancelledBy - The entity that cancelled the appointment
|
|
981
|
-
* @param clinicName - The clinic name for context
|
|
982
|
-
* @returns User-friendly cancellation source text
|
|
983
|
-
*/
|
|
984
|
-
private getCancelledByDisplayText(
|
|
985
|
-
cancelledBy: 'patient' | 'clinic' | 'practitioner' | 'system',
|
|
986
|
-
clinicName: string,
|
|
987
|
-
): string {
|
|
988
|
-
switch (cancelledBy) {
|
|
989
|
-
case 'patient':
|
|
990
|
-
return 'Patient Request';
|
|
991
|
-
case 'clinic':
|
|
992
|
-
return `${clinicName} (Clinic)`;
|
|
993
|
-
case 'practitioner':
|
|
994
|
-
return 'Your Practitioner';
|
|
995
|
-
case 'system':
|
|
996
|
-
return 'System (Automatic)';
|
|
997
|
-
default:
|
|
998
|
-
return 'Unknown';
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
/**
|
|
1003
|
-
* Sends an appointment cancellation email to the recipient
|
|
1004
|
-
* @param data - Appointment cancellation email data
|
|
1005
|
-
* @returns Promise with the sending result
|
|
1006
|
-
*/
|
|
1007
|
-
async sendAppointmentCancelledEmail(data: AppointmentCancellationEmailData): Promise<any> {
|
|
1008
|
-
Logger.info(
|
|
1009
|
-
`[AppointmentMailingService] Preparing to send appointment cancellation email to ${data.recipientRole}: ${data.recipientProfile.id}`,
|
|
1010
|
-
);
|
|
1011
|
-
|
|
1012
|
-
const recipientEmail = data.recipientProfile.email;
|
|
1013
|
-
|
|
1014
|
-
if (!recipientEmail) {
|
|
1015
|
-
Logger.error('[AppointmentMailingService] Recipient email not found for cancellation.', {
|
|
1016
|
-
recipientId: data.recipientProfile.id,
|
|
1017
|
-
role: data.recipientRole,
|
|
1018
|
-
});
|
|
1019
|
-
throw new Error('Recipient email address is missing.');
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
// Get clinic timezone from appointment data, default to UTC if not available
|
|
1023
|
-
const clinicTimezone = data.appointment.clinic_tz || 'UTC';
|
|
1024
|
-
|
|
1025
|
-
Logger.debug('[AppointmentMailingService] Formatting appointment time for cancellation', {
|
|
1026
|
-
clinicTimezone,
|
|
1027
|
-
utcTime: data.appointment.appointmentStartTime.toDate().toISOString(),
|
|
1028
|
-
});
|
|
1029
|
-
|
|
1030
|
-
// Format time with timezone label for clarity
|
|
1031
|
-
const formattedTime = this.formatTimestampInClinicTimezone(
|
|
1032
|
-
data.appointment.appointmentStartTime,
|
|
1033
|
-
clinicTimezone,
|
|
1034
|
-
'time',
|
|
1035
|
-
);
|
|
1036
|
-
const timezoneName = this.getTimezoneDisplayName(clinicTimezone);
|
|
1037
|
-
|
|
1038
|
-
// Determine the cancelled by source from the appointment
|
|
1039
|
-
const cancelledBy = data.appointment.canceledBy || 'system';
|
|
1040
|
-
const cancelledByDisplay = this.getCancelledByDisplayText(
|
|
1041
|
-
cancelledBy,
|
|
1042
|
-
data.appointment.clinicInfo.name,
|
|
1043
|
-
);
|
|
1044
|
-
|
|
1045
|
-
// Get recipient name based on role
|
|
1046
|
-
const recipientName =
|
|
1047
|
-
data.recipientRole === 'patient'
|
|
1048
|
-
? data.appointment.patientInfo.fullName
|
|
1049
|
-
: data.appointment.practitionerInfo.name;
|
|
1050
|
-
|
|
1051
|
-
// Build template variables
|
|
1052
|
-
const templateVariables: Record<string, string> = {
|
|
1053
|
-
recipientName,
|
|
1054
|
-
procedureName: data.appointment.procedureInfo.name,
|
|
1055
|
-
appointmentDate: this.formatTimestampInClinicTimezone(
|
|
1056
|
-
data.appointment.appointmentStartTime,
|
|
1057
|
-
clinicTimezone,
|
|
1058
|
-
'date',
|
|
1059
|
-
),
|
|
1060
|
-
appointmentTime: `${formattedTime} (${timezoneName})`,
|
|
1061
|
-
practitionerName: data.appointment.practitionerInfo.name,
|
|
1062
|
-
clinicName: data.appointment.clinicInfo.name,
|
|
1063
|
-
clinicAddress: this.formatClinicAddress(data.appointment),
|
|
1064
|
-
cancelledByDisplay,
|
|
1065
|
-
};
|
|
1066
|
-
|
|
1067
|
-
// Handle cancellation reason - render with or without the reason block
|
|
1068
|
-
const cancellationReason = data.cancellationReason || data.appointment.cancellationReason;
|
|
1069
|
-
let html = appointmentCancelledTemplate;
|
|
1070
|
-
|
|
1071
|
-
if (cancellationReason) {
|
|
1072
|
-
// Replace the conditional block with the reason content
|
|
1073
|
-
templateVariables.cancellationReason = cancellationReason;
|
|
1074
|
-
html = html.replace(
|
|
1075
|
-
/\{\{#if cancellationReason\}\}([\s\S]*?)\{\{\/if\}\}/g,
|
|
1076
|
-
'$1',
|
|
1077
|
-
);
|
|
1078
|
-
} else {
|
|
1079
|
-
// Remove the conditional block entirely
|
|
1080
|
-
html = html.replace(/\{\{#if cancellationReason\}\}[\s\S]*?\{\{\/if\}\}/g, '');
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
html = this.renderTemplate(html, templateVariables);
|
|
1084
|
-
|
|
1085
|
-
const subject =
|
|
1086
|
-
data.options?.customSubject ||
|
|
1087
|
-
`Appointment Cancelled: ${data.appointment.procedureInfo.name}`;
|
|
1088
|
-
const fromAddress =
|
|
1089
|
-
data.options?.fromAddress ||
|
|
1090
|
-
`Metaesthetics <no-reply@${data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN}>`;
|
|
1091
|
-
const domainToSendFrom = data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN;
|
|
1092
|
-
|
|
1093
|
-
const mailgunSendData = {
|
|
1094
|
-
to: recipientEmail,
|
|
1095
|
-
from: fromAddress,
|
|
1096
|
-
subject,
|
|
1097
|
-
html,
|
|
1098
|
-
};
|
|
1099
|
-
|
|
1100
|
-
try {
|
|
1101
|
-
const result = await this.sendEmail(domainToSendFrom, mailgunSendData);
|
|
1102
|
-
await this.logEmailAttempt(
|
|
1103
|
-
{ to: recipientEmail, subject, templateName: 'appointment_cancelled' },
|
|
1104
|
-
true,
|
|
1105
|
-
);
|
|
1106
|
-
Logger.info(
|
|
1107
|
-
`[AppointmentMailingService] Successfully sent cancellation email to ${recipientEmail}`,
|
|
1108
|
-
);
|
|
1109
|
-
return result;
|
|
1110
|
-
} catch (error) {
|
|
1111
|
-
await this.logEmailAttempt(
|
|
1112
|
-
{
|
|
1113
|
-
to: recipientEmail,
|
|
1114
|
-
subject,
|
|
1115
|
-
templateName: 'appointment_cancelled',
|
|
1116
|
-
},
|
|
1117
|
-
false,
|
|
1118
|
-
error,
|
|
1119
|
-
);
|
|
1120
|
-
Logger.error(
|
|
1121
|
-
`[AppointmentMailingService] Error sending cancellation email to ${recipientEmail}:`,
|
|
1122
|
-
error,
|
|
1123
|
-
);
|
|
1124
|
-
throw error;
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
/**
|
|
1129
|
-
* Sends a reschedule proposal email to the patient
|
|
1130
|
-
* @param data - Appointment reschedule proposal email data
|
|
1131
|
-
* @returns Promise with the sending result
|
|
1132
|
-
*/
|
|
1133
|
-
async sendAppointmentRescheduledProposalEmail(
|
|
1134
|
-
data: AppointmentRescheduledProposalEmailData,
|
|
1135
|
-
): Promise<any> {
|
|
1136
|
-
Logger.info(
|
|
1137
|
-
`[AppointmentMailingService] Preparing to send reschedule proposal email to patient: ${data.patientProfile.id}`,
|
|
1138
|
-
);
|
|
1139
|
-
|
|
1140
|
-
const recipientEmail = data.patientProfile.email;
|
|
1141
|
-
|
|
1142
|
-
if (!recipientEmail) {
|
|
1143
|
-
Logger.error('[AppointmentMailingService] Patient email not found for reschedule proposal.', {
|
|
1144
|
-
patientId: data.patientProfile.id,
|
|
1145
|
-
});
|
|
1146
|
-
throw new Error('Patient email address is missing.');
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
// Get clinic timezone from appointment data, default to UTC if not available
|
|
1150
|
-
const clinicTimezone = data.appointment.clinic_tz || 'UTC';
|
|
1151
|
-
|
|
1152
|
-
Logger.debug('[AppointmentMailingService] Formatting appointment times for reschedule', {
|
|
1153
|
-
clinicTimezone,
|
|
1154
|
-
previousTime: data.previousStartTime.toDate().toISOString(),
|
|
1155
|
-
newTime: data.appointment.appointmentStartTime.toDate().toISOString(),
|
|
1156
|
-
});
|
|
1157
|
-
|
|
1158
|
-
// Format previous time
|
|
1159
|
-
const previousFormattedTime = this.formatTimestampInClinicTimezone(
|
|
1160
|
-
data.previousStartTime,
|
|
1161
|
-
clinicTimezone,
|
|
1162
|
-
'time',
|
|
1163
|
-
);
|
|
1164
|
-
const previousFormattedDate = this.formatTimestampInClinicTimezone(
|
|
1165
|
-
data.previousStartTime,
|
|
1166
|
-
clinicTimezone,
|
|
1167
|
-
'date',
|
|
1168
|
-
);
|
|
1169
|
-
const previousTimezoneName = this.getTimezoneDisplayName(clinicTimezone);
|
|
1170
|
-
|
|
1171
|
-
// Format new proposed time
|
|
1172
|
-
const newFormattedTime = this.formatTimestampInClinicTimezone(
|
|
1173
|
-
data.appointment.appointmentStartTime,
|
|
1174
|
-
clinicTimezone,
|
|
1175
|
-
'time',
|
|
1176
|
-
);
|
|
1177
|
-
const newFormattedDate = this.formatTimestampInClinicTimezone(
|
|
1178
|
-
data.appointment.appointmentStartTime,
|
|
1179
|
-
clinicTimezone,
|
|
1180
|
-
'date',
|
|
1181
|
-
);
|
|
1182
|
-
const newTimezoneName = this.getTimezoneDisplayName(clinicTimezone);
|
|
1183
|
-
|
|
1184
|
-
const templateVariables = {
|
|
1185
|
-
patientName: data.appointment.patientInfo.fullName,
|
|
1186
|
-
procedureName: data.appointment.procedureInfo.name,
|
|
1187
|
-
practitionerName: data.appointment.practitionerInfo.name,
|
|
1188
|
-
clinicName: data.appointment.clinicInfo.name,
|
|
1189
|
-
clinicAddress: this.formatClinicAddress(data.appointment),
|
|
1190
|
-
previousDate: previousFormattedDate,
|
|
1191
|
-
previousTime: `${previousFormattedTime} (${previousTimezoneName})`,
|
|
1192
|
-
newDate: newFormattedDate,
|
|
1193
|
-
newTime: `${newFormattedTime} (${newTimezoneName})`,
|
|
1194
|
-
};
|
|
1195
|
-
|
|
1196
|
-
const html = this.renderTemplate(appointmentRescheduledProposalTemplate, templateVariables);
|
|
1197
|
-
const subject =
|
|
1198
|
-
data.options?.customSubject ||
|
|
1199
|
-
`Action Required: Reschedule Proposal for Your ${data.appointment.procedureInfo.name} Appointment`;
|
|
1200
|
-
const fromAddress =
|
|
1201
|
-
data.options?.fromAddress ||
|
|
1202
|
-
`Metaesthetics <no-reply@${data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN}>`;
|
|
1203
|
-
const domainToSendFrom = data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN;
|
|
1204
|
-
|
|
1205
|
-
const mailgunSendData = {
|
|
1206
|
-
to: recipientEmail,
|
|
1207
|
-
from: fromAddress,
|
|
1208
|
-
subject,
|
|
1209
|
-
html,
|
|
1210
|
-
};
|
|
1211
|
-
|
|
1212
|
-
try {
|
|
1213
|
-
const result = await this.sendEmail(domainToSendFrom, mailgunSendData);
|
|
1214
|
-
await this.logEmailAttempt(
|
|
1215
|
-
{ to: recipientEmail, subject, templateName: 'appointment_rescheduled_proposal' },
|
|
1216
|
-
true,
|
|
1217
|
-
);
|
|
1218
|
-
Logger.info(
|
|
1219
|
-
`[AppointmentMailingService] Successfully sent reschedule proposal email to ${recipientEmail}`,
|
|
1220
|
-
);
|
|
1221
|
-
return result;
|
|
1222
|
-
} catch (error) {
|
|
1223
|
-
await this.logEmailAttempt(
|
|
1224
|
-
{
|
|
1225
|
-
to: recipientEmail,
|
|
1226
|
-
subject,
|
|
1227
|
-
templateName: 'appointment_rescheduled_proposal',
|
|
1228
|
-
},
|
|
1229
|
-
false,
|
|
1230
|
-
error,
|
|
1231
|
-
);
|
|
1232
|
-
Logger.error(
|
|
1233
|
-
`[AppointmentMailingService] Error sending reschedule proposal email to ${recipientEmail}:`,
|
|
1234
|
-
error,
|
|
1235
|
-
);
|
|
1236
|
-
throw error;
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
async sendReviewRequestEmail(data: ReviewRequestEmailData): Promise<any> {
|
|
1241
|
-
Logger.info(
|
|
1242
|
-
`[AppointmentMailingService] Placeholder for sendReviewRequestEmail to patient: ${data.patientProfile.id}`,
|
|
1243
|
-
);
|
|
1244
|
-
return Promise.resolve();
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
async sendReviewAddedEmail(data: ReviewAddedEmailData): Promise<any> {
|
|
1248
|
-
Logger.info(
|
|
1249
|
-
`[AppointmentMailingService] Placeholder for sendReviewAddedEmail to ${data.recipientRole}: ${data.recipientProfile.id}`,
|
|
1250
|
-
);
|
|
1251
|
-
return Promise.resolve();
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1
|
+
import * as admin from 'firebase-admin';
|
|
2
|
+
import { DateTime } from 'luxon';
|
|
3
|
+
import { BaseMailingService, NewMailgunClient } from '../base.mailing.service';
|
|
4
|
+
import { Logger } from '../../logger';
|
|
5
|
+
import { Appointment } from '../../../types/appointment';
|
|
6
|
+
import { PatientProfile } from '../../../types/patient';
|
|
7
|
+
import { Practitioner } from '../../../types/practitioner';
|
|
8
|
+
import { Clinic } from '../../../types/clinic';
|
|
9
|
+
import { UserRole } from '../../../types';
|
|
10
|
+
import { PractitionerProfileInfo, PatientProfileInfo, ClinicInfo } from '../../../types/profile';
|
|
11
|
+
|
|
12
|
+
// Simple string literals for placeholders, to be replaced by file loading later
|
|
13
|
+
const patientAppointmentConfirmedTemplate = `
|
|
14
|
+
<!DOCTYPE html>
|
|
15
|
+
<html lang="en">
|
|
16
|
+
<head>
|
|
17
|
+
<meta charset="UTF-8">
|
|
18
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
19
|
+
<title>Appointment Confirmed</title>
|
|
20
|
+
<!--[if mso]>
|
|
21
|
+
<noscript>
|
|
22
|
+
<xml>
|
|
23
|
+
<o:OfficeDocumentSettings>
|
|
24
|
+
<o:PixelsPerInch>96</o:PixelsPerInch>
|
|
25
|
+
</o:OfficeDocumentSettings>
|
|
26
|
+
</xml>
|
|
27
|
+
</noscript>
|
|
28
|
+
<![endif]-->
|
|
29
|
+
</head>
|
|
30
|
+
<body style="margin: 0; padding: 0; background-color: #f8f6f5; font-family: Georgia, 'Times New Roman', serif;">
|
|
31
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #f8f6f5;">
|
|
32
|
+
<tr>
|
|
33
|
+
<td align="center" style="padding: 40px 20px;">
|
|
34
|
+
<table role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" style="max-width: 600px; background-color: #ffffff; border-radius: 2px; box-shadow: 0 1px 3px rgba(103, 87, 74, 0.08);">
|
|
35
|
+
|
|
36
|
+
<!-- Header -->
|
|
37
|
+
<tr>
|
|
38
|
+
<td style="padding: 48px 48px 32px 48px; border-bottom: 1px solid #f0ebe6;">
|
|
39
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
40
|
+
<tr>
|
|
41
|
+
<td>
|
|
42
|
+
<h1 style="margin: 0; font-size: 24px; font-weight: 400; color: #67574A; letter-spacing: 2px; text-transform: uppercase; font-family: Georgia, 'Times New Roman', serif;">Metaesthetics</h1>
|
|
43
|
+
</td>
|
|
44
|
+
</tr>
|
|
45
|
+
</table>
|
|
46
|
+
</td>
|
|
47
|
+
</tr>
|
|
48
|
+
|
|
49
|
+
<!-- Confirmed Banner -->
|
|
50
|
+
<tr>
|
|
51
|
+
<td style="padding: 0;">
|
|
52
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #00BB38;">
|
|
53
|
+
<tr>
|
|
54
|
+
<td style="padding: 20px 48px;">
|
|
55
|
+
<p style="margin: 0; font-size: 13px; font-weight: 600; color: #ffffff; letter-spacing: 1.5px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Appointment Confirmed</p>
|
|
56
|
+
</td>
|
|
57
|
+
</tr>
|
|
58
|
+
</table>
|
|
59
|
+
</td>
|
|
60
|
+
</tr>
|
|
61
|
+
|
|
62
|
+
<!-- Main Content -->
|
|
63
|
+
<tr>
|
|
64
|
+
<td style="padding: 40px 48px;">
|
|
65
|
+
|
|
66
|
+
<!-- Greeting -->
|
|
67
|
+
<p style="margin: 0 0 24px 0; font-size: 17px; color: #333333; line-height: 1.6; font-family: Georgia, 'Times New Roman', serif;">
|
|
68
|
+
Dear {{patientName}},
|
|
69
|
+
</p>
|
|
70
|
+
|
|
71
|
+
<p style="margin: 0 0 32px 0; font-size: 16px; color: #555555; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
72
|
+
Your appointment has been confirmed. We look forward to seeing you.
|
|
73
|
+
</p>
|
|
74
|
+
|
|
75
|
+
<!-- Appointment Details Card -->
|
|
76
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px; background-color: #faf9f7; border-left: 3px solid #00BB38;">
|
|
77
|
+
<tr>
|
|
78
|
+
<td style="padding: 24px;">
|
|
79
|
+
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #868686; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Procedure</p>
|
|
80
|
+
<p style="margin: 0 0 20px 0; font-size: 18px; color: #67574A; font-weight: 500; font-family: Georgia, 'Times New Roman', serif;">{{procedureName}}</p>
|
|
81
|
+
|
|
82
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
83
|
+
<tr>
|
|
84
|
+
<td style="padding-bottom: 16px;">
|
|
85
|
+
<p style="margin: 0 0 2px 0; font-size: 11px; color: #868686; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Date & Time</p>
|
|
86
|
+
<p style="margin: 0; font-size: 15px; color: #333333; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{appointmentDate}}</p>
|
|
87
|
+
<p style="margin: 4px 0 0 0; font-size: 14px; color: #67574A; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{appointmentTime}}</p>
|
|
88
|
+
</td>
|
|
89
|
+
</tr>
|
|
90
|
+
<tr>
|
|
91
|
+
<td style="padding-bottom: 16px;">
|
|
92
|
+
<p style="margin: 0 0 2px 0; font-size: 11px; color: #868686; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Practitioner</p>
|
|
93
|
+
<p style="margin: 0; font-size: 15px; color: #333333; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{practitionerName}}</p>
|
|
94
|
+
</td>
|
|
95
|
+
</tr>
|
|
96
|
+
<tr>
|
|
97
|
+
<td>
|
|
98
|
+
<p style="margin: 0 0 2px 0; font-size: 11px; color: #868686; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Location</p>
|
|
99
|
+
<p style="margin: 0; font-size: 15px; color: #333333; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{clinicName}}</p>
|
|
100
|
+
<p style="margin: 4px 0 0 0; font-size: 13px; color: #555555; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{clinicAddress}}</p>
|
|
101
|
+
</td>
|
|
102
|
+
</tr>
|
|
103
|
+
</table>
|
|
104
|
+
</td>
|
|
105
|
+
</tr>
|
|
106
|
+
</table>
|
|
107
|
+
|
|
108
|
+
<!-- Divider -->
|
|
109
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
|
|
110
|
+
<tr>
|
|
111
|
+
<td style="height: 1px; background-color: #e8e4df;"></td>
|
|
112
|
+
</tr>
|
|
113
|
+
</table>
|
|
114
|
+
|
|
115
|
+
<!-- Important Notice -->
|
|
116
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 24px;">
|
|
117
|
+
<tr>
|
|
118
|
+
<td style="padding: 20px 24px; background-color: #faf9f7; border-left: 3px solid #a48a76;">
|
|
119
|
+
<p style="margin: 0 0 8px 0; font-size: 13px; font-weight: 600; color: #67574A; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Before Your Visit</p>
|
|
120
|
+
<p style="margin: 0; font-size: 14px; color: #555555; line-height: 1.6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
121
|
+
Please arrive 15 minutes early. If you need to reschedule or cancel, contact us through the Metaesthetics app.
|
|
122
|
+
</p>
|
|
123
|
+
</td>
|
|
124
|
+
</tr>
|
|
125
|
+
</table>
|
|
126
|
+
|
|
127
|
+
<!-- Thank You -->
|
|
128
|
+
<p style="margin: 0; font-size: 14px; color: #868686; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
129
|
+
Thank you for choosing {{clinicName}}. We look forward to providing you with exceptional care.
|
|
130
|
+
</p>
|
|
131
|
+
|
|
132
|
+
</td>
|
|
133
|
+
</tr>
|
|
134
|
+
|
|
135
|
+
<!-- Footer -->
|
|
136
|
+
<tr>
|
|
137
|
+
<td style="padding: 32px 48px; background-color: #faf9f7; border-top: 1px solid #f0ebe6;">
|
|
138
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
139
|
+
<tr>
|
|
140
|
+
<td>
|
|
141
|
+
<p style="margin: 0 0 8px 0; font-size: 14px; font-weight: 500; color: #67574A; font-family: Georgia, 'Times New Roman', serif;">{{clinicName}}</p>
|
|
142
|
+
<p style="margin: 0 0 16px 0; font-size: 13px; color: #868686; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Premium Aesthetic Services</p>
|
|
143
|
+
<p style="margin: 0; font-size: 11px; color: #aaaaaa; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">This is an automated message from Metaesthetics. Please do not reply directly to this email.</p>
|
|
144
|
+
</td>
|
|
145
|
+
</tr>
|
|
146
|
+
</table>
|
|
147
|
+
</td>
|
|
148
|
+
</tr>
|
|
149
|
+
|
|
150
|
+
</table>
|
|
151
|
+
</td>
|
|
152
|
+
</tr>
|
|
153
|
+
</table>
|
|
154
|
+
</body>
|
|
155
|
+
</html>
|
|
156
|
+
`;
|
|
157
|
+
const clinicAppointmentRequestedTemplate = `
|
|
158
|
+
<!DOCTYPE html>
|
|
159
|
+
<html lang="en">
|
|
160
|
+
<head>
|
|
161
|
+
<meta charset="UTF-8">
|
|
162
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
163
|
+
<title>New Appointment Request</title>
|
|
164
|
+
<style>
|
|
165
|
+
body {
|
|
166
|
+
margin: 0;
|
|
167
|
+
padding: 0;
|
|
168
|
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
169
|
+
background: linear-gradient(135deg, #a48a76 0%, #67574A 100%);
|
|
170
|
+
min-height: 100vh;
|
|
171
|
+
}
|
|
172
|
+
.email-container {
|
|
173
|
+
max-width: 600px;
|
|
174
|
+
margin: 0 auto;
|
|
175
|
+
background: #ffffff;
|
|
176
|
+
border-radius: 20px;
|
|
177
|
+
overflow: hidden;
|
|
178
|
+
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
|
|
179
|
+
margin-top: 40px;
|
|
180
|
+
margin-bottom: 40px;
|
|
181
|
+
}
|
|
182
|
+
.header {
|
|
183
|
+
background: linear-gradient(135deg, #a48a76 0%, #67574A 100%);
|
|
184
|
+
padding: 40px 30px;
|
|
185
|
+
text-align: center;
|
|
186
|
+
color: white;
|
|
187
|
+
}
|
|
188
|
+
.header h1 {
|
|
189
|
+
margin: 0;
|
|
190
|
+
font-size: 28px;
|
|
191
|
+
font-weight: 300;
|
|
192
|
+
letter-spacing: 1px;
|
|
193
|
+
}
|
|
194
|
+
.header .subtitle {
|
|
195
|
+
margin: 10px 0 0 0;
|
|
196
|
+
font-size: 16px;
|
|
197
|
+
opacity: 0.9;
|
|
198
|
+
font-weight: 300;
|
|
199
|
+
}
|
|
200
|
+
.content {
|
|
201
|
+
padding: 40px 30px;
|
|
202
|
+
}
|
|
203
|
+
.greeting {
|
|
204
|
+
font-size: 18px;
|
|
205
|
+
color: #333;
|
|
206
|
+
margin-bottom: 25px;
|
|
207
|
+
font-weight: 400;
|
|
208
|
+
}
|
|
209
|
+
.appointment-card {
|
|
210
|
+
background: linear-gradient(135deg, #f8f6f5 0%, #f5f3f2 100%);
|
|
211
|
+
border-radius: 15px;
|
|
212
|
+
padding: 30px;
|
|
213
|
+
margin: 25px 0;
|
|
214
|
+
border-left: 5px solid #a48a76;
|
|
215
|
+
}
|
|
216
|
+
.appointment-title {
|
|
217
|
+
font-size: 20px;
|
|
218
|
+
color: #a48a76;
|
|
219
|
+
margin-bottom: 20px;
|
|
220
|
+
font-weight: 600;
|
|
221
|
+
}
|
|
222
|
+
.appointment-details {
|
|
223
|
+
display: grid;
|
|
224
|
+
gap: 15px;
|
|
225
|
+
}
|
|
226
|
+
.detail-row {
|
|
227
|
+
display: flex;
|
|
228
|
+
align-items: center;
|
|
229
|
+
padding: 8px 0;
|
|
230
|
+
}
|
|
231
|
+
.detail-label {
|
|
232
|
+
font-weight: 600;
|
|
233
|
+
color: #555;
|
|
234
|
+
min-width: 120px;
|
|
235
|
+
font-size: 14px;
|
|
236
|
+
}
|
|
237
|
+
.detail-value {
|
|
238
|
+
color: #333;
|
|
239
|
+
font-size: 16px;
|
|
240
|
+
font-weight: 500;
|
|
241
|
+
}
|
|
242
|
+
.patient-name {
|
|
243
|
+
color: #a48a76;
|
|
244
|
+
font-weight: 600;
|
|
245
|
+
}
|
|
246
|
+
.procedure-name {
|
|
247
|
+
color: #67574A;
|
|
248
|
+
font-weight: 600;
|
|
249
|
+
}
|
|
250
|
+
.cta-section {
|
|
251
|
+
text-align: center;
|
|
252
|
+
margin: 35px 0;
|
|
253
|
+
}
|
|
254
|
+
.cta-button {
|
|
255
|
+
display: inline-block;
|
|
256
|
+
background: linear-gradient(135deg, #a48a76 0%, #67574A 100%);
|
|
257
|
+
color: white;
|
|
258
|
+
text-decoration: none;
|
|
259
|
+
padding: 15px 35px;
|
|
260
|
+
border-radius: 50px;
|
|
261
|
+
font-weight: 600;
|
|
262
|
+
font-size: 16px;
|
|
263
|
+
letter-spacing: 0.5px;
|
|
264
|
+
transition: transform 0.3s ease;
|
|
265
|
+
box-shadow: 0 8px 25px rgba(164, 138, 118, 0.3);
|
|
266
|
+
}
|
|
267
|
+
.cta-button:hover {
|
|
268
|
+
transform: translateY(-2px);
|
|
269
|
+
}
|
|
270
|
+
.footer {
|
|
271
|
+
background: #f8f9fa;
|
|
272
|
+
padding: 25px 30px;
|
|
273
|
+
text-align: center;
|
|
274
|
+
color: #666;
|
|
275
|
+
font-size: 14px;
|
|
276
|
+
border-top: 1px solid #eee;
|
|
277
|
+
}
|
|
278
|
+
.logo {
|
|
279
|
+
font-size: 24px;
|
|
280
|
+
font-weight: 700;
|
|
281
|
+
color: white;
|
|
282
|
+
margin-bottom: 5px;
|
|
283
|
+
}
|
|
284
|
+
.divider {
|
|
285
|
+
height: 2px;
|
|
286
|
+
background: linear-gradient(90deg, #a48a76, #67574A);
|
|
287
|
+
margin: 25px 0;
|
|
288
|
+
border-radius: 1px;
|
|
289
|
+
}
|
|
290
|
+
</style>
|
|
291
|
+
</head>
|
|
292
|
+
<body>
|
|
293
|
+
<div class="email-container">
|
|
294
|
+
<div class="header">
|
|
295
|
+
<div class="logo">Metaesthetics</div>
|
|
296
|
+
<h1>New Appointment Request</h1>
|
|
297
|
+
<div class="subtitle">Requires Your Attention</div>
|
|
298
|
+
</div>
|
|
299
|
+
|
|
300
|
+
<div class="content">
|
|
301
|
+
<div class="greeting">
|
|
302
|
+
Dear <strong>{{clinicName}}</strong> Team,
|
|
303
|
+
</div>
|
|
304
|
+
|
|
305
|
+
<p style="color: #555; font-size: 16px; line-height: 1.6; margin-bottom: 25px;">
|
|
306
|
+
We hope this message finds you well. You have received a new appointment request that requires your review and confirmation.
|
|
307
|
+
</p>
|
|
308
|
+
|
|
309
|
+
<div class="appointment-card">
|
|
310
|
+
<div class="appointment-title">📅 Appointment Details</div>
|
|
311
|
+
<div class="appointment-details">
|
|
312
|
+
<div class="detail-row">
|
|
313
|
+
<div class="detail-label">Patient:</div>
|
|
314
|
+
<div class="detail-value patient-name">{{patientName}}</div>
|
|
315
|
+
</div>
|
|
316
|
+
<div class="detail-row">
|
|
317
|
+
<div class="detail-label">Procedure:</div>
|
|
318
|
+
<div class="detail-value procedure-name">{{procedureName}}</div>
|
|
319
|
+
</div>
|
|
320
|
+
<div class="detail-row">
|
|
321
|
+
<div class="detail-label">Date:</div>
|
|
322
|
+
<div class="detail-value">{{appointmentDate}}</div>
|
|
323
|
+
</div>
|
|
324
|
+
<div class="detail-row">
|
|
325
|
+
<div class="detail-label">Time:</div>
|
|
326
|
+
<div class="detail-value">{{appointmentTime}}</div>
|
|
327
|
+
</div>
|
|
328
|
+
<div class="detail-row">
|
|
329
|
+
<div class="detail-label">Practitioner:</div>
|
|
330
|
+
<div class="detail-value">{{practitionerName}}</div>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
|
|
335
|
+
<div class="divider"></div>
|
|
336
|
+
|
|
337
|
+
<p style="color: #555; font-size: 16px; line-height: 1.6; margin-bottom: 30px;">
|
|
338
|
+
Please review this appointment request and confirm availability in your admin panel. The patient is waiting for your confirmation to finalize their booking.
|
|
339
|
+
</p>
|
|
340
|
+
|
|
341
|
+
<div class="cta-section">
|
|
342
|
+
<a href="#" class="cta-button">Review & Confirm Appointment</a>
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
|
|
346
|
+
<div class="footer">
|
|
347
|
+
<p style="margin: 0 0 10px 0;">
|
|
348
|
+
<strong>Metaesthetics</strong> - Premium Aesthetic Services
|
|
349
|
+
</p>
|
|
350
|
+
<p style="margin: 0; font-size: 12px; color: #999;">
|
|
351
|
+
This is an automated message. Please do not reply to this email.
|
|
352
|
+
</p>
|
|
353
|
+
</div>
|
|
354
|
+
</div>
|
|
355
|
+
</body>
|
|
356
|
+
</html>
|
|
357
|
+
`;
|
|
358
|
+
|
|
359
|
+
const appointmentCancelledTemplate = `
|
|
360
|
+
<!DOCTYPE html>
|
|
361
|
+
<html lang="en">
|
|
362
|
+
<head>
|
|
363
|
+
<meta charset="UTF-8">
|
|
364
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
365
|
+
<title>Appointment Cancelled</title>
|
|
366
|
+
<!--[if mso]>
|
|
367
|
+
<noscript>
|
|
368
|
+
<xml>
|
|
369
|
+
<o:OfficeDocumentSettings>
|
|
370
|
+
<o:PixelsPerInch>96</o:PixelsPerInch>
|
|
371
|
+
</o:OfficeDocumentSettings>
|
|
372
|
+
</xml>
|
|
373
|
+
</noscript>
|
|
374
|
+
<![endif]-->
|
|
375
|
+
</head>
|
|
376
|
+
<body style="margin: 0; padding: 0; background-color: #f8f6f5; font-family: Georgia, 'Times New Roman', serif;">
|
|
377
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #f8f6f5;">
|
|
378
|
+
<tr>
|
|
379
|
+
<td align="center" style="padding: 40px 20px;">
|
|
380
|
+
<table role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" style="max-width: 600px; background-color: #ffffff; border-radius: 2px; box-shadow: 0 1px 3px rgba(103, 87, 74, 0.08);">
|
|
381
|
+
|
|
382
|
+
<!-- Header -->
|
|
383
|
+
<tr>
|
|
384
|
+
<td style="padding: 48px 48px 32px 48px; border-bottom: 1px solid #f0ebe6;">
|
|
385
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
386
|
+
<tr>
|
|
387
|
+
<td>
|
|
388
|
+
<h1 style="margin: 0; font-size: 24px; font-weight: 400; color: #67574A; letter-spacing: 2px; text-transform: uppercase; font-family: Georgia, 'Times New Roman', serif;">Metaesthetics</h1>
|
|
389
|
+
</td>
|
|
390
|
+
</tr>
|
|
391
|
+
</table>
|
|
392
|
+
</td>
|
|
393
|
+
</tr>
|
|
394
|
+
|
|
395
|
+
<!-- Cancellation Banner -->
|
|
396
|
+
<tr>
|
|
397
|
+
<td style="padding: 0;">
|
|
398
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #fa003f;">
|
|
399
|
+
<tr>
|
|
400
|
+
<td style="padding: 20px 48px;">
|
|
401
|
+
<p style="margin: 0; font-size: 13px; font-weight: 600; color: #ffffff; letter-spacing: 1.5px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Appointment Cancelled</p>
|
|
402
|
+
</td>
|
|
403
|
+
</tr>
|
|
404
|
+
</table>
|
|
405
|
+
</td>
|
|
406
|
+
</tr>
|
|
407
|
+
|
|
408
|
+
<!-- Main Content -->
|
|
409
|
+
<tr>
|
|
410
|
+
<td style="padding: 40px 48px;">
|
|
411
|
+
|
|
412
|
+
<!-- Greeting -->
|
|
413
|
+
<p style="margin: 0 0 24px 0; font-size: 17px; color: #333333; line-height: 1.6; font-family: Georgia, 'Times New Roman', serif;">
|
|
414
|
+
Dear {{recipientName}},
|
|
415
|
+
</p>
|
|
416
|
+
|
|
417
|
+
<p style="margin: 0 0 32px 0; font-size: 16px; color: #555555; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
418
|
+
We regret to inform you that your appointment has been cancelled. Please see the details below.
|
|
419
|
+
</p>
|
|
420
|
+
|
|
421
|
+
<!-- Cancelled By Info -->
|
|
422
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 24px;">
|
|
423
|
+
<tr>
|
|
424
|
+
<td style="padding: 16px 20px; background-color: #fef2f2; border-left: 3px solid #fa003f;">
|
|
425
|
+
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #868686; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Cancelled By</p>
|
|
426
|
+
<p style="margin: 0; font-size: 15px; color: #333333; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{cancelledByDisplay}}</p>
|
|
427
|
+
</td>
|
|
428
|
+
</tr>
|
|
429
|
+
</table>
|
|
430
|
+
|
|
431
|
+
{{#if cancellationReason}}
|
|
432
|
+
<!-- Cancellation Reason -->
|
|
433
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
|
|
434
|
+
<tr>
|
|
435
|
+
<td style="padding: 20px 24px; background-color: #faf9f7; border-left: 3px solid #a48a76;">
|
|
436
|
+
<p style="margin: 0 0 8px 0; font-size: 11px; font-weight: 600; color: #868686; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Reason</p>
|
|
437
|
+
<p style="margin: 0; font-size: 15px; color: #555555; line-height: 1.6; font-style: italic; font-family: Georgia, 'Times New Roman', serif;">"{{cancellationReason}}"</p>
|
|
438
|
+
</td>
|
|
439
|
+
</tr>
|
|
440
|
+
</table>
|
|
441
|
+
{{/if}}
|
|
442
|
+
|
|
443
|
+
<!-- Cancelled Appointment Details -->
|
|
444
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px; background-color: #f5f5f5; border-left: 3px solid #cccccc;">
|
|
445
|
+
<tr>
|
|
446
|
+
<td style="padding: 24px;">
|
|
447
|
+
<p style="margin: 0 0 16px 0; font-size: 12px; font-weight: 600; color: #999999; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Cancelled Appointment</p>
|
|
448
|
+
|
|
449
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
450
|
+
<tr>
|
|
451
|
+
<td style="padding-bottom: 12px;">
|
|
452
|
+
<p style="margin: 0 0 2px 0; font-size: 11px; color: #999999; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Procedure</p>
|
|
453
|
+
<p style="margin: 0; font-size: 15px; color: #888888; text-decoration: line-through; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{procedureName}}</p>
|
|
454
|
+
</td>
|
|
455
|
+
</tr>
|
|
456
|
+
<tr>
|
|
457
|
+
<td style="padding-bottom: 12px;">
|
|
458
|
+
<p style="margin: 0 0 2px 0; font-size: 11px; color: #999999; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Date & Time</p>
|
|
459
|
+
<p style="margin: 0; font-size: 15px; color: #888888; text-decoration: line-through; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{appointmentDate}} at {{appointmentTime}}</p>
|
|
460
|
+
</td>
|
|
461
|
+
</tr>
|
|
462
|
+
<tr>
|
|
463
|
+
<td style="padding-bottom: 12px;">
|
|
464
|
+
<p style="margin: 0 0 2px 0; font-size: 11px; color: #999999; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Practitioner</p>
|
|
465
|
+
<p style="margin: 0; font-size: 15px; color: #888888; text-decoration: line-through; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{practitionerName}}</p>
|
|
466
|
+
</td>
|
|
467
|
+
</tr>
|
|
468
|
+
<tr>
|
|
469
|
+
<td>
|
|
470
|
+
<p style="margin: 0 0 2px 0; font-size: 11px; color: #999999; text-transform: uppercase; letter-spacing: 0.5px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Location</p>
|
|
471
|
+
<p style="margin: 0; font-size: 15px; color: #888888; text-decoration: line-through; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{clinicName}}</p>
|
|
472
|
+
<p style="margin: 4px 0 0 0; font-size: 13px; color: #999999; text-decoration: line-through; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{clinicAddress}}</p>
|
|
473
|
+
</td>
|
|
474
|
+
</tr>
|
|
475
|
+
</table>
|
|
476
|
+
</td>
|
|
477
|
+
</tr>
|
|
478
|
+
</table>
|
|
479
|
+
|
|
480
|
+
<!-- Divider -->
|
|
481
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
|
|
482
|
+
<tr>
|
|
483
|
+
<td style="height: 1px; background-color: #e8e4df;"></td>
|
|
484
|
+
</tr>
|
|
485
|
+
</table>
|
|
486
|
+
|
|
487
|
+
<!-- Rebook Section -->
|
|
488
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 24px; background-color: #f0faf4; border-left: 3px solid #00BB38;">
|
|
489
|
+
<tr>
|
|
490
|
+
<td style="padding: 24px;">
|
|
491
|
+
<p style="margin: 0 0 8px 0; font-size: 14px; font-weight: 600; color: #00BB38; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Book a New Appointment</p>
|
|
492
|
+
<p style="margin: 0; font-size: 14px; color: #555555; line-height: 1.6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
493
|
+
We'd love to see you again. Open the Metaesthetics app to browse available times and book a new appointment.
|
|
494
|
+
</p>
|
|
495
|
+
</td>
|
|
496
|
+
</tr>
|
|
497
|
+
</table>
|
|
498
|
+
|
|
499
|
+
<!-- Support Info -->
|
|
500
|
+
<p style="margin: 0; font-size: 13px; color: #868686; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
501
|
+
If you have any questions about this cancellation, please contact {{clinicName}} through the Metaesthetics app.
|
|
502
|
+
</p>
|
|
503
|
+
|
|
504
|
+
</td>
|
|
505
|
+
</tr>
|
|
506
|
+
|
|
507
|
+
<!-- Footer -->
|
|
508
|
+
<tr>
|
|
509
|
+
<td style="padding: 32px 48px; background-color: #faf9f7; border-top: 1px solid #f0ebe6;">
|
|
510
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
511
|
+
<tr>
|
|
512
|
+
<td>
|
|
513
|
+
<p style="margin: 0 0 8px 0; font-size: 14px; font-weight: 500; color: #67574A; font-family: Georgia, 'Times New Roman', serif;">{{clinicName}}</p>
|
|
514
|
+
<p style="margin: 0 0 16px 0; font-size: 13px; color: #868686; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Premium Aesthetic Services</p>
|
|
515
|
+
<p style="margin: 0; font-size: 11px; color: #aaaaaa; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">This is an automated message from Metaesthetics. Please do not reply directly to this email.</p>
|
|
516
|
+
</td>
|
|
517
|
+
</tr>
|
|
518
|
+
</table>
|
|
519
|
+
</td>
|
|
520
|
+
</tr>
|
|
521
|
+
|
|
522
|
+
</table>
|
|
523
|
+
</td>
|
|
524
|
+
</tr>
|
|
525
|
+
</table>
|
|
526
|
+
</body>
|
|
527
|
+
</html>
|
|
528
|
+
`;
|
|
529
|
+
|
|
530
|
+
const appointmentRescheduledProposalTemplate = `
|
|
531
|
+
<!DOCTYPE html>
|
|
532
|
+
<html lang="en">
|
|
533
|
+
<head>
|
|
534
|
+
<meta charset="UTF-8">
|
|
535
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
536
|
+
<title>Appointment Reschedule Request</title>
|
|
537
|
+
<!--[if mso]>
|
|
538
|
+
<noscript>
|
|
539
|
+
<xml>
|
|
540
|
+
<o:OfficeDocumentSettings>
|
|
541
|
+
<o:PixelsPerInch>96</o:PixelsPerInch>
|
|
542
|
+
</o:OfficeDocumentSettings>
|
|
543
|
+
</xml>
|
|
544
|
+
</noscript>
|
|
545
|
+
<![endif]-->
|
|
546
|
+
</head>
|
|
547
|
+
<body style="margin: 0; padding: 0; background-color: #f8f6f5; font-family: Georgia, 'Times New Roman', serif;">
|
|
548
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #f8f6f5;">
|
|
549
|
+
<tr>
|
|
550
|
+
<td align="center" style="padding: 40px 20px;">
|
|
551
|
+
<table role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" style="max-width: 600px; background-color: #ffffff; border-radius: 2px; box-shadow: 0 1px 3px rgba(103, 87, 74, 0.08);">
|
|
552
|
+
|
|
553
|
+
<!-- Header -->
|
|
554
|
+
<tr>
|
|
555
|
+
<td style="padding: 48px 48px 32px 48px; border-bottom: 1px solid #f0ebe6;">
|
|
556
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
557
|
+
<tr>
|
|
558
|
+
<td>
|
|
559
|
+
<h1 style="margin: 0; font-size: 24px; font-weight: 400; color: #67574A; letter-spacing: 2px; text-transform: uppercase; font-family: Georgia, 'Times New Roman', serif;">Metaesthetics</h1>
|
|
560
|
+
</td>
|
|
561
|
+
</tr>
|
|
562
|
+
</table>
|
|
563
|
+
</td>
|
|
564
|
+
</tr>
|
|
565
|
+
|
|
566
|
+
<!-- Action Required Banner -->
|
|
567
|
+
<tr>
|
|
568
|
+
<td style="padding: 0;">
|
|
569
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #a48a76;">
|
|
570
|
+
<tr>
|
|
571
|
+
<td style="padding: 20px 48px;">
|
|
572
|
+
<p style="margin: 0; font-size: 13px; font-weight: 600; color: #ffffff; letter-spacing: 1.5px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Action Required</p>
|
|
573
|
+
</td>
|
|
574
|
+
</tr>
|
|
575
|
+
</table>
|
|
576
|
+
</td>
|
|
577
|
+
</tr>
|
|
578
|
+
|
|
579
|
+
<!-- Main Content -->
|
|
580
|
+
<tr>
|
|
581
|
+
<td style="padding: 40px 48px;">
|
|
582
|
+
|
|
583
|
+
<!-- Greeting -->
|
|
584
|
+
<p style="margin: 0 0 24px 0; font-size: 17px; color: #333333; line-height: 1.6; font-family: Georgia, 'Times New Roman', serif;">
|
|
585
|
+
Dear {{patientName}},
|
|
586
|
+
</p>
|
|
587
|
+
|
|
588
|
+
<p style="margin: 0 0 32px 0; font-size: 16px; color: #555555; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
589
|
+
{{clinicName}} has proposed a new time for your upcoming appointment. Please review the details below and respond at your earliest convenience.
|
|
590
|
+
</p>
|
|
591
|
+
|
|
592
|
+
<!-- Appointment Info Card -->
|
|
593
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px; background-color: #faf9f7; border-left: 3px solid #a48a76;">
|
|
594
|
+
<tr>
|
|
595
|
+
<td style="padding: 24px;">
|
|
596
|
+
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #868686; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Procedure</p>
|
|
597
|
+
<p style="margin: 0 0 16px 0; font-size: 18px; color: #67574A; font-weight: 500; font-family: Georgia, 'Times New Roman', serif;">{{procedureName}}</p>
|
|
598
|
+
|
|
599
|
+
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #868686; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Practitioner</p>
|
|
600
|
+
<p style="margin: 0; font-size: 15px; color: #333333; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{practitionerName}}</p>
|
|
601
|
+
</td>
|
|
602
|
+
</tr>
|
|
603
|
+
</table>
|
|
604
|
+
|
|
605
|
+
<!-- Time Comparison -->
|
|
606
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
|
|
607
|
+
<!-- Original Time (Strikethrough) -->
|
|
608
|
+
<tr>
|
|
609
|
+
<td style="padding: 20px 24px; background-color: #f5f5f5; border-left: 3px solid #cccccc;">
|
|
610
|
+
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #999999; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Original Appointment</p>
|
|
611
|
+
<p style="margin: 0; font-size: 16px; color: #999999; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; text-decoration: line-through;">{{previousDate}}</p>
|
|
612
|
+
<p style="margin: 4px 0 0 0; font-size: 14px; color: #999999; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; text-decoration: line-through;">{{previousTime}}</p>
|
|
613
|
+
</td>
|
|
614
|
+
</tr>
|
|
615
|
+
|
|
616
|
+
<!-- Spacer -->
|
|
617
|
+
<tr>
|
|
618
|
+
<td style="height: 12px;"></td>
|
|
619
|
+
</tr>
|
|
620
|
+
|
|
621
|
+
<!-- New Proposed Time -->
|
|
622
|
+
<tr>
|
|
623
|
+
<td style="padding: 24px; background-color: #f8f6f5; border-left: 3px solid #00BB38;">
|
|
624
|
+
<p style="margin: 0 0 4px 0; font-size: 11px; font-weight: 600; color: #00BB38; letter-spacing: 1px; text-transform: uppercase; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Proposed New Time</p>
|
|
625
|
+
<p style="margin: 0; font-size: 18px; color: #333333; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{newDate}}</p>
|
|
626
|
+
<p style="margin: 4px 0 0 0; font-size: 15px; color: #67574A; font-weight: 500; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">{{newTime}}</p>
|
|
627
|
+
</td>
|
|
628
|
+
</tr>
|
|
629
|
+
</table>
|
|
630
|
+
|
|
631
|
+
<!-- Divider -->
|
|
632
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px;">
|
|
633
|
+
<tr>
|
|
634
|
+
<td style="height: 1px; background-color: #e8e4df;"></td>
|
|
635
|
+
</tr>
|
|
636
|
+
</table>
|
|
637
|
+
|
|
638
|
+
<!-- Response Instructions -->
|
|
639
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 32px; background-color: #faf9f7;">
|
|
640
|
+
<tr>
|
|
641
|
+
<td style="padding: 28px;">
|
|
642
|
+
<p style="margin: 0 0 8px 0; font-size: 14px; font-weight: 600; color: #67574A; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">How to Respond</p>
|
|
643
|
+
<p style="margin: 0; font-size: 14px; color: #555555; line-height: 1.6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
644
|
+
Open the Metaesthetics app to accept or decline this reschedule request. Your appointment will remain pending until you respond.
|
|
645
|
+
</p>
|
|
646
|
+
</td>
|
|
647
|
+
</tr>
|
|
648
|
+
</table>
|
|
649
|
+
|
|
650
|
+
<!-- Response Notice -->
|
|
651
|
+
<p style="margin: 0; font-size: 13px; color: #868686; line-height: 1.6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
|
|
652
|
+
Please respond at your earliest convenience so we can finalize your appointment. If you have questions, contact {{clinicName}} through the app.
|
|
653
|
+
</p>
|
|
654
|
+
|
|
655
|
+
</td>
|
|
656
|
+
</tr>
|
|
657
|
+
|
|
658
|
+
<!-- Footer -->
|
|
659
|
+
<tr>
|
|
660
|
+
<td style="padding: 32px 48px; background-color: #faf9f7; border-top: 1px solid #f0ebe6;">
|
|
661
|
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
|
|
662
|
+
<tr>
|
|
663
|
+
<td>
|
|
664
|
+
<p style="margin: 0 0 8px 0; font-size: 14px; font-weight: 500; color: #67574A; font-family: Georgia, 'Times New Roman', serif;">{{clinicName}}</p>
|
|
665
|
+
<p style="margin: 0 0 16px 0; font-size: 13px; color: #868686; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Premium Aesthetic Services</p>
|
|
666
|
+
<p style="margin: 0; font-size: 11px; color: #aaaaaa; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">This is an automated message from Metaesthetics. Please do not reply directly to this email.</p>
|
|
667
|
+
</td>
|
|
668
|
+
</tr>
|
|
669
|
+
</table>
|
|
670
|
+
</td>
|
|
671
|
+
</tr>
|
|
672
|
+
|
|
673
|
+
</table>
|
|
674
|
+
</td>
|
|
675
|
+
</tr>
|
|
676
|
+
</table>
|
|
677
|
+
</body>
|
|
678
|
+
</html>
|
|
679
|
+
`;
|
|
680
|
+
|
|
681
|
+
// --- Interface Definitions for Email Data ---
|
|
682
|
+
|
|
683
|
+
export interface AppointmentEmailDataBase {
|
|
684
|
+
appointment: Appointment;
|
|
685
|
+
options?: {
|
|
686
|
+
customSubject?: string;
|
|
687
|
+
fromAddress?: string;
|
|
688
|
+
mailgunDomain?: string;
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
export interface AppointmentConfirmationEmailData extends AppointmentEmailDataBase {
|
|
693
|
+
recipientProfile: PatientProfileInfo | PractitionerProfileInfo;
|
|
694
|
+
recipientRole: 'patient' | 'practitioner';
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
export interface AppointmentRequestedEmailData extends AppointmentEmailDataBase {
|
|
698
|
+
clinicProfile: ClinicInfo;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export interface AppointmentCancellationEmailData extends AppointmentEmailDataBase {
|
|
702
|
+
recipientProfile: PatientProfileInfo | PractitionerProfileInfo;
|
|
703
|
+
recipientRole: 'patient' | 'practitioner';
|
|
704
|
+
cancellationReason?: string;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
export interface AppointmentRescheduledProposalEmailData extends AppointmentEmailDataBase {
|
|
708
|
+
patientProfile: PatientProfileInfo;
|
|
709
|
+
previousStartTime: admin.firestore.Timestamp;
|
|
710
|
+
previousEndTime: admin.firestore.Timestamp;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
export interface ReviewRequestEmailData extends AppointmentEmailDataBase {
|
|
714
|
+
patientProfile: PatientProfileInfo;
|
|
715
|
+
reviewLink: string;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
export interface ReviewAddedEmailData extends AppointmentEmailDataBase {
|
|
719
|
+
recipientProfile: PractitionerProfileInfo | ClinicInfo;
|
|
720
|
+
recipientRole: 'practitioner' | 'clinic';
|
|
721
|
+
reviewerName: string;
|
|
722
|
+
reviewRating: number;
|
|
723
|
+
reviewComment?: string;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Service for sending appointment-related emails.
|
|
728
|
+
*/
|
|
729
|
+
export class AppointmentMailingService extends BaseMailingService {
|
|
730
|
+
private readonly DEFAULT_MAILGUN_DOMAIN = 'mg.metaesthetics.net';
|
|
731
|
+
|
|
732
|
+
constructor(firestore: admin.firestore.Firestore, mailgunClient: NewMailgunClient) {
|
|
733
|
+
super(firestore, mailgunClient);
|
|
734
|
+
Logger.info('[AppointmentMailingService] Initialized.');
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Formats a Firestore Timestamp in the clinic's timezone
|
|
739
|
+
* @param timestamp - Firestore Timestamp (UTC)
|
|
740
|
+
* @param clinicTimezone - IANA timezone string (e.g., "Europe/Zurich")
|
|
741
|
+
* @param format - Format type: 'date', 'time', or 'datetime'
|
|
742
|
+
* @returns Formatted string in clinic's local timezone
|
|
743
|
+
*/
|
|
744
|
+
private formatTimestampInClinicTimezone(
|
|
745
|
+
timestamp: admin.firestore.Timestamp,
|
|
746
|
+
clinicTimezone: string,
|
|
747
|
+
format: 'date' | 'time' | 'datetime' = 'datetime',
|
|
748
|
+
): string {
|
|
749
|
+
try {
|
|
750
|
+
// Convert UTC timestamp to clinic's timezone
|
|
751
|
+
const dateTimeInClinicTz = DateTime.fromMillis(timestamp.toMillis(), {
|
|
752
|
+
zone: clinicTimezone,
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
// Format based on requested type
|
|
756
|
+
switch (format) {
|
|
757
|
+
case 'date':
|
|
758
|
+
// Format: "Monday, November 5, 2025"
|
|
759
|
+
return dateTimeInClinicTz.toLocaleString(DateTime.DATE_FULL);
|
|
760
|
+
case 'time':
|
|
761
|
+
// Format: "2:30 PM"
|
|
762
|
+
return dateTimeInClinicTz.toLocaleString(DateTime.TIME_SIMPLE);
|
|
763
|
+
case 'datetime':
|
|
764
|
+
// Format: "Monday, November 5, 2025 at 2:30 PM"
|
|
765
|
+
return dateTimeInClinicTz.toLocaleString(DateTime.DATETIME_FULL);
|
|
766
|
+
default:
|
|
767
|
+
return dateTimeInClinicTz.toLocaleString(DateTime.DATETIME_FULL);
|
|
768
|
+
}
|
|
769
|
+
} catch (error) {
|
|
770
|
+
Logger.error('[AppointmentMailingService] Error formatting timestamp in clinic timezone:', {
|
|
771
|
+
error: error instanceof Error ? error.message : String(error),
|
|
772
|
+
clinicTimezone,
|
|
773
|
+
});
|
|
774
|
+
// Fallback to UTC formatting if timezone conversion fails
|
|
775
|
+
return timestamp.toDate().toLocaleString();
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Gets a user-friendly display name for a timezone
|
|
781
|
+
* @param timezone - IANA timezone string (e.g., "Europe/Zurich")
|
|
782
|
+
* @returns User-friendly timezone name (e.g., "Clinic Time - Europe/Zurich")
|
|
783
|
+
*/
|
|
784
|
+
private getTimezoneDisplayName(timezone: string): string {
|
|
785
|
+
try {
|
|
786
|
+
// For common timezones, provide a more readable format
|
|
787
|
+
const timezoneMap: Record<string, string> = {
|
|
788
|
+
'Europe/Zurich': 'Clinic Time - Central European Time',
|
|
789
|
+
'Europe/London': 'Clinic Time - GMT/BST',
|
|
790
|
+
'America/New_York': 'Clinic Time - Eastern Time',
|
|
791
|
+
'America/Los_Angeles': 'Clinic Time - Pacific Time',
|
|
792
|
+
'Asia/Dubai': 'Clinic Time - Gulf Standard Time',
|
|
793
|
+
'Asia/Karachi': 'Clinic Time - Pakistan Standard Time',
|
|
794
|
+
'Asia/Kolkata': 'Clinic Time - India Standard Time',
|
|
795
|
+
'Australia/Sydney': 'Clinic Time - Australian Eastern Time',
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
// Return mapped name if available, otherwise use the IANA timezone
|
|
799
|
+
return timezoneMap[timezone] || `Clinic Time - ${timezone}`;
|
|
800
|
+
} catch (error) {
|
|
801
|
+
Logger.error('[AppointmentMailingService] Error getting timezone display name:', {
|
|
802
|
+
error: error instanceof Error ? error.message : String(error),
|
|
803
|
+
timezone,
|
|
804
|
+
});
|
|
805
|
+
return `Clinic Time - ${timezone}`;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
private formatClinicAddress(appointment: Appointment): string {
|
|
810
|
+
const loc = appointment.clinicInfo?.location;
|
|
811
|
+
if (!loc) return '';
|
|
812
|
+
const parts = [loc.address, loc.postalCode, loc.city, loc.country].filter(Boolean);
|
|
813
|
+
return parts.join(', ');
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
async sendAppointmentConfirmedEmail(data: AppointmentConfirmationEmailData): Promise<any> {
|
|
817
|
+
Logger.info(
|
|
818
|
+
`[AppointmentMailingService] Preparing to send appointment confirmation email to ${data.recipientRole}: ${data.recipientProfile.id}`,
|
|
819
|
+
);
|
|
820
|
+
|
|
821
|
+
const recipientEmail = data.recipientProfile.email;
|
|
822
|
+
|
|
823
|
+
if (!recipientEmail) {
|
|
824
|
+
Logger.error('[AppointmentMailingService] Recipient email not found for confirmation.', {
|
|
825
|
+
recipientId: data.recipientProfile.id,
|
|
826
|
+
role: data.recipientRole,
|
|
827
|
+
});
|
|
828
|
+
throw new Error('Recipient email address is missing.');
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
// Get clinic timezone from appointment data, default to UTC if not available
|
|
832
|
+
const clinicTimezone = data.appointment.clinic_tz || 'UTC';
|
|
833
|
+
|
|
834
|
+
Logger.debug('[AppointmentMailingService] Formatting appointment time', {
|
|
835
|
+
clinicTimezone,
|
|
836
|
+
utcTime: data.appointment.appointmentStartTime.toDate().toISOString(),
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
// Format time with timezone label for clarity
|
|
840
|
+
const formattedTime = this.formatTimestampInClinicTimezone(
|
|
841
|
+
data.appointment.appointmentStartTime,
|
|
842
|
+
clinicTimezone,
|
|
843
|
+
'time',
|
|
844
|
+
);
|
|
845
|
+
const timezoneName = this.getTimezoneDisplayName(clinicTimezone);
|
|
846
|
+
|
|
847
|
+
const templateVariables = {
|
|
848
|
+
patientName: data.appointment.patientInfo.fullName,
|
|
849
|
+
procedureName: data.appointment.procedureInfo.name,
|
|
850
|
+
appointmentDate: this.formatTimestampInClinicTimezone(
|
|
851
|
+
data.appointment.appointmentStartTime,
|
|
852
|
+
clinicTimezone,
|
|
853
|
+
'date',
|
|
854
|
+
),
|
|
855
|
+
appointmentTime: `${formattedTime} (${timezoneName})`,
|
|
856
|
+
practitionerName: data.appointment.practitionerInfo.name,
|
|
857
|
+
clinicName: data.appointment.clinicInfo.name,
|
|
858
|
+
clinicAddress: this.formatClinicAddress(data.appointment),
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
const html = this.renderTemplate(patientAppointmentConfirmedTemplate, templateVariables);
|
|
862
|
+
const subject = data.options?.customSubject || 'Your Appointment is Confirmed!';
|
|
863
|
+
const fromAddress =
|
|
864
|
+
data.options?.fromAddress ||
|
|
865
|
+
`Metaesthetics <no-reply@${data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN}>`;
|
|
866
|
+
const domainToSendFrom = data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN;
|
|
867
|
+
|
|
868
|
+
const mailgunSendData = {
|
|
869
|
+
to: recipientEmail,
|
|
870
|
+
from: fromAddress,
|
|
871
|
+
subject,
|
|
872
|
+
html,
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
try {
|
|
876
|
+
const result = await this.sendEmail(domainToSendFrom, mailgunSendData);
|
|
877
|
+
await this.logEmailAttempt(
|
|
878
|
+
{ to: recipientEmail, subject, templateName: 'appointment_confirmed' },
|
|
879
|
+
true,
|
|
880
|
+
);
|
|
881
|
+
return result;
|
|
882
|
+
} catch (error) {
|
|
883
|
+
await this.logEmailAttempt(
|
|
884
|
+
{
|
|
885
|
+
to: recipientEmail,
|
|
886
|
+
subject: data.options?.customSubject || 'Your Appointment is Confirmed!',
|
|
887
|
+
templateName: 'appointment_confirmed',
|
|
888
|
+
},
|
|
889
|
+
false,
|
|
890
|
+
error,
|
|
891
|
+
);
|
|
892
|
+
throw error;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
async sendAppointmentRequestedEmailToClinic(data: AppointmentRequestedEmailData): Promise<any> {
|
|
897
|
+
Logger.info(
|
|
898
|
+
`[AppointmentMailingService] Preparing to send appointment requested email to clinic: ${data.clinicProfile.id}`,
|
|
899
|
+
);
|
|
900
|
+
|
|
901
|
+
const clinicEmail = data.clinicProfile.contactInfo?.email;
|
|
902
|
+
if (!clinicEmail) {
|
|
903
|
+
Logger.error(
|
|
904
|
+
'[AppointmentMailingService] Clinic contact email not found for request notification.',
|
|
905
|
+
{ clinicId: data.clinicProfile.id },
|
|
906
|
+
);
|
|
907
|
+
throw new Error('Clinic contact email address is missing.');
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// Get clinic timezone from appointment data, default to UTC if not available
|
|
911
|
+
const clinicTimezone = data.appointment.clinic_tz || 'UTC';
|
|
912
|
+
|
|
913
|
+
Logger.debug('[AppointmentMailingService] Formatting appointment time for clinic', {
|
|
914
|
+
clinicTimezone,
|
|
915
|
+
utcTime: data.appointment.appointmentStartTime.toDate().toISOString(),
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
// Format time with timezone label for clarity
|
|
919
|
+
const formattedTime = this.formatTimestampInClinicTimezone(
|
|
920
|
+
data.appointment.appointmentStartTime,
|
|
921
|
+
clinicTimezone,
|
|
922
|
+
'time',
|
|
923
|
+
);
|
|
924
|
+
const timezoneName = this.getTimezoneDisplayName(clinicTimezone);
|
|
925
|
+
|
|
926
|
+
const templateVariables = {
|
|
927
|
+
clinicName: data.clinicProfile.name,
|
|
928
|
+
patientName: data.appointment.patientInfo.fullName,
|
|
929
|
+
procedureName: data.appointment.procedureInfo.name,
|
|
930
|
+
appointmentDate: this.formatTimestampInClinicTimezone(
|
|
931
|
+
data.appointment.appointmentStartTime,
|
|
932
|
+
clinicTimezone,
|
|
933
|
+
'date',
|
|
934
|
+
),
|
|
935
|
+
appointmentTime: `${formattedTime} (${timezoneName})`,
|
|
936
|
+
practitionerName: data.appointment.practitionerInfo.name,
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
const html = this.renderTemplate(clinicAppointmentRequestedTemplate, templateVariables);
|
|
940
|
+
const subject = data.options?.customSubject || 'New Appointment Request Received';
|
|
941
|
+
const fromAddress =
|
|
942
|
+
data.options?.fromAddress ||
|
|
943
|
+
`Metaesthetics <no-reply@${data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN}>`;
|
|
944
|
+
const domainToSendFrom = data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN;
|
|
945
|
+
|
|
946
|
+
const mailgunSendData = {
|
|
947
|
+
to: clinicEmail,
|
|
948
|
+
from: fromAddress,
|
|
949
|
+
subject,
|
|
950
|
+
html,
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
try {
|
|
954
|
+
const result = await this.sendEmail(domainToSendFrom, mailgunSendData);
|
|
955
|
+
await this.logEmailAttempt(
|
|
956
|
+
{
|
|
957
|
+
to: clinicEmail,
|
|
958
|
+
subject,
|
|
959
|
+
templateName: 'appointment_requested_clinic',
|
|
960
|
+
},
|
|
961
|
+
true,
|
|
962
|
+
);
|
|
963
|
+
return result;
|
|
964
|
+
} catch (error) {
|
|
965
|
+
await this.logEmailAttempt(
|
|
966
|
+
{
|
|
967
|
+
to: clinicEmail,
|
|
968
|
+
subject: data.options?.customSubject || 'New Appointment Request Received',
|
|
969
|
+
templateName: 'appointment_requested_clinic',
|
|
970
|
+
},
|
|
971
|
+
false,
|
|
972
|
+
error,
|
|
973
|
+
);
|
|
974
|
+
throw error;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Gets a user-friendly display text for who cancelled the appointment
|
|
980
|
+
* @param cancelledBy - The entity that cancelled the appointment
|
|
981
|
+
* @param clinicName - The clinic name for context
|
|
982
|
+
* @returns User-friendly cancellation source text
|
|
983
|
+
*/
|
|
984
|
+
private getCancelledByDisplayText(
|
|
985
|
+
cancelledBy: 'patient' | 'clinic' | 'practitioner' | 'system',
|
|
986
|
+
clinicName: string,
|
|
987
|
+
): string {
|
|
988
|
+
switch (cancelledBy) {
|
|
989
|
+
case 'patient':
|
|
990
|
+
return 'Patient Request';
|
|
991
|
+
case 'clinic':
|
|
992
|
+
return `${clinicName} (Clinic)`;
|
|
993
|
+
case 'practitioner':
|
|
994
|
+
return 'Your Practitioner';
|
|
995
|
+
case 'system':
|
|
996
|
+
return 'System (Automatic)';
|
|
997
|
+
default:
|
|
998
|
+
return 'Unknown';
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Sends an appointment cancellation email to the recipient
|
|
1004
|
+
* @param data - Appointment cancellation email data
|
|
1005
|
+
* @returns Promise with the sending result
|
|
1006
|
+
*/
|
|
1007
|
+
async sendAppointmentCancelledEmail(data: AppointmentCancellationEmailData): Promise<any> {
|
|
1008
|
+
Logger.info(
|
|
1009
|
+
`[AppointmentMailingService] Preparing to send appointment cancellation email to ${data.recipientRole}: ${data.recipientProfile.id}`,
|
|
1010
|
+
);
|
|
1011
|
+
|
|
1012
|
+
const recipientEmail = data.recipientProfile.email;
|
|
1013
|
+
|
|
1014
|
+
if (!recipientEmail) {
|
|
1015
|
+
Logger.error('[AppointmentMailingService] Recipient email not found for cancellation.', {
|
|
1016
|
+
recipientId: data.recipientProfile.id,
|
|
1017
|
+
role: data.recipientRole,
|
|
1018
|
+
});
|
|
1019
|
+
throw new Error('Recipient email address is missing.');
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
// Get clinic timezone from appointment data, default to UTC if not available
|
|
1023
|
+
const clinicTimezone = data.appointment.clinic_tz || 'UTC';
|
|
1024
|
+
|
|
1025
|
+
Logger.debug('[AppointmentMailingService] Formatting appointment time for cancellation', {
|
|
1026
|
+
clinicTimezone,
|
|
1027
|
+
utcTime: data.appointment.appointmentStartTime.toDate().toISOString(),
|
|
1028
|
+
});
|
|
1029
|
+
|
|
1030
|
+
// Format time with timezone label for clarity
|
|
1031
|
+
const formattedTime = this.formatTimestampInClinicTimezone(
|
|
1032
|
+
data.appointment.appointmentStartTime,
|
|
1033
|
+
clinicTimezone,
|
|
1034
|
+
'time',
|
|
1035
|
+
);
|
|
1036
|
+
const timezoneName = this.getTimezoneDisplayName(clinicTimezone);
|
|
1037
|
+
|
|
1038
|
+
// Determine the cancelled by source from the appointment
|
|
1039
|
+
const cancelledBy = data.appointment.canceledBy || 'system';
|
|
1040
|
+
const cancelledByDisplay = this.getCancelledByDisplayText(
|
|
1041
|
+
cancelledBy,
|
|
1042
|
+
data.appointment.clinicInfo.name,
|
|
1043
|
+
);
|
|
1044
|
+
|
|
1045
|
+
// Get recipient name based on role
|
|
1046
|
+
const recipientName =
|
|
1047
|
+
data.recipientRole === 'patient'
|
|
1048
|
+
? data.appointment.patientInfo.fullName
|
|
1049
|
+
: data.appointment.practitionerInfo.name;
|
|
1050
|
+
|
|
1051
|
+
// Build template variables
|
|
1052
|
+
const templateVariables: Record<string, string> = {
|
|
1053
|
+
recipientName,
|
|
1054
|
+
procedureName: data.appointment.procedureInfo.name,
|
|
1055
|
+
appointmentDate: this.formatTimestampInClinicTimezone(
|
|
1056
|
+
data.appointment.appointmentStartTime,
|
|
1057
|
+
clinicTimezone,
|
|
1058
|
+
'date',
|
|
1059
|
+
),
|
|
1060
|
+
appointmentTime: `${formattedTime} (${timezoneName})`,
|
|
1061
|
+
practitionerName: data.appointment.practitionerInfo.name,
|
|
1062
|
+
clinicName: data.appointment.clinicInfo.name,
|
|
1063
|
+
clinicAddress: this.formatClinicAddress(data.appointment),
|
|
1064
|
+
cancelledByDisplay,
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
// Handle cancellation reason - render with or without the reason block
|
|
1068
|
+
const cancellationReason = data.cancellationReason || data.appointment.cancellationReason;
|
|
1069
|
+
let html = appointmentCancelledTemplate;
|
|
1070
|
+
|
|
1071
|
+
if (cancellationReason) {
|
|
1072
|
+
// Replace the conditional block with the reason content
|
|
1073
|
+
templateVariables.cancellationReason = cancellationReason;
|
|
1074
|
+
html = html.replace(
|
|
1075
|
+
/\{\{#if cancellationReason\}\}([\s\S]*?)\{\{\/if\}\}/g,
|
|
1076
|
+
'$1',
|
|
1077
|
+
);
|
|
1078
|
+
} else {
|
|
1079
|
+
// Remove the conditional block entirely
|
|
1080
|
+
html = html.replace(/\{\{#if cancellationReason\}\}[\s\S]*?\{\{\/if\}\}/g, '');
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
html = this.renderTemplate(html, templateVariables);
|
|
1084
|
+
|
|
1085
|
+
const subject =
|
|
1086
|
+
data.options?.customSubject ||
|
|
1087
|
+
`Appointment Cancelled: ${data.appointment.procedureInfo.name}`;
|
|
1088
|
+
const fromAddress =
|
|
1089
|
+
data.options?.fromAddress ||
|
|
1090
|
+
`Metaesthetics <no-reply@${data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN}>`;
|
|
1091
|
+
const domainToSendFrom = data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN;
|
|
1092
|
+
|
|
1093
|
+
const mailgunSendData = {
|
|
1094
|
+
to: recipientEmail,
|
|
1095
|
+
from: fromAddress,
|
|
1096
|
+
subject,
|
|
1097
|
+
html,
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
try {
|
|
1101
|
+
const result = await this.sendEmail(domainToSendFrom, mailgunSendData);
|
|
1102
|
+
await this.logEmailAttempt(
|
|
1103
|
+
{ to: recipientEmail, subject, templateName: 'appointment_cancelled' },
|
|
1104
|
+
true,
|
|
1105
|
+
);
|
|
1106
|
+
Logger.info(
|
|
1107
|
+
`[AppointmentMailingService] Successfully sent cancellation email to ${recipientEmail}`,
|
|
1108
|
+
);
|
|
1109
|
+
return result;
|
|
1110
|
+
} catch (error) {
|
|
1111
|
+
await this.logEmailAttempt(
|
|
1112
|
+
{
|
|
1113
|
+
to: recipientEmail,
|
|
1114
|
+
subject,
|
|
1115
|
+
templateName: 'appointment_cancelled',
|
|
1116
|
+
},
|
|
1117
|
+
false,
|
|
1118
|
+
error,
|
|
1119
|
+
);
|
|
1120
|
+
Logger.error(
|
|
1121
|
+
`[AppointmentMailingService] Error sending cancellation email to ${recipientEmail}:`,
|
|
1122
|
+
error,
|
|
1123
|
+
);
|
|
1124
|
+
throw error;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Sends a reschedule proposal email to the patient
|
|
1130
|
+
* @param data - Appointment reschedule proposal email data
|
|
1131
|
+
* @returns Promise with the sending result
|
|
1132
|
+
*/
|
|
1133
|
+
async sendAppointmentRescheduledProposalEmail(
|
|
1134
|
+
data: AppointmentRescheduledProposalEmailData,
|
|
1135
|
+
): Promise<any> {
|
|
1136
|
+
Logger.info(
|
|
1137
|
+
`[AppointmentMailingService] Preparing to send reschedule proposal email to patient: ${data.patientProfile.id}`,
|
|
1138
|
+
);
|
|
1139
|
+
|
|
1140
|
+
const recipientEmail = data.patientProfile.email;
|
|
1141
|
+
|
|
1142
|
+
if (!recipientEmail) {
|
|
1143
|
+
Logger.error('[AppointmentMailingService] Patient email not found for reschedule proposal.', {
|
|
1144
|
+
patientId: data.patientProfile.id,
|
|
1145
|
+
});
|
|
1146
|
+
throw new Error('Patient email address is missing.');
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
// Get clinic timezone from appointment data, default to UTC if not available
|
|
1150
|
+
const clinicTimezone = data.appointment.clinic_tz || 'UTC';
|
|
1151
|
+
|
|
1152
|
+
Logger.debug('[AppointmentMailingService] Formatting appointment times for reschedule', {
|
|
1153
|
+
clinicTimezone,
|
|
1154
|
+
previousTime: data.previousStartTime.toDate().toISOString(),
|
|
1155
|
+
newTime: data.appointment.appointmentStartTime.toDate().toISOString(),
|
|
1156
|
+
});
|
|
1157
|
+
|
|
1158
|
+
// Format previous time
|
|
1159
|
+
const previousFormattedTime = this.formatTimestampInClinicTimezone(
|
|
1160
|
+
data.previousStartTime,
|
|
1161
|
+
clinicTimezone,
|
|
1162
|
+
'time',
|
|
1163
|
+
);
|
|
1164
|
+
const previousFormattedDate = this.formatTimestampInClinicTimezone(
|
|
1165
|
+
data.previousStartTime,
|
|
1166
|
+
clinicTimezone,
|
|
1167
|
+
'date',
|
|
1168
|
+
);
|
|
1169
|
+
const previousTimezoneName = this.getTimezoneDisplayName(clinicTimezone);
|
|
1170
|
+
|
|
1171
|
+
// Format new proposed time
|
|
1172
|
+
const newFormattedTime = this.formatTimestampInClinicTimezone(
|
|
1173
|
+
data.appointment.appointmentStartTime,
|
|
1174
|
+
clinicTimezone,
|
|
1175
|
+
'time',
|
|
1176
|
+
);
|
|
1177
|
+
const newFormattedDate = this.formatTimestampInClinicTimezone(
|
|
1178
|
+
data.appointment.appointmentStartTime,
|
|
1179
|
+
clinicTimezone,
|
|
1180
|
+
'date',
|
|
1181
|
+
);
|
|
1182
|
+
const newTimezoneName = this.getTimezoneDisplayName(clinicTimezone);
|
|
1183
|
+
|
|
1184
|
+
const templateVariables = {
|
|
1185
|
+
patientName: data.appointment.patientInfo.fullName,
|
|
1186
|
+
procedureName: data.appointment.procedureInfo.name,
|
|
1187
|
+
practitionerName: data.appointment.practitionerInfo.name,
|
|
1188
|
+
clinicName: data.appointment.clinicInfo.name,
|
|
1189
|
+
clinicAddress: this.formatClinicAddress(data.appointment),
|
|
1190
|
+
previousDate: previousFormattedDate,
|
|
1191
|
+
previousTime: `${previousFormattedTime} (${previousTimezoneName})`,
|
|
1192
|
+
newDate: newFormattedDate,
|
|
1193
|
+
newTime: `${newFormattedTime} (${newTimezoneName})`,
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
const html = this.renderTemplate(appointmentRescheduledProposalTemplate, templateVariables);
|
|
1197
|
+
const subject =
|
|
1198
|
+
data.options?.customSubject ||
|
|
1199
|
+
`Action Required: Reschedule Proposal for Your ${data.appointment.procedureInfo.name} Appointment`;
|
|
1200
|
+
const fromAddress =
|
|
1201
|
+
data.options?.fromAddress ||
|
|
1202
|
+
`Metaesthetics <no-reply@${data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN}>`;
|
|
1203
|
+
const domainToSendFrom = data.options?.mailgunDomain || this.DEFAULT_MAILGUN_DOMAIN;
|
|
1204
|
+
|
|
1205
|
+
const mailgunSendData = {
|
|
1206
|
+
to: recipientEmail,
|
|
1207
|
+
from: fromAddress,
|
|
1208
|
+
subject,
|
|
1209
|
+
html,
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1212
|
+
try {
|
|
1213
|
+
const result = await this.sendEmail(domainToSendFrom, mailgunSendData);
|
|
1214
|
+
await this.logEmailAttempt(
|
|
1215
|
+
{ to: recipientEmail, subject, templateName: 'appointment_rescheduled_proposal' },
|
|
1216
|
+
true,
|
|
1217
|
+
);
|
|
1218
|
+
Logger.info(
|
|
1219
|
+
`[AppointmentMailingService] Successfully sent reschedule proposal email to ${recipientEmail}`,
|
|
1220
|
+
);
|
|
1221
|
+
return result;
|
|
1222
|
+
} catch (error) {
|
|
1223
|
+
await this.logEmailAttempt(
|
|
1224
|
+
{
|
|
1225
|
+
to: recipientEmail,
|
|
1226
|
+
subject,
|
|
1227
|
+
templateName: 'appointment_rescheduled_proposal',
|
|
1228
|
+
},
|
|
1229
|
+
false,
|
|
1230
|
+
error,
|
|
1231
|
+
);
|
|
1232
|
+
Logger.error(
|
|
1233
|
+
`[AppointmentMailingService] Error sending reschedule proposal email to ${recipientEmail}:`,
|
|
1234
|
+
error,
|
|
1235
|
+
);
|
|
1236
|
+
throw error;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
async sendReviewRequestEmail(data: ReviewRequestEmailData): Promise<any> {
|
|
1241
|
+
Logger.info(
|
|
1242
|
+
`[AppointmentMailingService] Placeholder for sendReviewRequestEmail to patient: ${data.patientProfile.id}`,
|
|
1243
|
+
);
|
|
1244
|
+
return Promise.resolve();
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
async sendReviewAddedEmail(data: ReviewAddedEmailData): Promise<any> {
|
|
1248
|
+
Logger.info(
|
|
1249
|
+
`[AppointmentMailingService] Placeholder for sendReviewAddedEmail to ${data.recipientRole}: ${data.recipientProfile.id}`,
|
|
1250
|
+
);
|
|
1251
|
+
return Promise.resolve();
|
|
1252
|
+
}
|
|
1253
|
+
}
|