@blackcode_sa/metaestetics-api 1.14.29 → 1.14.34
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 +133 -15
- package/dist/admin/index.d.ts +133 -15
- package/dist/admin/index.js +376 -2
- package/dist/admin/index.mjs +373 -2
- package/dist/index.js +4 -2
- package/dist/index.mjs +4 -2
- package/package.json +1 -1
- package/src/admin/index.ts +2 -0
- package/src/admin/mailing/README.md +44 -0
- package/src/admin/mailing/index.ts +1 -0
- package/src/admin/mailing/patientInvite/index.ts +2 -0
- package/src/admin/mailing/patientInvite/patientInvite.mailing.ts +415 -0
- package/src/admin/mailing/patientInvite/templates/invitation.template.ts +105 -0
- package/src/services/analytics/analytics.service.ts +10 -4
package/dist/admin/index.mjs
CHANGED
|
@@ -382,6 +382,15 @@ var PATIENT_MEDICAL_INFO_COLLECTION = "medical_info";
|
|
|
382
382
|
var PATIENTS_COLLECTION = "patients";
|
|
383
383
|
var PATIENT_SENSITIVE_INFO_COLLECTION = "sensitive-info";
|
|
384
384
|
|
|
385
|
+
// src/types/patient/token.types.ts
|
|
386
|
+
var INVITE_TOKENS_COLLECTION = "inviteTokens";
|
|
387
|
+
var PatientTokenStatus = /* @__PURE__ */ ((PatientTokenStatus2) => {
|
|
388
|
+
PatientTokenStatus2["ACTIVE"] = "active";
|
|
389
|
+
PatientTokenStatus2["USED"] = "used";
|
|
390
|
+
PatientTokenStatus2["EXPIRED"] = "expired";
|
|
391
|
+
return PatientTokenStatus2;
|
|
392
|
+
})(PatientTokenStatus || {});
|
|
393
|
+
|
|
385
394
|
// src/types/clinic/practitioner-invite.types.ts
|
|
386
395
|
var PractitionerInviteStatus = /* @__PURE__ */ ((PractitionerInviteStatus2) => {
|
|
387
396
|
PractitionerInviteStatus2["PENDING"] = "pending";
|
|
@@ -9026,7 +9035,8 @@ var AnalyticsService = class extends BaseService {
|
|
|
9026
9035
|
return metrics;
|
|
9027
9036
|
}
|
|
9028
9037
|
}
|
|
9029
|
-
const
|
|
9038
|
+
const filters = (options == null ? void 0 : options.clinicBranchId) ? { clinicBranchId: options.clinicBranchId } : void 0;
|
|
9039
|
+
const appointments = await this.fetchAppointments(filters, dateRange);
|
|
9030
9040
|
const canceled = getCanceledAppointments(appointments);
|
|
9031
9041
|
if (groupBy === "clinic") {
|
|
9032
9042
|
return this.groupCancellationsByClinic(canceled, appointments);
|
|
@@ -9255,7 +9265,8 @@ var AnalyticsService = class extends BaseService {
|
|
|
9255
9265
|
return metrics;
|
|
9256
9266
|
}
|
|
9257
9267
|
}
|
|
9258
|
-
const
|
|
9268
|
+
const filters = (options == null ? void 0 : options.clinicBranchId) ? { clinicBranchId: options.clinicBranchId } : void 0;
|
|
9269
|
+
const appointments = await this.fetchAppointments(filters, dateRange);
|
|
9259
9270
|
const noShow = getNoShowAppointments(appointments);
|
|
9260
9271
|
if (groupBy === "clinic") {
|
|
9261
9272
|
return this.groupNoShowsByClinic(noShow, appointments);
|
|
@@ -13073,6 +13084,363 @@ var ExistingPractitionerInviteMailingService = class extends BaseMailingService
|
|
|
13073
13084
|
}
|
|
13074
13085
|
};
|
|
13075
13086
|
|
|
13087
|
+
// src/admin/mailing/patientInvite/templates/invitation.template.ts
|
|
13088
|
+
var patientInvitationTemplate = `
|
|
13089
|
+
<!DOCTYPE html>
|
|
13090
|
+
<html>
|
|
13091
|
+
<head>
|
|
13092
|
+
<meta charset="UTF-8">
|
|
13093
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
13094
|
+
<title>Claim Your Patient Profile at {{clinicName}}</title>
|
|
13095
|
+
<style>
|
|
13096
|
+
body {
|
|
13097
|
+
font-family: Arial, sans-serif;
|
|
13098
|
+
line-height: 1.6;
|
|
13099
|
+
color: #333;
|
|
13100
|
+
margin: 0;
|
|
13101
|
+
padding: 0;
|
|
13102
|
+
}
|
|
13103
|
+
.container {
|
|
13104
|
+
max-width: 600px;
|
|
13105
|
+
margin: 0 auto;
|
|
13106
|
+
padding: 20px;
|
|
13107
|
+
}
|
|
13108
|
+
.header {
|
|
13109
|
+
background-color: #4A90E2;
|
|
13110
|
+
padding: 20px;
|
|
13111
|
+
text-align: center;
|
|
13112
|
+
color: white;
|
|
13113
|
+
}
|
|
13114
|
+
.content {
|
|
13115
|
+
padding: 20px;
|
|
13116
|
+
background-color: #f9f9f9;
|
|
13117
|
+
}
|
|
13118
|
+
.footer {
|
|
13119
|
+
padding: 20px;
|
|
13120
|
+
text-align: center;
|
|
13121
|
+
font-size: 12px;
|
|
13122
|
+
color: #888;
|
|
13123
|
+
}
|
|
13124
|
+
.token {
|
|
13125
|
+
font-size: 24px;
|
|
13126
|
+
font-weight: bold;
|
|
13127
|
+
color: #4A90E2;
|
|
13128
|
+
padding: 10px;
|
|
13129
|
+
background-color: #e9f0f9;
|
|
13130
|
+
border-radius: 4px;
|
|
13131
|
+
display: inline-block;
|
|
13132
|
+
letter-spacing: 2px;
|
|
13133
|
+
margin: 10px 0;
|
|
13134
|
+
}
|
|
13135
|
+
.info-box {
|
|
13136
|
+
background-color: #fff;
|
|
13137
|
+
border-left: 4px solid #4A90E2;
|
|
13138
|
+
padding: 15px;
|
|
13139
|
+
margin: 20px 0;
|
|
13140
|
+
}
|
|
13141
|
+
</style>
|
|
13142
|
+
</head>
|
|
13143
|
+
<body>
|
|
13144
|
+
<div class="container">
|
|
13145
|
+
<div class="header">
|
|
13146
|
+
<h1>Welcome to MetaEsthetics</h1>
|
|
13147
|
+
</div>
|
|
13148
|
+
<div class="content">
|
|
13149
|
+
<p>Hello {{patientName}},</p>
|
|
13150
|
+
|
|
13151
|
+
<p>A patient profile has been created for you at <strong>{{clinicName}}</strong>. You can now claim this profile to access your personal health dashboard and appointment history.</p>
|
|
13152
|
+
|
|
13153
|
+
<div class="info-box">
|
|
13154
|
+
<p><strong>What you'll get access to:</strong></p>
|
|
13155
|
+
<ul>
|
|
13156
|
+
<li>Your complete treatment history</li>
|
|
13157
|
+
<li>Upcoming appointment details</li>
|
|
13158
|
+
<li>Pre and post-treatment instructions</li>
|
|
13159
|
+
<li>Direct messaging with your clinic</li>
|
|
13160
|
+
</ul>
|
|
13161
|
+
</div>
|
|
13162
|
+
|
|
13163
|
+
<p>To claim your profile, use this registration token:</p>
|
|
13164
|
+
|
|
13165
|
+
<div style="text-align: center;">
|
|
13166
|
+
<span class="token">{{inviteToken}}</span>
|
|
13167
|
+
</div>
|
|
13168
|
+
|
|
13169
|
+
<p><strong>Important:</strong> This token will expire on <strong>{{expirationDate}}</strong>.</p>
|
|
13170
|
+
|
|
13171
|
+
<p>To create your account:</p>
|
|
13172
|
+
<ol>
|
|
13173
|
+
<li>Download the <strong>MetaEsthetics</strong> app from the App Store (iOS) or Google Play Store (Android)</li>
|
|
13174
|
+
<li>Open the app and create an account using your email address</li>
|
|
13175
|
+
<li>When prompted, enter the token shown above</li>
|
|
13176
|
+
<li>Your profile will be automatically linked to your new account</li>
|
|
13177
|
+
</ol>
|
|
13178
|
+
|
|
13179
|
+
<p>If you have any questions or didn't expect this email, please contact {{contactName}} at {{contactEmail}}.</p>
|
|
13180
|
+
</div>
|
|
13181
|
+
<div class="footer">
|
|
13182
|
+
<p>This is an automated message from {{clinicName}}. Please do not reply to this email.</p>
|
|
13183
|
+
<p>© {{currentYear}} MetaEsthetics. All rights reserved.</p>
|
|
13184
|
+
</div>
|
|
13185
|
+
</div>
|
|
13186
|
+
</body>
|
|
13187
|
+
</html>
|
|
13188
|
+
`;
|
|
13189
|
+
|
|
13190
|
+
// src/admin/mailing/patientInvite/patientInvite.mailing.ts
|
|
13191
|
+
var PatientInviteMailingService = class extends BaseMailingService {
|
|
13192
|
+
/**
|
|
13193
|
+
* Constructor for PatientInviteMailingService
|
|
13194
|
+
* @param firestore - Firestore instance provided by the caller
|
|
13195
|
+
* @param mailgunClient - Mailgun client instance (mailgun.js v10+) provided by the caller
|
|
13196
|
+
*/
|
|
13197
|
+
constructor(firestore19, mailgunClient) {
|
|
13198
|
+
super(firestore19, mailgunClient);
|
|
13199
|
+
this.DEFAULT_REGISTRATION_URL = "https://metaesthetics.net/patient/register";
|
|
13200
|
+
this.DEFAULT_SUBJECT = "Claim Your Patient Profile - MetaEsthetics";
|
|
13201
|
+
this.DEFAULT_MAILGUN_DOMAIN = "mg.metaesthetics.net";
|
|
13202
|
+
}
|
|
13203
|
+
/**
|
|
13204
|
+
* Sends a patient invitation email
|
|
13205
|
+
* @param data - The patient invitation data
|
|
13206
|
+
* @returns Promise resolved when email is sent
|
|
13207
|
+
*/
|
|
13208
|
+
async sendInvitationEmail(data) {
|
|
13209
|
+
var _a, _b, _c, _d, _e, _f;
|
|
13210
|
+
try {
|
|
13211
|
+
Logger.info(
|
|
13212
|
+
"[PatientInviteMailingService] Sending invitation email to",
|
|
13213
|
+
data.token.email
|
|
13214
|
+
);
|
|
13215
|
+
const expirationDate = data.token.expiresAt.toDate().toLocaleDateString("en-US", {
|
|
13216
|
+
weekday: "long",
|
|
13217
|
+
year: "numeric",
|
|
13218
|
+
month: "long",
|
|
13219
|
+
day: "numeric"
|
|
13220
|
+
});
|
|
13221
|
+
const registrationUrl = ((_a = data.options) == null ? void 0 : _a.registrationUrl) || this.DEFAULT_REGISTRATION_URL;
|
|
13222
|
+
const contactName = data.clinic.contactName || "Clinic Administrator";
|
|
13223
|
+
const contactEmail = data.clinic.contactEmail;
|
|
13224
|
+
const subject = ((_b = data.options) == null ? void 0 : _b.customSubject) || this.DEFAULT_SUBJECT;
|
|
13225
|
+
const fromAddress = ((_c = data.options) == null ? void 0 : _c.fromAddress) || `MetaEsthetics <no-reply@${((_d = data.options) == null ? void 0 : _d.mailgunDomain) || this.DEFAULT_MAILGUN_DOMAIN}>`;
|
|
13226
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear().toString();
|
|
13227
|
+
const patientName = `${data.patient.firstName} ${data.patient.lastName}`;
|
|
13228
|
+
const templateVariables = {
|
|
13229
|
+
clinicName: data.clinic.name,
|
|
13230
|
+
patientName,
|
|
13231
|
+
inviteToken: data.token.token,
|
|
13232
|
+
expirationDate,
|
|
13233
|
+
registrationUrl,
|
|
13234
|
+
contactName,
|
|
13235
|
+
contactEmail,
|
|
13236
|
+
currentYear
|
|
13237
|
+
};
|
|
13238
|
+
Logger.info("[PatientInviteMailingService] Template variables:", {
|
|
13239
|
+
clinicName: templateVariables.clinicName,
|
|
13240
|
+
patientName: templateVariables.patientName,
|
|
13241
|
+
expirationDate: templateVariables.expirationDate,
|
|
13242
|
+
registrationUrl: templateVariables.registrationUrl,
|
|
13243
|
+
contactName: templateVariables.contactName,
|
|
13244
|
+
contactEmail: templateVariables.contactEmail,
|
|
13245
|
+
hasInviteToken: !!templateVariables.inviteToken
|
|
13246
|
+
});
|
|
13247
|
+
const html = this.renderTemplate(
|
|
13248
|
+
patientInvitationTemplate,
|
|
13249
|
+
templateVariables
|
|
13250
|
+
);
|
|
13251
|
+
const mailgunSendData = {
|
|
13252
|
+
to: data.token.email,
|
|
13253
|
+
from: fromAddress,
|
|
13254
|
+
subject,
|
|
13255
|
+
html
|
|
13256
|
+
};
|
|
13257
|
+
const domainToSendFrom = ((_e = data.options) == null ? void 0 : _e.mailgunDomain) || this.DEFAULT_MAILGUN_DOMAIN;
|
|
13258
|
+
Logger.info("[PatientInviteMailingService] Sending email with data:", {
|
|
13259
|
+
domain: domainToSendFrom,
|
|
13260
|
+
to: mailgunSendData.to,
|
|
13261
|
+
from: mailgunSendData.from,
|
|
13262
|
+
subject: mailgunSendData.subject,
|
|
13263
|
+
hasHtml: !!mailgunSendData.html
|
|
13264
|
+
});
|
|
13265
|
+
const result = await this.sendEmail(domainToSendFrom, mailgunSendData);
|
|
13266
|
+
await this.logEmailAttempt(
|
|
13267
|
+
{
|
|
13268
|
+
to: data.token.email,
|
|
13269
|
+
subject,
|
|
13270
|
+
templateName: "patient_invitation"
|
|
13271
|
+
},
|
|
13272
|
+
true
|
|
13273
|
+
);
|
|
13274
|
+
return result;
|
|
13275
|
+
} catch (error) {
|
|
13276
|
+
Logger.error(
|
|
13277
|
+
"[PatientInviteMailingService] Error sending invitation email:",
|
|
13278
|
+
{
|
|
13279
|
+
errorMessage: error.message,
|
|
13280
|
+
errorDetails: error.details,
|
|
13281
|
+
errorStatus: error.status,
|
|
13282
|
+
stack: error.stack
|
|
13283
|
+
}
|
|
13284
|
+
);
|
|
13285
|
+
await this.logEmailAttempt(
|
|
13286
|
+
{
|
|
13287
|
+
to: data.token.email,
|
|
13288
|
+
subject: ((_f = data.options) == null ? void 0 : _f.customSubject) || this.DEFAULT_SUBJECT,
|
|
13289
|
+
templateName: "patient_invitation"
|
|
13290
|
+
},
|
|
13291
|
+
false,
|
|
13292
|
+
error
|
|
13293
|
+
);
|
|
13294
|
+
throw error;
|
|
13295
|
+
}
|
|
13296
|
+
}
|
|
13297
|
+
/**
|
|
13298
|
+
* Handles the patient token creation event from Cloud Functions.
|
|
13299
|
+
* Fetches necessary data and sends the invitation email.
|
|
13300
|
+
* @param tokenData - The fully typed token object including its id
|
|
13301
|
+
* @param mailgunConfig - Mailgun configuration (from, domain, optional registrationUrl)
|
|
13302
|
+
* @returns Promise resolved when the email is sent
|
|
13303
|
+
*/
|
|
13304
|
+
async handleTokenCreationEvent(tokenData, mailgunConfig) {
|
|
13305
|
+
try {
|
|
13306
|
+
Logger.info(
|
|
13307
|
+
"[PatientInviteMailingService] Handling token creation event for token:",
|
|
13308
|
+
tokenData.id
|
|
13309
|
+
);
|
|
13310
|
+
if (!tokenData || !tokenData.id || !tokenData.token || !tokenData.email) {
|
|
13311
|
+
throw new Error(
|
|
13312
|
+
`Invalid token data: Missing required properties. Token ID: ${tokenData == null ? void 0 : tokenData.id}`
|
|
13313
|
+
);
|
|
13314
|
+
}
|
|
13315
|
+
if (!tokenData.patientId) {
|
|
13316
|
+
throw new Error(
|
|
13317
|
+
`Token ${tokenData.id} is missing patientId reference`
|
|
13318
|
+
);
|
|
13319
|
+
}
|
|
13320
|
+
if (!tokenData.clinicId) {
|
|
13321
|
+
throw new Error(`Token ${tokenData.id} is missing clinicId reference`);
|
|
13322
|
+
}
|
|
13323
|
+
if (!tokenData.expiresAt) {
|
|
13324
|
+
throw new Error(`Token ${tokenData.id} is missing expiration date`);
|
|
13325
|
+
}
|
|
13326
|
+
if (tokenData.status !== "active" /* ACTIVE */ && String(tokenData.status).toLowerCase() !== "active") {
|
|
13327
|
+
Logger.warn(
|
|
13328
|
+
"[PatientInviteMailingService] Token is not active, skipping email.",
|
|
13329
|
+
{ tokenId: tokenData.id, status: tokenData.status }
|
|
13330
|
+
);
|
|
13331
|
+
return;
|
|
13332
|
+
}
|
|
13333
|
+
Logger.info(
|
|
13334
|
+
`[PatientInviteMailingService] Token status validation:`,
|
|
13335
|
+
{
|
|
13336
|
+
tokenId: tokenData.id,
|
|
13337
|
+
status: tokenData.status,
|
|
13338
|
+
statusType: typeof tokenData.status
|
|
13339
|
+
}
|
|
13340
|
+
);
|
|
13341
|
+
Logger.info(
|
|
13342
|
+
`[PatientInviteMailingService] Fetching patient data: ${tokenData.patientId}`
|
|
13343
|
+
);
|
|
13344
|
+
const patientRef = this.db.collection(PATIENTS_COLLECTION).doc(tokenData.patientId);
|
|
13345
|
+
const patientDoc = await patientRef.get();
|
|
13346
|
+
if (!patientDoc.exists) {
|
|
13347
|
+
throw new Error(`Patient ${tokenData.patientId} not found`);
|
|
13348
|
+
}
|
|
13349
|
+
const patientData = patientDoc.data();
|
|
13350
|
+
if (!patientData) {
|
|
13351
|
+
throw new Error(
|
|
13352
|
+
`Patient ${tokenData.patientId} has invalid data structure`
|
|
13353
|
+
);
|
|
13354
|
+
}
|
|
13355
|
+
const sensitiveInfoRef = patientRef.collection(PATIENT_SENSITIVE_INFO_COLLECTION).doc(tokenData.patientId);
|
|
13356
|
+
const sensitiveInfoDoc = await sensitiveInfoRef.get();
|
|
13357
|
+
let firstName = "Patient";
|
|
13358
|
+
let lastName = "";
|
|
13359
|
+
if (sensitiveInfoDoc.exists) {
|
|
13360
|
+
const sensitiveInfo = sensitiveInfoDoc.data();
|
|
13361
|
+
firstName = (sensitiveInfo == null ? void 0 : sensitiveInfo.firstName) || "Patient";
|
|
13362
|
+
lastName = (sensitiveInfo == null ? void 0 : sensitiveInfo.lastName) || "";
|
|
13363
|
+
} else {
|
|
13364
|
+
Logger.warn(
|
|
13365
|
+
`[PatientInviteMailingService] No sensitive info found for patient ${tokenData.patientId}, using displayName`
|
|
13366
|
+
);
|
|
13367
|
+
const displayNameParts = (patientData.displayName || "Patient").split(" ");
|
|
13368
|
+
firstName = displayNameParts[0] || "Patient";
|
|
13369
|
+
lastName = displayNameParts.slice(1).join(" ") || "";
|
|
13370
|
+
}
|
|
13371
|
+
Logger.info(
|
|
13372
|
+
`[PatientInviteMailingService] Patient found: ${firstName} ${lastName}`
|
|
13373
|
+
);
|
|
13374
|
+
Logger.info(
|
|
13375
|
+
`[PatientInviteMailingService] Fetching clinic data: ${tokenData.clinicId}`
|
|
13376
|
+
);
|
|
13377
|
+
const clinicRef = this.db.collection(CLINICS_COLLECTION).doc(tokenData.clinicId);
|
|
13378
|
+
const clinicDoc = await clinicRef.get();
|
|
13379
|
+
if (!clinicDoc.exists) {
|
|
13380
|
+
throw new Error(`Clinic ${tokenData.clinicId} not found`);
|
|
13381
|
+
}
|
|
13382
|
+
const clinicData = clinicDoc.data();
|
|
13383
|
+
if (!clinicData || !clinicData.contactInfo) {
|
|
13384
|
+
throw new Error(
|
|
13385
|
+
`Clinic ${tokenData.clinicId} has invalid data structure`
|
|
13386
|
+
);
|
|
13387
|
+
}
|
|
13388
|
+
Logger.info(
|
|
13389
|
+
`[PatientInviteMailingService] Clinic found: ${clinicData.name}`
|
|
13390
|
+
);
|
|
13391
|
+
if (!mailgunConfig.fromAddress) {
|
|
13392
|
+
Logger.warn(
|
|
13393
|
+
"[PatientInviteMailingService] No fromAddress provided, using default"
|
|
13394
|
+
);
|
|
13395
|
+
mailgunConfig.fromAddress = `MetaEsthetics <no-reply@${this.DEFAULT_MAILGUN_DOMAIN}>`;
|
|
13396
|
+
}
|
|
13397
|
+
const emailData = {
|
|
13398
|
+
token: {
|
|
13399
|
+
id: tokenData.id,
|
|
13400
|
+
token: tokenData.token,
|
|
13401
|
+
patientId: tokenData.patientId,
|
|
13402
|
+
email: tokenData.email,
|
|
13403
|
+
clinicId: tokenData.clinicId,
|
|
13404
|
+
expiresAt: tokenData.expiresAt
|
|
13405
|
+
},
|
|
13406
|
+
patient: {
|
|
13407
|
+
firstName,
|
|
13408
|
+
lastName
|
|
13409
|
+
},
|
|
13410
|
+
clinic: {
|
|
13411
|
+
name: clinicData.name || "Medical Clinic",
|
|
13412
|
+
contactEmail: clinicData.contactInfo.email || "contact@clinic.com",
|
|
13413
|
+
contactName: "Clinic Admin"
|
|
13414
|
+
},
|
|
13415
|
+
options: {
|
|
13416
|
+
fromAddress: mailgunConfig.fromAddress,
|
|
13417
|
+
mailgunDomain: mailgunConfig.domain,
|
|
13418
|
+
registrationUrl: mailgunConfig.registrationUrl
|
|
13419
|
+
}
|
|
13420
|
+
};
|
|
13421
|
+
Logger.info(
|
|
13422
|
+
"[PatientInviteMailingService] Email data prepared, sending invitation"
|
|
13423
|
+
);
|
|
13424
|
+
await this.sendInvitationEmail(emailData);
|
|
13425
|
+
Logger.info(
|
|
13426
|
+
"[PatientInviteMailingService] Invitation email sent successfully"
|
|
13427
|
+
);
|
|
13428
|
+
} catch (error) {
|
|
13429
|
+
Logger.error(
|
|
13430
|
+
"[PatientInviteMailingService] Error handling token creation event:",
|
|
13431
|
+
{
|
|
13432
|
+
errorMessage: error.message,
|
|
13433
|
+
errorDetails: error.details,
|
|
13434
|
+
errorStatus: error.status,
|
|
13435
|
+
stack: error.stack,
|
|
13436
|
+
tokenId: tokenData == null ? void 0 : tokenData.id
|
|
13437
|
+
}
|
|
13438
|
+
);
|
|
13439
|
+
throw error;
|
|
13440
|
+
}
|
|
13441
|
+
}
|
|
13442
|
+
};
|
|
13443
|
+
|
|
13076
13444
|
// src/admin/users/user-profile.admin.ts
|
|
13077
13445
|
import * as admin18 from "firebase-admin";
|
|
13078
13446
|
var UserProfileAdminService = class {
|
|
@@ -13378,6 +13746,7 @@ export {
|
|
|
13378
13746
|
DocumentManagerAdminService,
|
|
13379
13747
|
ExistingPractitionerInviteMailingService,
|
|
13380
13748
|
FilledFormsAggregationService,
|
|
13749
|
+
INVITE_TOKENS_COLLECTION,
|
|
13381
13750
|
Logger,
|
|
13382
13751
|
NOTIFICATIONS_COLLECTION,
|
|
13383
13752
|
NO_SHOW_ANALYTICS_SUBCOLLECTION,
|
|
@@ -13391,8 +13760,10 @@ export {
|
|
|
13391
13760
|
PROCEDURE_ANALYTICS_SUBCOLLECTION,
|
|
13392
13761
|
PatientAggregationService,
|
|
13393
13762
|
PatientInstructionStatus,
|
|
13763
|
+
PatientInviteMailingService,
|
|
13394
13764
|
PatientRequirementOverallStatus,
|
|
13395
13765
|
PatientRequirementsAdminService,
|
|
13766
|
+
PatientTokenStatus,
|
|
13396
13767
|
PractitionerAggregationService,
|
|
13397
13768
|
PractitionerInviteAggregationService,
|
|
13398
13769
|
PractitionerInviteMailingService,
|
package/dist/index.js
CHANGED
|
@@ -2295,7 +2295,8 @@ var AnalyticsService = class extends BaseService {
|
|
|
2295
2295
|
return metrics;
|
|
2296
2296
|
}
|
|
2297
2297
|
}
|
|
2298
|
-
const
|
|
2298
|
+
const filters = (options == null ? void 0 : options.clinicBranchId) ? { clinicBranchId: options.clinicBranchId } : void 0;
|
|
2299
|
+
const appointments = await this.fetchAppointments(filters, dateRange);
|
|
2299
2300
|
const canceled = getCanceledAppointments(appointments);
|
|
2300
2301
|
if (groupBy === "clinic") {
|
|
2301
2302
|
return this.groupCancellationsByClinic(canceled, appointments);
|
|
@@ -2524,7 +2525,8 @@ var AnalyticsService = class extends BaseService {
|
|
|
2524
2525
|
return metrics;
|
|
2525
2526
|
}
|
|
2526
2527
|
}
|
|
2527
|
-
const
|
|
2528
|
+
const filters = (options == null ? void 0 : options.clinicBranchId) ? { clinicBranchId: options.clinicBranchId } : void 0;
|
|
2529
|
+
const appointments = await this.fetchAppointments(filters, dateRange);
|
|
2528
2530
|
const noShow = getNoShowAppointments(appointments);
|
|
2529
2531
|
if (groupBy === "clinic") {
|
|
2530
2532
|
return this.groupNoShowsByClinic(noShow, appointments);
|
package/dist/index.mjs
CHANGED
|
@@ -2138,7 +2138,8 @@ var AnalyticsService = class extends BaseService {
|
|
|
2138
2138
|
return metrics;
|
|
2139
2139
|
}
|
|
2140
2140
|
}
|
|
2141
|
-
const
|
|
2141
|
+
const filters = (options == null ? void 0 : options.clinicBranchId) ? { clinicBranchId: options.clinicBranchId } : void 0;
|
|
2142
|
+
const appointments = await this.fetchAppointments(filters, dateRange);
|
|
2142
2143
|
const canceled = getCanceledAppointments(appointments);
|
|
2143
2144
|
if (groupBy === "clinic") {
|
|
2144
2145
|
return this.groupCancellationsByClinic(canceled, appointments);
|
|
@@ -2367,7 +2368,8 @@ var AnalyticsService = class extends BaseService {
|
|
|
2367
2368
|
return metrics;
|
|
2368
2369
|
}
|
|
2369
2370
|
}
|
|
2370
|
-
const
|
|
2371
|
+
const filters = (options == null ? void 0 : options.clinicBranchId) ? { clinicBranchId: options.clinicBranchId } : void 0;
|
|
2372
|
+
const appointments = await this.fetchAppointments(filters, dateRange);
|
|
2371
2373
|
const noShow = getNoShowAppointments(appointments);
|
|
2372
2374
|
if (groupBy === "clinic") {
|
|
2373
2375
|
return this.groupNoShowsByClinic(noShow, appointments);
|
package/package.json
CHANGED
package/src/admin/index.ts
CHANGED
|
@@ -15,6 +15,8 @@ export type { ClinicInfo } from '../types/profile';
|
|
|
15
15
|
export type { Practitioner, PractitionerToken } from '../types/practitioner';
|
|
16
16
|
export type { PractitionerInvite } from '../types/clinic/practitioner-invite.types';
|
|
17
17
|
export type { DoctorInfo } from '../types/clinic';
|
|
18
|
+
export type { PatientToken } from '../types/patient/token.types';
|
|
19
|
+
export { PatientTokenStatus, INVITE_TOKENS_COLLECTION } from '../types/patient/token.types';
|
|
18
20
|
export type { Procedure, ProcedureSummaryInfo } from '../types/procedure';
|
|
19
21
|
export type { PatientProfile as Patient } from '../types/patient';
|
|
20
22
|
export type { Appointment } from '../types/appointment';
|
|
@@ -46,6 +46,50 @@ Sends email invitations to practitioners when they are invited to join a clinic.
|
|
|
46
46
|
2. The function uses the `PractitionerInviteMailingService` to send an invitation email to the practitioner.
|
|
47
47
|
3. The email contains the token needed to claim their profile and instructions for registration.
|
|
48
48
|
|
|
49
|
+
### Patient Invitation Service
|
|
50
|
+
|
|
51
|
+
Sends email invitations to patients when a clinic admin creates their profile and generates an invitation token.
|
|
52
|
+
|
|
53
|
+
#### How it works:
|
|
54
|
+
|
|
55
|
+
1. When a new patient invitation token is created in the Firestore database (`patients/{patientId}/inviteTokens/{tokenId}`), the `onPatientTokenCreated` cloud function is triggered.
|
|
56
|
+
2. The function uses the `PatientInviteMailingService` to send an invitation email to the patient.
|
|
57
|
+
3. The email contains the token needed to claim their profile and instructions for registering in the patient app.
|
|
58
|
+
|
|
59
|
+
#### Example Usage in Code:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { PatientInviteMailingService } from "./admin/mailing";
|
|
63
|
+
|
|
64
|
+
// Create a new instance of the service
|
|
65
|
+
const mailingService = new PatientInviteMailingService(firestoreClient, mailgunClient);
|
|
66
|
+
|
|
67
|
+
// Send an invitation email
|
|
68
|
+
await mailingService.sendInvitationEmail({
|
|
69
|
+
token: {
|
|
70
|
+
id: "token-id",
|
|
71
|
+
token: "ABC123",
|
|
72
|
+
patientId: "patient-id",
|
|
73
|
+
email: "patient@example.com",
|
|
74
|
+
clinicId: "clinic-id",
|
|
75
|
+
expiresAt: admin.firestore.Timestamp.fromDate(new Date()),
|
|
76
|
+
},
|
|
77
|
+
patient: {
|
|
78
|
+
firstName: "Jane",
|
|
79
|
+
lastName: "Doe",
|
|
80
|
+
},
|
|
81
|
+
clinic: {
|
|
82
|
+
name: "Example Clinic",
|
|
83
|
+
contactEmail: "admin@example.com",
|
|
84
|
+
contactName: "Clinic Admin",
|
|
85
|
+
},
|
|
86
|
+
options: {
|
|
87
|
+
registrationUrl: "https://your-app.com/patient/register",
|
|
88
|
+
customSubject: "Claim Your Patient Profile",
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
49
93
|
#### Example Usage in Code:
|
|
50
94
|
|
|
51
95
|
```typescript
|