@blackcode_sa/metaestetics-api 1.12.72 → 1.13.1
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 +872 -1
- package/dist/admin/index.d.ts +872 -1
- package/dist/admin/index.js +3604 -356
- package/dist/admin/index.mjs +3594 -357
- package/dist/index.d.mts +1349 -1
- package/dist/index.d.ts +1349 -1
- package/dist/index.js +5325 -2141
- package/dist/index.mjs +4939 -1767
- package/package.json +1 -1
- package/src/admin/analytics/analytics.admin.service.ts +278 -0
- package/src/admin/analytics/index.ts +2 -0
- package/src/admin/index.ts +6 -0
- package/src/backoffice/services/analytics.service.proposal.md +4 -0
- package/src/services/analytics/ARCHITECTURE.md +199 -0
- package/src/services/analytics/CLOUD_FUNCTIONS.md +225 -0
- package/src/services/analytics/GROUPED_ANALYTICS.md +501 -0
- package/src/services/analytics/QUICK_START.md +393 -0
- package/src/services/analytics/README.md +304 -0
- package/src/services/analytics/SUMMARY.md +141 -0
- package/src/services/analytics/TRENDS.md +380 -0
- package/src/services/analytics/USAGE_GUIDE.md +518 -0
- package/src/services/analytics/analytics-cloud.service.ts +222 -0
- package/src/services/analytics/analytics.service.ts +2142 -0
- package/src/services/analytics/index.ts +4 -0
- package/src/services/analytics/review-analytics.service.ts +941 -0
- package/src/services/analytics/utils/appointment-filtering.utils.ts +138 -0
- package/src/services/analytics/utils/cost-calculation.utils.ts +182 -0
- package/src/services/analytics/utils/grouping.utils.ts +434 -0
- package/src/services/analytics/utils/stored-analytics.utils.ts +347 -0
- package/src/services/analytics/utils/time-calculation.utils.ts +186 -0
- package/src/services/analytics/utils/trend-calculation.utils.ts +200 -0
- package/src/services/index.ts +1 -0
- package/src/types/analytics/analytics.types.ts +597 -0
- package/src/types/analytics/grouped-analytics.types.ts +173 -0
- package/src/types/analytics/index.ts +4 -0
- package/src/types/analytics/stored-analytics.types.ts +137 -0
- package/src/types/index.ts +3 -0
package/dist/index.d.ts
CHANGED
|
@@ -3996,6 +3996,837 @@ interface CreatePatientTokenData {
|
|
|
3996
3996
|
expiresAt?: Date;
|
|
3997
3997
|
}
|
|
3998
3998
|
|
|
3999
|
+
/**
|
|
4000
|
+
* Base metrics interface with common properties
|
|
4001
|
+
*/
|
|
4002
|
+
interface BaseMetrics {
|
|
4003
|
+
total: number;
|
|
4004
|
+
dateRange?: {
|
|
4005
|
+
start: Date;
|
|
4006
|
+
end: Date;
|
|
4007
|
+
};
|
|
4008
|
+
}
|
|
4009
|
+
/**
|
|
4010
|
+
* Date range filter for analytics queries
|
|
4011
|
+
*/
|
|
4012
|
+
interface AnalyticsDateRange {
|
|
4013
|
+
start: Date;
|
|
4014
|
+
end: Date;
|
|
4015
|
+
}
|
|
4016
|
+
/**
|
|
4017
|
+
* Common filters for analytics queries
|
|
4018
|
+
*/
|
|
4019
|
+
interface AnalyticsFilters {
|
|
4020
|
+
clinicBranchId?: string;
|
|
4021
|
+
practitionerId?: string;
|
|
4022
|
+
procedureId?: string;
|
|
4023
|
+
patientId?: string;
|
|
4024
|
+
}
|
|
4025
|
+
/**
|
|
4026
|
+
* Grouping period for trend analysis
|
|
4027
|
+
*/
|
|
4028
|
+
type GroupingPeriod = 'day' | 'week' | 'month';
|
|
4029
|
+
/**
|
|
4030
|
+
* Trend period type (only predefined periods, no custom)
|
|
4031
|
+
*/
|
|
4032
|
+
type TrendPeriod = 'week' | 'month' | 'quarter' | 'year';
|
|
4033
|
+
/**
|
|
4034
|
+
* Entity type for grouping analytics
|
|
4035
|
+
*/
|
|
4036
|
+
type EntityType = 'clinic' | 'practitioner' | 'patient' | 'procedure' | 'technology';
|
|
4037
|
+
/**
|
|
4038
|
+
* Practitioner Analytics
|
|
4039
|
+
* Comprehensive metrics for a practitioner's performance
|
|
4040
|
+
*/
|
|
4041
|
+
interface PractitionerAnalytics extends BaseMetrics {
|
|
4042
|
+
practitionerId: string;
|
|
4043
|
+
practitionerName: string;
|
|
4044
|
+
totalAppointments: number;
|
|
4045
|
+
completedAppointments: number;
|
|
4046
|
+
canceledAppointments: number;
|
|
4047
|
+
noShowAppointments: number;
|
|
4048
|
+
pendingAppointments: number;
|
|
4049
|
+
confirmedAppointments: number;
|
|
4050
|
+
cancellationRate: number;
|
|
4051
|
+
noShowRate: number;
|
|
4052
|
+
averageBookedTime: number;
|
|
4053
|
+
averageActualTime: number;
|
|
4054
|
+
timeEfficiency: number;
|
|
4055
|
+
totalRevenue: number;
|
|
4056
|
+
averageRevenuePerAppointment: number;
|
|
4057
|
+
currency: string;
|
|
4058
|
+
topProcedures: Array<{
|
|
4059
|
+
procedureId: string;
|
|
4060
|
+
procedureName: string;
|
|
4061
|
+
count: number;
|
|
4062
|
+
revenue: number;
|
|
4063
|
+
}>;
|
|
4064
|
+
patientRetentionRate: number;
|
|
4065
|
+
uniquePatients: number;
|
|
4066
|
+
}
|
|
4067
|
+
/**
|
|
4068
|
+
* Procedure Analytics
|
|
4069
|
+
* Comprehensive metrics for procedure performance
|
|
4070
|
+
*/
|
|
4071
|
+
interface ProcedureAnalytics extends BaseMetrics {
|
|
4072
|
+
procedureId: string;
|
|
4073
|
+
procedureName: string;
|
|
4074
|
+
procedureFamily: string;
|
|
4075
|
+
categoryName: string;
|
|
4076
|
+
subcategoryName: string;
|
|
4077
|
+
technologyName: string;
|
|
4078
|
+
totalAppointments: number;
|
|
4079
|
+
completedAppointments: number;
|
|
4080
|
+
canceledAppointments: number;
|
|
4081
|
+
noShowAppointments: number;
|
|
4082
|
+
cancellationRate: number;
|
|
4083
|
+
noShowRate: number;
|
|
4084
|
+
averageCost: number;
|
|
4085
|
+
totalRevenue: number;
|
|
4086
|
+
averageRevenuePerAppointment: number;
|
|
4087
|
+
currency: string;
|
|
4088
|
+
averageBookedDuration: number;
|
|
4089
|
+
averageActualDuration: number;
|
|
4090
|
+
productUsage: Array<{
|
|
4091
|
+
productId: string;
|
|
4092
|
+
productName: string;
|
|
4093
|
+
brandName: string;
|
|
4094
|
+
totalQuantity: number;
|
|
4095
|
+
totalRevenue: number;
|
|
4096
|
+
usageCount: number;
|
|
4097
|
+
}>;
|
|
4098
|
+
}
|
|
4099
|
+
/**
|
|
4100
|
+
* Time Efficiency Metrics
|
|
4101
|
+
* Analysis of booked time vs actual time spent
|
|
4102
|
+
*/
|
|
4103
|
+
interface TimeEfficiencyMetrics {
|
|
4104
|
+
totalAppointments: number;
|
|
4105
|
+
appointmentsWithActualTime: number;
|
|
4106
|
+
averageBookedDuration: number;
|
|
4107
|
+
averageActualDuration: number;
|
|
4108
|
+
averageEfficiency: number;
|
|
4109
|
+
totalOverrun: number;
|
|
4110
|
+
totalUnderutilization: number;
|
|
4111
|
+
averageOverrun: number;
|
|
4112
|
+
averageUnderutilization: number;
|
|
4113
|
+
efficiencyDistribution: Array<{
|
|
4114
|
+
range: string;
|
|
4115
|
+
count: number;
|
|
4116
|
+
percentage: number;
|
|
4117
|
+
}>;
|
|
4118
|
+
}
|
|
4119
|
+
/**
|
|
4120
|
+
* Cancellation Metrics
|
|
4121
|
+
* Analysis of appointment cancellations
|
|
4122
|
+
*/
|
|
4123
|
+
interface CancellationMetrics {
|
|
4124
|
+
entityId: string;
|
|
4125
|
+
entityName: string;
|
|
4126
|
+
entityType: EntityType;
|
|
4127
|
+
totalAppointments: number;
|
|
4128
|
+
canceledAppointments: number;
|
|
4129
|
+
cancellationRate: number;
|
|
4130
|
+
canceledByPatient: number;
|
|
4131
|
+
canceledByClinic: number;
|
|
4132
|
+
canceledByPractitioner: number;
|
|
4133
|
+
canceledRescheduled: number;
|
|
4134
|
+
averageCancellationLeadTime: number;
|
|
4135
|
+
cancellationReasons: Array<{
|
|
4136
|
+
reason: string;
|
|
4137
|
+
count: number;
|
|
4138
|
+
percentage: number;
|
|
4139
|
+
}>;
|
|
4140
|
+
practitionerId?: string;
|
|
4141
|
+
practitionerName?: string;
|
|
4142
|
+
}
|
|
4143
|
+
/**
|
|
4144
|
+
* No-Show Metrics
|
|
4145
|
+
* Analysis of appointment no-shows
|
|
4146
|
+
*/
|
|
4147
|
+
interface NoShowMetrics {
|
|
4148
|
+
entityId: string;
|
|
4149
|
+
entityName: string;
|
|
4150
|
+
entityType: EntityType;
|
|
4151
|
+
totalAppointments: number;
|
|
4152
|
+
noShowAppointments: number;
|
|
4153
|
+
noShowRate: number;
|
|
4154
|
+
practitionerId?: string;
|
|
4155
|
+
practitionerName?: string;
|
|
4156
|
+
}
|
|
4157
|
+
/**
|
|
4158
|
+
* Revenue Metrics
|
|
4159
|
+
* Financial analysis and revenue tracking
|
|
4160
|
+
*/
|
|
4161
|
+
interface RevenueMetrics {
|
|
4162
|
+
totalRevenue: number;
|
|
4163
|
+
averageRevenuePerAppointment: number;
|
|
4164
|
+
totalAppointments: number;
|
|
4165
|
+
completedAppointments: number;
|
|
4166
|
+
currency: string;
|
|
4167
|
+
revenueByStatus: Partial<Record<AppointmentStatus, number>>;
|
|
4168
|
+
revenueByPaymentStatus: Partial<Record<PaymentStatus, number>>;
|
|
4169
|
+
unpaidRevenue: number;
|
|
4170
|
+
refundedRevenue: number;
|
|
4171
|
+
totalTax: number;
|
|
4172
|
+
totalSubtotal: number;
|
|
4173
|
+
}
|
|
4174
|
+
/**
|
|
4175
|
+
* Revenue Trend
|
|
4176
|
+
* Revenue data over time
|
|
4177
|
+
*/
|
|
4178
|
+
interface RevenueTrend {
|
|
4179
|
+
period: string;
|
|
4180
|
+
startDate: Date;
|
|
4181
|
+
endDate: Date;
|
|
4182
|
+
revenue: number;
|
|
4183
|
+
appointmentCount: number;
|
|
4184
|
+
averageRevenue: number;
|
|
4185
|
+
currency?: string;
|
|
4186
|
+
previousPeriod?: {
|
|
4187
|
+
revenue: number;
|
|
4188
|
+
appointmentCount: number;
|
|
4189
|
+
percentageChange: number;
|
|
4190
|
+
direction: 'up' | 'down' | 'stable';
|
|
4191
|
+
};
|
|
4192
|
+
}
|
|
4193
|
+
/**
|
|
4194
|
+
* Duration Trend
|
|
4195
|
+
* Appointment duration trends over time
|
|
4196
|
+
*/
|
|
4197
|
+
interface DurationTrend {
|
|
4198
|
+
period: string;
|
|
4199
|
+
startDate: Date;
|
|
4200
|
+
endDate: Date;
|
|
4201
|
+
averageBookedDuration: number;
|
|
4202
|
+
averageActualDuration: number;
|
|
4203
|
+
averageEfficiency: number;
|
|
4204
|
+
appointmentCount: number;
|
|
4205
|
+
previousPeriod?: {
|
|
4206
|
+
averageBookedDuration: number;
|
|
4207
|
+
averageActualDuration: number;
|
|
4208
|
+
averageEfficiency: number;
|
|
4209
|
+
efficiencyPercentageChange: number;
|
|
4210
|
+
direction: 'up' | 'down' | 'stable';
|
|
4211
|
+
};
|
|
4212
|
+
}
|
|
4213
|
+
/**
|
|
4214
|
+
* Appointment Count Trend
|
|
4215
|
+
* Appointment count trends over time
|
|
4216
|
+
*/
|
|
4217
|
+
interface AppointmentTrend {
|
|
4218
|
+
period: string;
|
|
4219
|
+
startDate: Date;
|
|
4220
|
+
endDate: Date;
|
|
4221
|
+
totalAppointments: number;
|
|
4222
|
+
completedAppointments: number;
|
|
4223
|
+
canceledAppointments: number;
|
|
4224
|
+
noShowAppointments: number;
|
|
4225
|
+
pendingAppointments: number;
|
|
4226
|
+
confirmedAppointments: number;
|
|
4227
|
+
previousPeriod?: {
|
|
4228
|
+
totalAppointments: number;
|
|
4229
|
+
completedAppointments: number;
|
|
4230
|
+
percentageChange: number;
|
|
4231
|
+
direction: 'up' | 'down' | 'stable';
|
|
4232
|
+
};
|
|
4233
|
+
}
|
|
4234
|
+
/**
|
|
4235
|
+
* Cancellation Rate Trend
|
|
4236
|
+
* Cancellation and no-show rate trends over time
|
|
4237
|
+
*/
|
|
4238
|
+
interface CancellationRateTrend {
|
|
4239
|
+
period: string;
|
|
4240
|
+
startDate: Date;
|
|
4241
|
+
endDate: Date;
|
|
4242
|
+
cancellationRate: number;
|
|
4243
|
+
noShowRate: number;
|
|
4244
|
+
totalAppointments: number;
|
|
4245
|
+
canceledAppointments: number;
|
|
4246
|
+
noShowAppointments: number;
|
|
4247
|
+
previousPeriod?: {
|
|
4248
|
+
cancellationRate: number;
|
|
4249
|
+
noShowRate: number;
|
|
4250
|
+
cancellationRateChange: number;
|
|
4251
|
+
noShowRateChange: number;
|
|
4252
|
+
direction: 'up' | 'down' | 'stable';
|
|
4253
|
+
};
|
|
4254
|
+
}
|
|
4255
|
+
/**
|
|
4256
|
+
* Review Trend
|
|
4257
|
+
* Review rating and recommendation trends over time
|
|
4258
|
+
*/
|
|
4259
|
+
interface ReviewTrend {
|
|
4260
|
+
period: string;
|
|
4261
|
+
startDate: Date;
|
|
4262
|
+
endDate: Date;
|
|
4263
|
+
averageRating: number;
|
|
4264
|
+
recommendationRate: number;
|
|
4265
|
+
totalReviews: number;
|
|
4266
|
+
practitionerAverage?: number;
|
|
4267
|
+
procedureAverage?: number;
|
|
4268
|
+
previousPeriod?: {
|
|
4269
|
+
averageRating: number;
|
|
4270
|
+
recommendationRate: number;
|
|
4271
|
+
percentageChange: number;
|
|
4272
|
+
direction: 'up' | 'down' | 'stable';
|
|
4273
|
+
};
|
|
4274
|
+
entityId?: string;
|
|
4275
|
+
entityName?: string;
|
|
4276
|
+
}
|
|
4277
|
+
/**
|
|
4278
|
+
* Product Usage Metrics
|
|
4279
|
+
* Analysis of product usage in appointments
|
|
4280
|
+
*/
|
|
4281
|
+
interface ProductUsageMetrics {
|
|
4282
|
+
productId: string;
|
|
4283
|
+
productName: string;
|
|
4284
|
+
brandId: string;
|
|
4285
|
+
brandName: string;
|
|
4286
|
+
totalQuantity: number;
|
|
4287
|
+
totalRevenue: number;
|
|
4288
|
+
averagePrice: number;
|
|
4289
|
+
currency: string;
|
|
4290
|
+
usageCount: number;
|
|
4291
|
+
averageQuantityPerAppointment: number;
|
|
4292
|
+
usageByProcedure: Array<{
|
|
4293
|
+
procedureId: string;
|
|
4294
|
+
procedureName: string;
|
|
4295
|
+
count: number;
|
|
4296
|
+
totalQuantity: number;
|
|
4297
|
+
}>;
|
|
4298
|
+
}
|
|
4299
|
+
/**
|
|
4300
|
+
* Product Revenue Metrics
|
|
4301
|
+
* Revenue contribution by product
|
|
4302
|
+
*/
|
|
4303
|
+
interface ProductRevenueMetrics {
|
|
4304
|
+
productId: string;
|
|
4305
|
+
productName: string;
|
|
4306
|
+
brandName: string;
|
|
4307
|
+
totalRevenue: number;
|
|
4308
|
+
currency: string;
|
|
4309
|
+
usageCount: number;
|
|
4310
|
+
averageRevenuePerUsage: number;
|
|
4311
|
+
}
|
|
4312
|
+
/**
|
|
4313
|
+
* Product Usage by Procedure
|
|
4314
|
+
* Product usage patterns for specific procedures
|
|
4315
|
+
*/
|
|
4316
|
+
interface ProductUsageByProcedure {
|
|
4317
|
+
procedureId: string;
|
|
4318
|
+
procedureName: string;
|
|
4319
|
+
products: Array<{
|
|
4320
|
+
productId: string;
|
|
4321
|
+
productName: string;
|
|
4322
|
+
brandName: string;
|
|
4323
|
+
totalQuantity: number;
|
|
4324
|
+
totalRevenue: number;
|
|
4325
|
+
usageCount: number;
|
|
4326
|
+
}>;
|
|
4327
|
+
}
|
|
4328
|
+
/**
|
|
4329
|
+
* Patient Analytics
|
|
4330
|
+
* Comprehensive patient metrics
|
|
4331
|
+
*/
|
|
4332
|
+
interface PatientAnalytics {
|
|
4333
|
+
patientId: string;
|
|
4334
|
+
patientName: string;
|
|
4335
|
+
totalAppointments: number;
|
|
4336
|
+
completedAppointments: number;
|
|
4337
|
+
canceledAppointments: number;
|
|
4338
|
+
noShowAppointments: number;
|
|
4339
|
+
cancellationRate: number;
|
|
4340
|
+
noShowRate: number;
|
|
4341
|
+
totalRevenue: number;
|
|
4342
|
+
averageRevenuePerAppointment: number;
|
|
4343
|
+
currency: string;
|
|
4344
|
+
lifetimeValue: number;
|
|
4345
|
+
firstAppointmentDate: Date | null;
|
|
4346
|
+
lastAppointmentDate: Date | null;
|
|
4347
|
+
averageDaysBetweenAppointments: number | null;
|
|
4348
|
+
uniquePractitioners: number;
|
|
4349
|
+
uniqueClinics: number;
|
|
4350
|
+
favoriteProcedures: Array<{
|
|
4351
|
+
procedureId: string;
|
|
4352
|
+
procedureName: string;
|
|
4353
|
+
count: number;
|
|
4354
|
+
}>;
|
|
4355
|
+
}
|
|
4356
|
+
/**
|
|
4357
|
+
* Patient Lifetime Value Metrics
|
|
4358
|
+
* Patient value analysis
|
|
4359
|
+
*/
|
|
4360
|
+
interface PatientLifetimeValueMetrics {
|
|
4361
|
+
totalPatients: number;
|
|
4362
|
+
averageLifetimeValue: number;
|
|
4363
|
+
currency: string;
|
|
4364
|
+
topPatients: Array<{
|
|
4365
|
+
patientId: string;
|
|
4366
|
+
patientName: string;
|
|
4367
|
+
lifetimeValue: number;
|
|
4368
|
+
appointmentCount: number;
|
|
4369
|
+
}>;
|
|
4370
|
+
valueDistribution: Array<{
|
|
4371
|
+
range: string;
|
|
4372
|
+
count: number;
|
|
4373
|
+
percentage: number;
|
|
4374
|
+
}>;
|
|
4375
|
+
}
|
|
4376
|
+
/**
|
|
4377
|
+
* Patient Retention Metrics
|
|
4378
|
+
* Patient retention and return analysis
|
|
4379
|
+
*/
|
|
4380
|
+
interface PatientRetentionMetrics {
|
|
4381
|
+
totalPatients: number;
|
|
4382
|
+
newPatients: number;
|
|
4383
|
+
returningPatients: number;
|
|
4384
|
+
retentionRate: number;
|
|
4385
|
+
averageAppointmentsPerPatient: number;
|
|
4386
|
+
patientsByAppointmentCount: Array<{
|
|
4387
|
+
appointmentCount: number;
|
|
4388
|
+
patientCount: number;
|
|
4389
|
+
percentage: number;
|
|
4390
|
+
}>;
|
|
4391
|
+
}
|
|
4392
|
+
/**
|
|
4393
|
+
* Cost Per Patient Metrics
|
|
4394
|
+
* Cost analysis per patient
|
|
4395
|
+
*/
|
|
4396
|
+
interface CostPerPatientMetrics {
|
|
4397
|
+
totalPatients: number;
|
|
4398
|
+
totalRevenue: number;
|
|
4399
|
+
averageCostPerPatient: number;
|
|
4400
|
+
currency: string;
|
|
4401
|
+
costDistribution: Array<{
|
|
4402
|
+
range: string;
|
|
4403
|
+
patientCount: number;
|
|
4404
|
+
percentage: number;
|
|
4405
|
+
}>;
|
|
4406
|
+
patientCosts?: Array<{
|
|
4407
|
+
patientId: string;
|
|
4408
|
+
patientName: string;
|
|
4409
|
+
totalCost: number;
|
|
4410
|
+
appointmentCount: number;
|
|
4411
|
+
averageCost: number;
|
|
4412
|
+
}>;
|
|
4413
|
+
}
|
|
4414
|
+
/**
|
|
4415
|
+
* Payment Status Breakdown
|
|
4416
|
+
* Analysis of payment statuses
|
|
4417
|
+
*/
|
|
4418
|
+
interface PaymentStatusBreakdown {
|
|
4419
|
+
totalAppointments: number;
|
|
4420
|
+
byStatus: Partial<Record<PaymentStatus, {
|
|
4421
|
+
count: number;
|
|
4422
|
+
percentage: number;
|
|
4423
|
+
totalRevenue: number;
|
|
4424
|
+
}>>;
|
|
4425
|
+
unpaidCount: number;
|
|
4426
|
+
unpaidRevenue: number;
|
|
4427
|
+
paidCount: number;
|
|
4428
|
+
paidRevenue: number;
|
|
4429
|
+
partiallyPaidCount: number;
|
|
4430
|
+
partiallyPaidRevenue: number;
|
|
4431
|
+
refundedCount: number;
|
|
4432
|
+
refundedRevenue: number;
|
|
4433
|
+
}
|
|
4434
|
+
/**
|
|
4435
|
+
* Clinic Analytics
|
|
4436
|
+
* Comprehensive clinic performance metrics
|
|
4437
|
+
*/
|
|
4438
|
+
interface ClinicAnalytics {
|
|
4439
|
+
clinicBranchId: string;
|
|
4440
|
+
clinicName: string;
|
|
4441
|
+
totalAppointments: number;
|
|
4442
|
+
completedAppointments: number;
|
|
4443
|
+
canceledAppointments: number;
|
|
4444
|
+
noShowAppointments: number;
|
|
4445
|
+
cancellationRate: number;
|
|
4446
|
+
noShowRate: number;
|
|
4447
|
+
totalRevenue: number;
|
|
4448
|
+
averageRevenuePerAppointment: number;
|
|
4449
|
+
currency: string;
|
|
4450
|
+
practitionerCount: number;
|
|
4451
|
+
patientCount: number;
|
|
4452
|
+
procedureCount: number;
|
|
4453
|
+
topPractitioners: Array<{
|
|
4454
|
+
practitionerId: string;
|
|
4455
|
+
practitionerName: string;
|
|
4456
|
+
appointmentCount: number;
|
|
4457
|
+
revenue: number;
|
|
4458
|
+
}>;
|
|
4459
|
+
topProcedures: Array<{
|
|
4460
|
+
procedureId: string;
|
|
4461
|
+
procedureName: string;
|
|
4462
|
+
appointmentCount: number;
|
|
4463
|
+
revenue: number;
|
|
4464
|
+
}>;
|
|
4465
|
+
}
|
|
4466
|
+
/**
|
|
4467
|
+
* Clinic Comparison Metrics
|
|
4468
|
+
* Comparison data for multiple clinics
|
|
4469
|
+
*/
|
|
4470
|
+
interface ClinicComparisonMetrics {
|
|
4471
|
+
clinicBranchId: string;
|
|
4472
|
+
clinicName: string;
|
|
4473
|
+
totalAppointments: number;
|
|
4474
|
+
completedAppointments: number;
|
|
4475
|
+
cancellationRate: number;
|
|
4476
|
+
noShowRate: number;
|
|
4477
|
+
totalRevenue: number;
|
|
4478
|
+
averageRevenuePerAppointment: number;
|
|
4479
|
+
practitionerCount: number;
|
|
4480
|
+
patientCount: number;
|
|
4481
|
+
efficiency: number;
|
|
4482
|
+
}
|
|
4483
|
+
/**
|
|
4484
|
+
* Procedure Popularity
|
|
4485
|
+
* Popularity metrics for procedures
|
|
4486
|
+
*/
|
|
4487
|
+
interface ProcedurePopularity {
|
|
4488
|
+
procedureId: string;
|
|
4489
|
+
procedureName: string;
|
|
4490
|
+
categoryName: string;
|
|
4491
|
+
subcategoryName: string;
|
|
4492
|
+
technologyName: string;
|
|
4493
|
+
appointmentCount: number;
|
|
4494
|
+
completedCount: number;
|
|
4495
|
+
rank: number;
|
|
4496
|
+
}
|
|
4497
|
+
/**
|
|
4498
|
+
* Procedure Profitability
|
|
4499
|
+
* Profitability metrics for procedures
|
|
4500
|
+
*/
|
|
4501
|
+
interface ProcedureProfitability {
|
|
4502
|
+
procedureId: string;
|
|
4503
|
+
procedureName: string;
|
|
4504
|
+
categoryName: string;
|
|
4505
|
+
subcategoryName: string;
|
|
4506
|
+
technologyName: string;
|
|
4507
|
+
totalRevenue: number;
|
|
4508
|
+
averageRevenue: number;
|
|
4509
|
+
appointmentCount: number;
|
|
4510
|
+
rank: number;
|
|
4511
|
+
}
|
|
4512
|
+
/**
|
|
4513
|
+
* Cancellation Reason Statistics
|
|
4514
|
+
* Breakdown of cancellation reasons
|
|
4515
|
+
*/
|
|
4516
|
+
interface CancellationReasonStats {
|
|
4517
|
+
reason: string;
|
|
4518
|
+
count: number;
|
|
4519
|
+
percentage: number;
|
|
4520
|
+
averageLeadTime: number;
|
|
4521
|
+
}
|
|
4522
|
+
/**
|
|
4523
|
+
* Dashboard Analytics
|
|
4524
|
+
* Comprehensive dashboard data aggregation
|
|
4525
|
+
*/
|
|
4526
|
+
interface DashboardAnalytics {
|
|
4527
|
+
overview: {
|
|
4528
|
+
totalAppointments: number;
|
|
4529
|
+
completedAppointments: number;
|
|
4530
|
+
canceledAppointments: number;
|
|
4531
|
+
noShowAppointments: number;
|
|
4532
|
+
pendingAppointments: number;
|
|
4533
|
+
confirmedAppointments: number;
|
|
4534
|
+
totalRevenue: number;
|
|
4535
|
+
averageRevenuePerAppointment: number;
|
|
4536
|
+
currency: string;
|
|
4537
|
+
uniquePatients: number;
|
|
4538
|
+
uniquePractitioners: number;
|
|
4539
|
+
uniqueProcedures: number;
|
|
4540
|
+
cancellationRate: number;
|
|
4541
|
+
noShowRate: number;
|
|
4542
|
+
};
|
|
4543
|
+
practitionerMetrics: PractitionerAnalytics[];
|
|
4544
|
+
procedureMetrics: ProcedureAnalytics[];
|
|
4545
|
+
cancellationMetrics: CancellationMetrics;
|
|
4546
|
+
noShowMetrics: NoShowMetrics;
|
|
4547
|
+
revenueTrends: RevenueTrend[];
|
|
4548
|
+
timeEfficiency: TimeEfficiencyMetrics;
|
|
4549
|
+
topProducts: ProductUsageMetrics[];
|
|
4550
|
+
recentActivity: Array<{
|
|
4551
|
+
type: 'appointment' | 'cancellation' | 'completion' | 'no_show';
|
|
4552
|
+
date: Date;
|
|
4553
|
+
description: string;
|
|
4554
|
+
entityId?: string;
|
|
4555
|
+
entityName?: string;
|
|
4556
|
+
}>;
|
|
4557
|
+
}
|
|
4558
|
+
|
|
4559
|
+
/**
|
|
4560
|
+
* Period type for analytics snapshots
|
|
4561
|
+
*/
|
|
4562
|
+
type AnalyticsPeriod = 'daily' | 'weekly' | 'monthly' | 'yearly' | 'all_time';
|
|
4563
|
+
/**
|
|
4564
|
+
* Analytics document metadata
|
|
4565
|
+
*/
|
|
4566
|
+
interface AnalyticsMetadata {
|
|
4567
|
+
clinicBranchId: string;
|
|
4568
|
+
period: AnalyticsPeriod;
|
|
4569
|
+
periodStart: Date;
|
|
4570
|
+
periodEnd: Date;
|
|
4571
|
+
computedAt: Timestamp;
|
|
4572
|
+
computedBy: 'cloud_function' | 'manual';
|
|
4573
|
+
version: string;
|
|
4574
|
+
}
|
|
4575
|
+
/**
|
|
4576
|
+
* Stored Practitioner Analytics
|
|
4577
|
+
* Stored in: clinics/{clinicBranchId}/analytics/practitioners/{practitionerId}/{period}
|
|
4578
|
+
*/
|
|
4579
|
+
interface StoredPractitionerAnalytics extends PractitionerAnalytics {
|
|
4580
|
+
metadata: AnalyticsMetadata;
|
|
4581
|
+
}
|
|
4582
|
+
/**
|
|
4583
|
+
* Stored Procedure Analytics
|
|
4584
|
+
* Stored in: clinics/{clinicBranchId}/analytics/procedures/{procedureId}/{period}
|
|
4585
|
+
*/
|
|
4586
|
+
interface StoredProcedureAnalytics extends ProcedureAnalytics {
|
|
4587
|
+
metadata: AnalyticsMetadata;
|
|
4588
|
+
}
|
|
4589
|
+
/**
|
|
4590
|
+
* Stored Clinic Analytics
|
|
4591
|
+
* Stored in: clinics/{clinicBranchId}/analytics/clinic/{period}
|
|
4592
|
+
*/
|
|
4593
|
+
interface StoredClinicAnalytics extends ClinicAnalytics {
|
|
4594
|
+
metadata: AnalyticsMetadata;
|
|
4595
|
+
}
|
|
4596
|
+
/**
|
|
4597
|
+
* Stored Dashboard Analytics
|
|
4598
|
+
* Stored in: clinics/{clinicBranchId}/analytics/dashboard/{period}
|
|
4599
|
+
*/
|
|
4600
|
+
interface StoredDashboardAnalytics extends DashboardAnalytics {
|
|
4601
|
+
metadata: AnalyticsMetadata;
|
|
4602
|
+
}
|
|
4603
|
+
/**
|
|
4604
|
+
* Stored Time Efficiency Metrics
|
|
4605
|
+
* Stored in: clinics/{clinicBranchId}/analytics/time_efficiency/{period}
|
|
4606
|
+
*/
|
|
4607
|
+
interface StoredTimeEfficiencyMetrics extends TimeEfficiencyMetrics {
|
|
4608
|
+
metadata: AnalyticsMetadata;
|
|
4609
|
+
}
|
|
4610
|
+
/**
|
|
4611
|
+
* Stored Cancellation Metrics
|
|
4612
|
+
* Stored in: clinics/{clinicBranchId}/analytics/cancellations/{entityType}/{period}
|
|
4613
|
+
*/
|
|
4614
|
+
interface StoredCancellationMetrics extends CancellationMetrics {
|
|
4615
|
+
metadata: AnalyticsMetadata;
|
|
4616
|
+
}
|
|
4617
|
+
/**
|
|
4618
|
+
* Stored No-Show Metrics
|
|
4619
|
+
* Stored in: clinics/{clinicBranchId}/analytics/no_shows/{entityType}/{period}
|
|
4620
|
+
*/
|
|
4621
|
+
interface StoredNoShowMetrics extends NoShowMetrics {
|
|
4622
|
+
metadata: AnalyticsMetadata;
|
|
4623
|
+
}
|
|
4624
|
+
/**
|
|
4625
|
+
* Stored Revenue Metrics
|
|
4626
|
+
* Stored in: clinics/{clinicBranchId}/analytics/revenue/{period}
|
|
4627
|
+
*/
|
|
4628
|
+
interface StoredRevenueMetrics extends RevenueMetrics {
|
|
4629
|
+
metadata: AnalyticsMetadata;
|
|
4630
|
+
}
|
|
4631
|
+
/**
|
|
4632
|
+
* Collection names for stored analytics
|
|
4633
|
+
*/
|
|
4634
|
+
declare const ANALYTICS_COLLECTION = "analytics";
|
|
4635
|
+
declare const PRACTITIONER_ANALYTICS_SUBCOLLECTION = "practitioners";
|
|
4636
|
+
declare const PROCEDURE_ANALYTICS_SUBCOLLECTION = "procedures";
|
|
4637
|
+
declare const CLINIC_ANALYTICS_SUBCOLLECTION = "clinic";
|
|
4638
|
+
declare const DASHBOARD_ANALYTICS_SUBCOLLECTION = "dashboard";
|
|
4639
|
+
declare const TIME_EFFICIENCY_ANALYTICS_SUBCOLLECTION = "time_efficiency";
|
|
4640
|
+
declare const CANCELLATION_ANALYTICS_SUBCOLLECTION = "cancellations";
|
|
4641
|
+
declare const NO_SHOW_ANALYTICS_SUBCOLLECTION = "no_shows";
|
|
4642
|
+
declare const REVENUE_ANALYTICS_SUBCOLLECTION = "revenue";
|
|
4643
|
+
/**
|
|
4644
|
+
* Options for reading stored analytics
|
|
4645
|
+
*/
|
|
4646
|
+
interface ReadStoredAnalyticsOptions {
|
|
4647
|
+
/**
|
|
4648
|
+
* Whether to use cached/pre-computed data
|
|
4649
|
+
* @default true
|
|
4650
|
+
*/
|
|
4651
|
+
useCache?: boolean;
|
|
4652
|
+
/**
|
|
4653
|
+
* Maximum age of cached data in hours before recalculating
|
|
4654
|
+
* @default 12
|
|
4655
|
+
*/
|
|
4656
|
+
maxCacheAgeHours?: number;
|
|
4657
|
+
/**
|
|
4658
|
+
* Period to read
|
|
4659
|
+
* @default 'all_time'
|
|
4660
|
+
*/
|
|
4661
|
+
period?: AnalyticsPeriod;
|
|
4662
|
+
/**
|
|
4663
|
+
* Date range for the period (calculated if not provided)
|
|
4664
|
+
*/
|
|
4665
|
+
dateRange?: AnalyticsDateRange;
|
|
4666
|
+
/**
|
|
4667
|
+
* Clinic branch ID (required for reading stored analytics)
|
|
4668
|
+
*/
|
|
4669
|
+
clinicBranchId?: string;
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4672
|
+
/**
|
|
4673
|
+
* Base interface for grouped analytics results
|
|
4674
|
+
* All grouped analytics share common entity identification
|
|
4675
|
+
*/
|
|
4676
|
+
interface GroupedAnalyticsBase {
|
|
4677
|
+
entityId: string;
|
|
4678
|
+
entityName: string;
|
|
4679
|
+
entityType: EntityType;
|
|
4680
|
+
}
|
|
4681
|
+
/**
|
|
4682
|
+
* Review metrics for grouped analytics
|
|
4683
|
+
* Note: This is a simplified version for grouped analytics.
|
|
4684
|
+
* For full review analytics, see ReviewAnalyticsService.ReviewMetrics
|
|
4685
|
+
*/
|
|
4686
|
+
interface ReviewMetrics {
|
|
4687
|
+
totalReviews: number;
|
|
4688
|
+
averageRating: number;
|
|
4689
|
+
recommendationRate: number;
|
|
4690
|
+
ratingDifference?: number;
|
|
4691
|
+
recommendationDifference?: number;
|
|
4692
|
+
}
|
|
4693
|
+
/**
|
|
4694
|
+
* Grouped Revenue Metrics
|
|
4695
|
+
* Revenue analytics grouped by clinic, practitioner, procedure, or patient
|
|
4696
|
+
*/
|
|
4697
|
+
interface GroupedRevenueMetrics extends GroupedAnalyticsBase {
|
|
4698
|
+
totalRevenue: number;
|
|
4699
|
+
averageRevenuePerAppointment: number;
|
|
4700
|
+
totalAppointments: number;
|
|
4701
|
+
completedAppointments: number;
|
|
4702
|
+
currency: string;
|
|
4703
|
+
unpaidRevenue: number;
|
|
4704
|
+
refundedRevenue: number;
|
|
4705
|
+
totalTax: number;
|
|
4706
|
+
totalSubtotal: number;
|
|
4707
|
+
practitionerId?: string;
|
|
4708
|
+
practitionerName?: string;
|
|
4709
|
+
reviewMetrics?: ReviewMetrics;
|
|
4710
|
+
}
|
|
4711
|
+
/**
|
|
4712
|
+
* Grouped Product Usage Metrics
|
|
4713
|
+
* Product usage analytics grouped by clinic, practitioner, procedure, or patient
|
|
4714
|
+
*/
|
|
4715
|
+
interface GroupedProductUsageMetrics extends GroupedAnalyticsBase {
|
|
4716
|
+
totalProductsUsed: number;
|
|
4717
|
+
uniqueProducts: number;
|
|
4718
|
+
totalProductRevenue: number;
|
|
4719
|
+
totalProductQuantity: number;
|
|
4720
|
+
averageProductsPerAppointment: number;
|
|
4721
|
+
topProducts: Array<{
|
|
4722
|
+
productId: string;
|
|
4723
|
+
productName: string;
|
|
4724
|
+
brandName: string;
|
|
4725
|
+
totalQuantity: number;
|
|
4726
|
+
totalRevenue: number;
|
|
4727
|
+
usageCount: number;
|
|
4728
|
+
}>;
|
|
4729
|
+
practitionerId?: string;
|
|
4730
|
+
practitionerName?: string;
|
|
4731
|
+
}
|
|
4732
|
+
/**
|
|
4733
|
+
* Grouped Patient Retention Metrics
|
|
4734
|
+
* Patient retention analytics grouped by clinic, practitioner, or procedure
|
|
4735
|
+
*/
|
|
4736
|
+
interface GroupedPatientRetentionMetrics extends GroupedAnalyticsBase {
|
|
4737
|
+
totalPatients: number;
|
|
4738
|
+
newPatients: number;
|
|
4739
|
+
returningPatients: number;
|
|
4740
|
+
retentionRate: number;
|
|
4741
|
+
averageAppointmentsPerPatient: number;
|
|
4742
|
+
patientsByAppointmentCount: Array<{
|
|
4743
|
+
appointmentCount: number;
|
|
4744
|
+
patientCount: number;
|
|
4745
|
+
percentage: number;
|
|
4746
|
+
}>;
|
|
4747
|
+
}
|
|
4748
|
+
/**
|
|
4749
|
+
* Grouped Time Efficiency Metrics
|
|
4750
|
+
* Time efficiency analytics grouped by clinic, practitioner, procedure, or patient
|
|
4751
|
+
*/
|
|
4752
|
+
interface GroupedTimeEfficiencyMetrics extends GroupedAnalyticsBase {
|
|
4753
|
+
totalAppointments: number;
|
|
4754
|
+
appointmentsWithActualTime: number;
|
|
4755
|
+
averageBookedDuration: number;
|
|
4756
|
+
averageActualDuration: number;
|
|
4757
|
+
averageEfficiency: number;
|
|
4758
|
+
totalOverrun: number;
|
|
4759
|
+
totalUnderutilization: number;
|
|
4760
|
+
averageOverrun: number;
|
|
4761
|
+
averageUnderutilization: number;
|
|
4762
|
+
practitionerId?: string;
|
|
4763
|
+
practitionerName?: string;
|
|
4764
|
+
}
|
|
4765
|
+
/**
|
|
4766
|
+
* Grouped Patient Behavior Metrics
|
|
4767
|
+
* Patient behavior (no-show, cancellation) grouped by clinic, practitioner, or procedure
|
|
4768
|
+
*/
|
|
4769
|
+
interface GroupedPatientBehaviorMetrics extends GroupedAnalyticsBase {
|
|
4770
|
+
totalPatients: number;
|
|
4771
|
+
patientsWithNoShows: number;
|
|
4772
|
+
patientsWithCancellations: number;
|
|
4773
|
+
averageNoShowRate: number;
|
|
4774
|
+
averageCancellationRate: number;
|
|
4775
|
+
topNoShowPatients: Array<{
|
|
4776
|
+
patientId: string;
|
|
4777
|
+
patientName: string;
|
|
4778
|
+
noShowCount: number;
|
|
4779
|
+
totalAppointments: number;
|
|
4780
|
+
noShowRate: number;
|
|
4781
|
+
}>;
|
|
4782
|
+
topCancellationPatients: Array<{
|
|
4783
|
+
patientId: string;
|
|
4784
|
+
patientName: string;
|
|
4785
|
+
cancellationCount: number;
|
|
4786
|
+
totalAppointments: number;
|
|
4787
|
+
cancellationRate: number;
|
|
4788
|
+
}>;
|
|
4789
|
+
}
|
|
4790
|
+
/**
|
|
4791
|
+
* Grouped Procedure Performance Metrics
|
|
4792
|
+
* Procedure performance grouped by clinic or practitioner
|
|
4793
|
+
*/
|
|
4794
|
+
interface GroupedProcedurePerformanceMetrics extends GroupedAnalyticsBase {
|
|
4795
|
+
totalProcedures: number;
|
|
4796
|
+
totalAppointments: number;
|
|
4797
|
+
completedAppointments: number;
|
|
4798
|
+
totalRevenue: number;
|
|
4799
|
+
averageRevenuePerProcedure: number;
|
|
4800
|
+
topProcedures: Array<{
|
|
4801
|
+
procedureId: string;
|
|
4802
|
+
procedureName: string;
|
|
4803
|
+
appointmentCount: number;
|
|
4804
|
+
revenue: number;
|
|
4805
|
+
cancellationRate: number;
|
|
4806
|
+
noShowRate: number;
|
|
4807
|
+
}>;
|
|
4808
|
+
}
|
|
4809
|
+
/**
|
|
4810
|
+
* Grouped Practitioner Performance Metrics
|
|
4811
|
+
* Practitioner performance grouped by clinic
|
|
4812
|
+
*/
|
|
4813
|
+
interface GroupedPractitionerPerformanceMetrics extends GroupedAnalyticsBase {
|
|
4814
|
+
totalPractitioners: number;
|
|
4815
|
+
totalAppointments: number;
|
|
4816
|
+
completedAppointments: number;
|
|
4817
|
+
totalRevenue: number;
|
|
4818
|
+
averageRevenuePerPractitioner: number;
|
|
4819
|
+
topPractitioners: Array<{
|
|
4820
|
+
practitionerId: string;
|
|
4821
|
+
practitionerName: string;
|
|
4822
|
+
appointmentCount: number;
|
|
4823
|
+
revenue: number;
|
|
4824
|
+
cancellationRate: number;
|
|
4825
|
+
noShowRate: number;
|
|
4826
|
+
timeEfficiency: number;
|
|
4827
|
+
}>;
|
|
4828
|
+
}
|
|
4829
|
+
|
|
3999
4830
|
/**
|
|
4000
4831
|
* Procedure represents a specific medical procedure that can be performed by a practitioner in a clinic
|
|
4001
4832
|
* It inherits properties from technology and adds clinic/practitioner specific details
|
|
@@ -6810,6 +7641,523 @@ declare class AppointmentService extends BaseService {
|
|
|
6810
7641
|
}): Promise<NextStepsRecommendation[]>;
|
|
6811
7642
|
}
|
|
6812
7643
|
|
|
7644
|
+
/**
|
|
7645
|
+
* Review metrics for a specific entity (practitioner, procedure, etc.)
|
|
7646
|
+
* Full review analytics metrics with detailed breakdowns
|
|
7647
|
+
*/
|
|
7648
|
+
interface ReviewAnalyticsMetrics {
|
|
7649
|
+
entityId: string;
|
|
7650
|
+
entityName: string;
|
|
7651
|
+
entityType: 'practitioner' | 'procedure' | 'category' | 'subcategory' | 'technology';
|
|
7652
|
+
totalReviews: number;
|
|
7653
|
+
averageRating: number;
|
|
7654
|
+
recommendationRate: number;
|
|
7655
|
+
practitionerMetrics?: {
|
|
7656
|
+
averageKnowledgeAndExpertise: number;
|
|
7657
|
+
averageCommunicationSkills: number;
|
|
7658
|
+
averageBedSideManner: number;
|
|
7659
|
+
averageThoroughness: number;
|
|
7660
|
+
averageTrustworthiness: number;
|
|
7661
|
+
};
|
|
7662
|
+
procedureMetrics?: {
|
|
7663
|
+
averageEffectiveness: number;
|
|
7664
|
+
averageOutcomeExplanation: number;
|
|
7665
|
+
averagePainManagement: number;
|
|
7666
|
+
averageFollowUpCare: number;
|
|
7667
|
+
averageValueForMoney: number;
|
|
7668
|
+
};
|
|
7669
|
+
comparisonToOverall: {
|
|
7670
|
+
ratingDifference: number;
|
|
7671
|
+
recommendationDifference: number;
|
|
7672
|
+
};
|
|
7673
|
+
}
|
|
7674
|
+
/**
|
|
7675
|
+
* Review detail with full information
|
|
7676
|
+
*/
|
|
7677
|
+
interface ReviewDetail {
|
|
7678
|
+
reviewId: string;
|
|
7679
|
+
appointmentId: string;
|
|
7680
|
+
patientId: string;
|
|
7681
|
+
patientName?: string;
|
|
7682
|
+
createdAt: Date;
|
|
7683
|
+
practitionerReview?: PractitionerReview;
|
|
7684
|
+
procedureReview?: ProcedureReview;
|
|
7685
|
+
procedureName?: string;
|
|
7686
|
+
practitionerName?: string;
|
|
7687
|
+
appointmentDate: Date;
|
|
7688
|
+
}
|
|
7689
|
+
/**
|
|
7690
|
+
* Overall review averages for comparison
|
|
7691
|
+
*/
|
|
7692
|
+
interface OverallReviewAverages {
|
|
7693
|
+
practitionerAverage: {
|
|
7694
|
+
totalReviews: number;
|
|
7695
|
+
averageRating: number;
|
|
7696
|
+
recommendationRate: number;
|
|
7697
|
+
averageKnowledgeAndExpertise: number;
|
|
7698
|
+
averageCommunicationSkills: number;
|
|
7699
|
+
averageBedSideManner: number;
|
|
7700
|
+
averageThoroughness: number;
|
|
7701
|
+
averageTrustworthiness: number;
|
|
7702
|
+
};
|
|
7703
|
+
procedureAverage: {
|
|
7704
|
+
totalReviews: number;
|
|
7705
|
+
averageRating: number;
|
|
7706
|
+
recommendationRate: number;
|
|
7707
|
+
averageEffectiveness: number;
|
|
7708
|
+
averageOutcomeExplanation: number;
|
|
7709
|
+
averagePainManagement: number;
|
|
7710
|
+
averageFollowUpCare: number;
|
|
7711
|
+
averageValueForMoney: number;
|
|
7712
|
+
};
|
|
7713
|
+
}
|
|
7714
|
+
/**
|
|
7715
|
+
* Review Analytics Service
|
|
7716
|
+
* Provides review metrics and analytics for practitioners, procedures, categories, and technologies
|
|
7717
|
+
*/
|
|
7718
|
+
declare class ReviewAnalyticsService extends BaseService {
|
|
7719
|
+
private appointmentService;
|
|
7720
|
+
constructor(db: Firestore, auth: any, app: any, appointmentService?: AppointmentService);
|
|
7721
|
+
/**
|
|
7722
|
+
* Fetches reviews filtered by date range and optional filters
|
|
7723
|
+
* Properly filters by clinic branch by checking appointment's clinicId
|
|
7724
|
+
*/
|
|
7725
|
+
private fetchReviews;
|
|
7726
|
+
/**
|
|
7727
|
+
* Gets review metrics for a specific entity
|
|
7728
|
+
*/
|
|
7729
|
+
getReviewMetricsByEntity(entityType: 'practitioner' | 'procedure' | 'category' | 'subcategory' | 'technology', entityId: string, dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<ReviewAnalyticsMetrics | null>;
|
|
7730
|
+
/**
|
|
7731
|
+
* Gets review metrics for multiple entities (grouped)
|
|
7732
|
+
*/
|
|
7733
|
+
getReviewMetricsByEntities(entityType: 'practitioner' | 'procedure' | 'category' | 'subcategory' | 'technology', dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<ReviewAnalyticsMetrics[]>;
|
|
7734
|
+
/**
|
|
7735
|
+
* Calculates review metrics from a list of reviews
|
|
7736
|
+
*/
|
|
7737
|
+
private calculateReviewMetrics;
|
|
7738
|
+
/**
|
|
7739
|
+
* Gets overall review averages for comparison
|
|
7740
|
+
*/
|
|
7741
|
+
getOverallReviewAverages(dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<OverallReviewAverages>;
|
|
7742
|
+
/**
|
|
7743
|
+
* Gets review details for a specific entity
|
|
7744
|
+
*/
|
|
7745
|
+
getReviewDetails(entityType: 'practitioner' | 'procedure', entityId: string, dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<ReviewDetail[]>;
|
|
7746
|
+
/**
|
|
7747
|
+
* Helper method to calculate average
|
|
7748
|
+
*/
|
|
7749
|
+
private calculateAverage;
|
|
7750
|
+
/**
|
|
7751
|
+
* Calculate review trends over time
|
|
7752
|
+
* Groups reviews by period and calculates rating and recommendation metrics
|
|
7753
|
+
*
|
|
7754
|
+
* @param dateRange - Date range for trend analysis (must align with period boundaries)
|
|
7755
|
+
* @param period - Period type (week, month, quarter, year)
|
|
7756
|
+
* @param filters - Optional filters for clinic, practitioner, procedure
|
|
7757
|
+
* @param entityType - Optional entity type to group trends by (practitioner, procedure, technology)
|
|
7758
|
+
* @returns Array of review trends with percentage changes
|
|
7759
|
+
*/
|
|
7760
|
+
getReviewTrends(dateRange: AnalyticsDateRange, period: TrendPeriod, filters?: AnalyticsFilters, entityType?: 'practitioner' | 'procedure' | 'technology'): Promise<ReviewTrend[]>;
|
|
7761
|
+
/**
|
|
7762
|
+
* Calculate grouped review trends (by practitioner, procedure, or technology)
|
|
7763
|
+
* Returns the AVERAGE across all entities of that type for each period
|
|
7764
|
+
* @private
|
|
7765
|
+
*/
|
|
7766
|
+
private getGroupedReviewTrends;
|
|
7767
|
+
}
|
|
7768
|
+
|
|
7769
|
+
/**
|
|
7770
|
+
* AnalyticsService provides comprehensive financial and analytical intelligence
|
|
7771
|
+
* for the Clinic Admin app, including metrics about doctors, procedures,
|
|
7772
|
+
* appointments, patients, products, and clinic operations.
|
|
7773
|
+
*/
|
|
7774
|
+
declare class AnalyticsService extends BaseService {
|
|
7775
|
+
private appointmentService;
|
|
7776
|
+
private reviewAnalyticsService;
|
|
7777
|
+
/**
|
|
7778
|
+
* Creates a new AnalyticsService instance.
|
|
7779
|
+
*
|
|
7780
|
+
* @param db Firestore instance
|
|
7781
|
+
* @param auth Firebase Auth instance
|
|
7782
|
+
* @param app Firebase App instance
|
|
7783
|
+
* @param appointmentService Appointment service instance for querying appointments
|
|
7784
|
+
*/
|
|
7785
|
+
constructor(db: Firestore, auth: Auth, app: FirebaseApp, appointmentService: AppointmentService);
|
|
7786
|
+
/**
|
|
7787
|
+
* Fetches appointments with optional filters
|
|
7788
|
+
*
|
|
7789
|
+
* @param filters - Optional filters
|
|
7790
|
+
* @param dateRange - Optional date range
|
|
7791
|
+
* @returns Array of appointments
|
|
7792
|
+
*/
|
|
7793
|
+
private fetchAppointments;
|
|
7794
|
+
/**
|
|
7795
|
+
* Get practitioner performance metrics
|
|
7796
|
+
* First checks for stored analytics, then calculates if not available or stale
|
|
7797
|
+
*
|
|
7798
|
+
* @param practitionerId - ID of the practitioner
|
|
7799
|
+
* @param dateRange - Optional date range filter
|
|
7800
|
+
* @param options - Options for reading stored analytics
|
|
7801
|
+
* @returns Practitioner analytics object
|
|
7802
|
+
*/
|
|
7803
|
+
getPractitionerAnalytics(practitionerId: string, dateRange?: AnalyticsDateRange, options?: ReadStoredAnalyticsOptions): Promise<PractitionerAnalytics>;
|
|
7804
|
+
/**
|
|
7805
|
+
* Get procedure performance metrics
|
|
7806
|
+
* First checks for stored analytics, then calculates if not available or stale
|
|
7807
|
+
*
|
|
7808
|
+
* @param procedureId - ID of the procedure (optional, if not provided returns all)
|
|
7809
|
+
* @param dateRange - Optional date range filter
|
|
7810
|
+
* @param options - Options for reading stored analytics
|
|
7811
|
+
* @returns Procedure analytics object or array
|
|
7812
|
+
*/
|
|
7813
|
+
getProcedureAnalytics(procedureId?: string, dateRange?: AnalyticsDateRange, options?: ReadStoredAnalyticsOptions): Promise<ProcedureAnalytics | ProcedureAnalytics[]>;
|
|
7814
|
+
/**
|
|
7815
|
+
* Calculate analytics for a specific procedure
|
|
7816
|
+
*
|
|
7817
|
+
* @param appointments - Appointments for the procedure
|
|
7818
|
+
* @param procedureId - Procedure ID
|
|
7819
|
+
* @returns Procedure analytics
|
|
7820
|
+
*/
|
|
7821
|
+
private calculateProcedureAnalytics;
|
|
7822
|
+
/**
|
|
7823
|
+
* Get procedure popularity metrics
|
|
7824
|
+
*
|
|
7825
|
+
* @param dateRange - Optional date range filter
|
|
7826
|
+
* @param limit - Number of top procedures to return
|
|
7827
|
+
* @returns Array of procedure popularity metrics
|
|
7828
|
+
*/
|
|
7829
|
+
getProcedurePopularity(dateRange?: AnalyticsDateRange, limit?: number): Promise<ProcedurePopularity[]>;
|
|
7830
|
+
/**
|
|
7831
|
+
* Get procedure profitability metrics
|
|
7832
|
+
*
|
|
7833
|
+
* @param dateRange - Optional date range filter
|
|
7834
|
+
* @param limit - Number of top procedures to return
|
|
7835
|
+
* @returns Array of procedure profitability metrics
|
|
7836
|
+
*/
|
|
7837
|
+
getProcedureProfitability(dateRange?: AnalyticsDateRange, limit?: number): Promise<ProcedureProfitability[]>;
|
|
7838
|
+
/**
|
|
7839
|
+
* Get time efficiency metrics grouped by clinic, practitioner, procedure, patient, or technology
|
|
7840
|
+
*
|
|
7841
|
+
* @param groupBy - Group by 'clinic' | 'practitioner' | 'procedure' | 'patient' | 'technology'
|
|
7842
|
+
* @param dateRange - Optional date range filter
|
|
7843
|
+
* @param filters - Optional additional filters
|
|
7844
|
+
* @returns Grouped time efficiency metrics
|
|
7845
|
+
*/
|
|
7846
|
+
getTimeEfficiencyMetricsByEntity(groupBy: EntityType, dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<GroupedTimeEfficiencyMetrics[]>;
|
|
7847
|
+
/**
|
|
7848
|
+
* Get time efficiency metrics for appointments
|
|
7849
|
+
* First checks for stored analytics, then calculates if not available or stale
|
|
7850
|
+
*
|
|
7851
|
+
* @param filters - Optional filters
|
|
7852
|
+
* @param dateRange - Optional date range filter
|
|
7853
|
+
* @param options - Options for reading stored analytics
|
|
7854
|
+
* @returns Time efficiency metrics
|
|
7855
|
+
*/
|
|
7856
|
+
getTimeEfficiencyMetrics(filters?: AnalyticsFilters, dateRange?: AnalyticsDateRange, options?: ReadStoredAnalyticsOptions): Promise<TimeEfficiencyMetrics>;
|
|
7857
|
+
/**
|
|
7858
|
+
* Get cancellation metrics
|
|
7859
|
+
* First checks for stored analytics when grouping by clinic, then calculates if not available or stale
|
|
7860
|
+
*
|
|
7861
|
+
* @param groupBy - Group by 'clinic' | 'practitioner' | 'patient' | 'procedure' | 'technology'
|
|
7862
|
+
* @param dateRange - Optional date range filter
|
|
7863
|
+
* @param options - Options for reading stored analytics (requires clinicBranchId for cache)
|
|
7864
|
+
* @returns Cancellation metrics grouped by specified entity
|
|
7865
|
+
*/
|
|
7866
|
+
getCancellationMetrics(groupBy: EntityType, dateRange?: AnalyticsDateRange, options?: ReadStoredAnalyticsOptions): Promise<CancellationMetrics | CancellationMetrics[]>;
|
|
7867
|
+
/**
|
|
7868
|
+
* Group cancellations by clinic
|
|
7869
|
+
*/
|
|
7870
|
+
private groupCancellationsByClinic;
|
|
7871
|
+
/**
|
|
7872
|
+
* Group cancellations by practitioner
|
|
7873
|
+
*/
|
|
7874
|
+
private groupCancellationsByPractitioner;
|
|
7875
|
+
/**
|
|
7876
|
+
* Group cancellations by patient
|
|
7877
|
+
*/
|
|
7878
|
+
private groupCancellationsByPatient;
|
|
7879
|
+
/**
|
|
7880
|
+
* Group cancellations by procedure
|
|
7881
|
+
*/
|
|
7882
|
+
private groupCancellationsByProcedure;
|
|
7883
|
+
/**
|
|
7884
|
+
* Group cancellations by technology
|
|
7885
|
+
* Aggregates all procedures using the same technology across all doctors
|
|
7886
|
+
*/
|
|
7887
|
+
private groupCancellationsByTechnology;
|
|
7888
|
+
/**
|
|
7889
|
+
* Calculate cancellation metrics for a specific entity
|
|
7890
|
+
*/
|
|
7891
|
+
private calculateCancellationMetrics;
|
|
7892
|
+
/**
|
|
7893
|
+
* Get no-show metrics
|
|
7894
|
+
* First checks for stored analytics when grouping by clinic, then calculates if not available or stale
|
|
7895
|
+
*
|
|
7896
|
+
* @param groupBy - Group by 'clinic' | 'practitioner' | 'patient' | 'procedure' | 'technology'
|
|
7897
|
+
* @param dateRange - Optional date range filter
|
|
7898
|
+
* @param options - Options for reading stored analytics (requires clinicBranchId for cache)
|
|
7899
|
+
* @returns No-show metrics grouped by specified entity
|
|
7900
|
+
*/
|
|
7901
|
+
getNoShowMetrics(groupBy: EntityType, dateRange?: AnalyticsDateRange, options?: ReadStoredAnalyticsOptions): Promise<NoShowMetrics | NoShowMetrics[]>;
|
|
7902
|
+
/**
|
|
7903
|
+
* Group no-shows by clinic
|
|
7904
|
+
*/
|
|
7905
|
+
private groupNoShowsByClinic;
|
|
7906
|
+
/**
|
|
7907
|
+
* Group no-shows by practitioner
|
|
7908
|
+
*/
|
|
7909
|
+
private groupNoShowsByPractitioner;
|
|
7910
|
+
/**
|
|
7911
|
+
* Group no-shows by patient
|
|
7912
|
+
*/
|
|
7913
|
+
private groupNoShowsByPatient;
|
|
7914
|
+
/**
|
|
7915
|
+
* Group no-shows by procedure
|
|
7916
|
+
*/
|
|
7917
|
+
private groupNoShowsByProcedure;
|
|
7918
|
+
/**
|
|
7919
|
+
* Group no-shows by technology
|
|
7920
|
+
* Aggregates all procedures using the same technology across all doctors
|
|
7921
|
+
*/
|
|
7922
|
+
private groupNoShowsByTechnology;
|
|
7923
|
+
/**
|
|
7924
|
+
* Get revenue metrics grouped by clinic, practitioner, procedure, patient, or technology
|
|
7925
|
+
*
|
|
7926
|
+
* @param groupBy - Group by 'clinic' | 'practitioner' | 'procedure' | 'patient' | 'technology'
|
|
7927
|
+
* @param dateRange - Optional date range filter
|
|
7928
|
+
* @param filters - Optional additional filters
|
|
7929
|
+
* @returns Grouped revenue metrics
|
|
7930
|
+
*/
|
|
7931
|
+
getRevenueMetricsByEntity(groupBy: EntityType, dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<GroupedRevenueMetrics[]>;
|
|
7932
|
+
/**
|
|
7933
|
+
* Get revenue metrics
|
|
7934
|
+
* First checks for stored analytics, then calculates if not available or stale
|
|
7935
|
+
*
|
|
7936
|
+
* IMPORTANT: Financial calculations only consider COMPLETED appointments.
|
|
7937
|
+
* Confirmed, pending, canceled, and no-show appointments are NOT included in revenue calculations.
|
|
7938
|
+
* Only procedures that have been completed generate revenue.
|
|
7939
|
+
*
|
|
7940
|
+
* @param filters - Optional filters
|
|
7941
|
+
* @param dateRange - Optional date range filter
|
|
7942
|
+
* @param options - Options for reading stored analytics
|
|
7943
|
+
* @returns Revenue metrics
|
|
7944
|
+
*/
|
|
7945
|
+
getRevenueMetrics(filters?: AnalyticsFilters, dateRange?: AnalyticsDateRange, options?: ReadStoredAnalyticsOptions): Promise<RevenueMetrics>;
|
|
7946
|
+
/**
|
|
7947
|
+
* Get product usage metrics grouped by clinic, practitioner, procedure, or patient
|
|
7948
|
+
*
|
|
7949
|
+
* @param groupBy - Group by 'clinic' | 'practitioner' | 'procedure' | 'patient'
|
|
7950
|
+
* @param dateRange - Optional date range filter
|
|
7951
|
+
* @param filters - Optional additional filters
|
|
7952
|
+
* @returns Grouped product usage metrics
|
|
7953
|
+
*/
|
|
7954
|
+
getProductUsageMetricsByEntity(groupBy: EntityType, dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<GroupedProductUsageMetrics[]>;
|
|
7955
|
+
/**
|
|
7956
|
+
* Get product usage metrics
|
|
7957
|
+
*
|
|
7958
|
+
* IMPORTANT: Only COMPLETED appointments are included in product usage calculations.
|
|
7959
|
+
* Products are only considered "used" when the procedure has been completed.
|
|
7960
|
+
* Confirmed, pending, canceled, and no-show appointments are excluded from product metrics.
|
|
7961
|
+
*
|
|
7962
|
+
* @param productId - Optional product ID (if not provided, returns all products)
|
|
7963
|
+
* @param dateRange - Optional date range filter
|
|
7964
|
+
* @param filters - Optional filters (e.g., clinicBranchId)
|
|
7965
|
+
* @returns Product usage metrics
|
|
7966
|
+
*/
|
|
7967
|
+
getProductUsageMetrics(productId?: string, dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<ProductUsageMetrics | ProductUsageMetrics[]>;
|
|
7968
|
+
/**
|
|
7969
|
+
* Get patient behavior metrics grouped by clinic, practitioner, procedure, or technology
|
|
7970
|
+
* Shows patient no-show and cancellation patterns per entity
|
|
7971
|
+
*
|
|
7972
|
+
* @param groupBy - Group by 'clinic' | 'practitioner' | 'procedure' | 'technology'
|
|
7973
|
+
* @param dateRange - Optional date range filter
|
|
7974
|
+
* @param filters - Optional additional filters
|
|
7975
|
+
* @returns Grouped patient behavior metrics
|
|
7976
|
+
*/
|
|
7977
|
+
getPatientBehaviorMetricsByEntity(groupBy: 'clinic' | 'practitioner' | 'procedure' | 'technology', dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<GroupedPatientBehaviorMetrics[]>;
|
|
7978
|
+
/**
|
|
7979
|
+
* Get patient analytics
|
|
7980
|
+
*
|
|
7981
|
+
* @param patientId - Optional patient ID (if not provided, returns aggregate)
|
|
7982
|
+
* @param dateRange - Optional date range filter
|
|
7983
|
+
* @returns Patient analytics
|
|
7984
|
+
*/
|
|
7985
|
+
getPatientAnalytics(patientId?: string, dateRange?: AnalyticsDateRange): Promise<PatientAnalytics | PatientAnalytics[]>;
|
|
7986
|
+
/**
|
|
7987
|
+
* Calculate analytics for a specific patient
|
|
7988
|
+
*/
|
|
7989
|
+
private calculatePatientAnalytics;
|
|
7990
|
+
/**
|
|
7991
|
+
* Determines analytics period from date range
|
|
7992
|
+
*/
|
|
7993
|
+
private determinePeriodFromDateRange;
|
|
7994
|
+
/**
|
|
7995
|
+
* Get comprehensive dashboard data
|
|
7996
|
+
* First checks for stored analytics, then calculates if not available or stale
|
|
7997
|
+
*
|
|
7998
|
+
* @param filters - Optional filters
|
|
7999
|
+
* @param dateRange - Optional date range filter
|
|
8000
|
+
* @param options - Options for reading stored analytics
|
|
8001
|
+
* @returns Complete dashboard analytics
|
|
8002
|
+
*/
|
|
8003
|
+
getDashboardData(filters?: AnalyticsFilters, dateRange?: AnalyticsDateRange, options?: ReadStoredAnalyticsOptions): Promise<DashboardAnalytics>;
|
|
8004
|
+
/**
|
|
8005
|
+
* Calculate revenue trends over time
|
|
8006
|
+
* Groups appointments by week/month/quarter/year and calculates revenue metrics
|
|
8007
|
+
*
|
|
8008
|
+
* @param dateRange - Date range for trend analysis (must align with period boundaries)
|
|
8009
|
+
* @param period - Period type (week, month, quarter, year)
|
|
8010
|
+
* @param filters - Optional filters for clinic, practitioner, procedure, patient
|
|
8011
|
+
* @param groupBy - Optional entity type to group trends by (clinic, practitioner, procedure, technology, patient)
|
|
8012
|
+
* @returns Array of revenue trends with percentage changes
|
|
8013
|
+
*/
|
|
8014
|
+
getRevenueTrends(dateRange: AnalyticsDateRange, period: TrendPeriod, filters?: AnalyticsFilters, groupBy?: EntityType): Promise<RevenueTrend[]>;
|
|
8015
|
+
/**
|
|
8016
|
+
* Calculate revenue trends grouped by entity
|
|
8017
|
+
*/
|
|
8018
|
+
private getGroupedRevenueTrends;
|
|
8019
|
+
/**
|
|
8020
|
+
* Calculate duration/efficiency trends over time
|
|
8021
|
+
*
|
|
8022
|
+
* @param dateRange - Date range for trend analysis
|
|
8023
|
+
* @param period - Period type (week, month, quarter, year)
|
|
8024
|
+
* @param filters - Optional filters
|
|
8025
|
+
* @param groupBy - Optional entity type to group trends by
|
|
8026
|
+
* @returns Array of duration trends with percentage changes
|
|
8027
|
+
*/
|
|
8028
|
+
getDurationTrends(dateRange: AnalyticsDateRange, period: TrendPeriod, filters?: AnalyticsFilters, groupBy?: EntityType): Promise<DurationTrend[]>;
|
|
8029
|
+
/**
|
|
8030
|
+
* Calculate appointment count trends over time
|
|
8031
|
+
*
|
|
8032
|
+
* @param dateRange - Date range for trend analysis
|
|
8033
|
+
* @param period - Period type (week, month, quarter, year)
|
|
8034
|
+
* @param filters - Optional filters
|
|
8035
|
+
* @param groupBy - Optional entity type to group trends by
|
|
8036
|
+
* @returns Array of appointment trends with percentage changes
|
|
8037
|
+
*/
|
|
8038
|
+
getAppointmentTrends(dateRange: AnalyticsDateRange, period: TrendPeriod, filters?: AnalyticsFilters, groupBy?: EntityType): Promise<AppointmentTrend[]>;
|
|
8039
|
+
/**
|
|
8040
|
+
* Calculate cancellation and no-show rate trends over time
|
|
8041
|
+
*
|
|
8042
|
+
* @param dateRange - Date range for trend analysis
|
|
8043
|
+
* @param period - Period type (week, month, quarter, year)
|
|
8044
|
+
* @param filters - Optional filters
|
|
8045
|
+
* @param groupBy - Optional entity type to group trends by
|
|
8046
|
+
* @returns Array of cancellation rate trends with percentage changes
|
|
8047
|
+
*/
|
|
8048
|
+
getCancellationRateTrends(dateRange: AnalyticsDateRange, period: TrendPeriod, filters?: AnalyticsFilters, groupBy?: EntityType): Promise<CancellationRateTrend[]>;
|
|
8049
|
+
/**
|
|
8050
|
+
* Get review metrics for a specific entity (practitioner, procedure, etc.)
|
|
8051
|
+
*/
|
|
8052
|
+
getReviewMetricsByEntity(entityType: 'practitioner' | 'procedure' | 'category' | 'subcategory' | 'technology', entityId: string, dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<ReviewAnalyticsMetrics | null>;
|
|
8053
|
+
/**
|
|
8054
|
+
* Get review metrics for multiple entities (grouped)
|
|
8055
|
+
*/
|
|
8056
|
+
getReviewMetricsByEntities(entityType: 'practitioner' | 'procedure' | 'category' | 'subcategory' | 'technology', dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<ReviewAnalyticsMetrics[]>;
|
|
8057
|
+
/**
|
|
8058
|
+
* Get overall review averages for comparison
|
|
8059
|
+
*/
|
|
8060
|
+
getOverallReviewAverages(dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<OverallReviewAverages>;
|
|
8061
|
+
/**
|
|
8062
|
+
* Get review details for a specific entity
|
|
8063
|
+
*/
|
|
8064
|
+
getReviewDetails(entityType: 'practitioner' | 'procedure', entityId: string, dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters): Promise<ReviewDetail[]>;
|
|
8065
|
+
/**
|
|
8066
|
+
* Calculate review trends over time
|
|
8067
|
+
* Groups reviews by period and calculates rating and recommendation metrics
|
|
8068
|
+
*
|
|
8069
|
+
* @param dateRange - Date range for trend analysis
|
|
8070
|
+
* @param period - Period type (week, month, quarter, year)
|
|
8071
|
+
* @param filters - Optional filters for clinic, practitioner, procedure
|
|
8072
|
+
* @param entityType - Optional entity type to group trends by
|
|
8073
|
+
* @returns Array of review trends with percentage changes
|
|
8074
|
+
*/
|
|
8075
|
+
getReviewTrends(dateRange: AnalyticsDateRange, period: TrendPeriod, filters?: AnalyticsFilters, entityType?: 'practitioner' | 'procedure' | 'technology'): Promise<ReviewTrend[]>;
|
|
8076
|
+
}
|
|
8077
|
+
|
|
8078
|
+
/**
|
|
8079
|
+
* Request data for on-demand analytics calculation
|
|
8080
|
+
*/
|
|
8081
|
+
interface CalculateAnalyticsRequest {
|
|
8082
|
+
analyticsType: 'dashboard' | 'practitioner' | 'procedure' | 'clinic' | 'timeEfficiency' | 'revenue' | 'cancellation' | 'noShow' | 'productUsage' | 'patient' | 'revenueByEntity' | 'productUsageByEntity' | 'timeEfficiencyByEntity' | 'patientBehaviorByEntity';
|
|
8083
|
+
filters?: AnalyticsFilters;
|
|
8084
|
+
dateRange?: {
|
|
8085
|
+
start: string;
|
|
8086
|
+
end: string;
|
|
8087
|
+
};
|
|
8088
|
+
entityId?: string;
|
|
8089
|
+
groupBy?: EntityType;
|
|
8090
|
+
options?: {
|
|
8091
|
+
storeInCache?: boolean;
|
|
8092
|
+
useCache?: boolean;
|
|
8093
|
+
maxCacheAgeHours?: number;
|
|
8094
|
+
};
|
|
8095
|
+
}
|
|
8096
|
+
/**
|
|
8097
|
+
* Client-side service for calling analytics Cloud Functions
|
|
8098
|
+
*
|
|
8099
|
+
* This service provides a convenient way to trigger on-demand analytics
|
|
8100
|
+
* calculations via Cloud Functions, which can be faster and more efficient
|
|
8101
|
+
* than calculating on the client.
|
|
8102
|
+
*/
|
|
8103
|
+
declare class AnalyticsCloudService {
|
|
8104
|
+
private functions;
|
|
8105
|
+
/**
|
|
8106
|
+
* Creates a new AnalyticsCloudService instance
|
|
8107
|
+
*
|
|
8108
|
+
* @param app - Firebase App instance
|
|
8109
|
+
* @param region - Functions region (default: 'europe-west6')
|
|
8110
|
+
*/
|
|
8111
|
+
constructor(app: FirebaseApp, region?: string);
|
|
8112
|
+
/**
|
|
8113
|
+
* Calls the Cloud Function to calculate analytics on-demand
|
|
8114
|
+
*
|
|
8115
|
+
* @param request - Analytics calculation request
|
|
8116
|
+
* @returns Promise resolving to the calculated analytics data
|
|
8117
|
+
*/
|
|
8118
|
+
calculateOnDemand(request: CalculateAnalyticsRequest): Promise<any>;
|
|
8119
|
+
/**
|
|
8120
|
+
* Calculate dashboard analytics on-demand
|
|
8121
|
+
*/
|
|
8122
|
+
calculateDashboard(filters: AnalyticsFilters, dateRange: AnalyticsDateRange, options?: {
|
|
8123
|
+
storeInCache?: boolean;
|
|
8124
|
+
}): Promise<any>;
|
|
8125
|
+
/**
|
|
8126
|
+
* Calculate practitioner analytics on-demand
|
|
8127
|
+
*/
|
|
8128
|
+
calculatePractitioner(practitionerId: string, dateRange?: AnalyticsDateRange, options?: {
|
|
8129
|
+
storeInCache?: boolean;
|
|
8130
|
+
clinicBranchId?: string;
|
|
8131
|
+
}): Promise<any>;
|
|
8132
|
+
/**
|
|
8133
|
+
* Calculate procedure analytics on-demand
|
|
8134
|
+
*/
|
|
8135
|
+
calculateProcedure(procedureId: string, dateRange?: AnalyticsDateRange, options?: {
|
|
8136
|
+
storeInCache?: boolean;
|
|
8137
|
+
clinicBranchId?: string;
|
|
8138
|
+
}): Promise<any>;
|
|
8139
|
+
/**
|
|
8140
|
+
* Calculate revenue metrics grouped by entity on-demand
|
|
8141
|
+
*/
|
|
8142
|
+
calculateRevenueByEntity(groupBy: EntityType, dateRange?: AnalyticsDateRange, filters?: AnalyticsFilters, options?: {
|
|
8143
|
+
storeInCache?: boolean;
|
|
8144
|
+
}): Promise<any>;
|
|
8145
|
+
/**
|
|
8146
|
+
* Calculate cancellation metrics grouped by entity on-demand
|
|
8147
|
+
*/
|
|
8148
|
+
calculateCancellations(groupBy: EntityType, dateRange?: AnalyticsDateRange, options?: {
|
|
8149
|
+
storeInCache?: boolean;
|
|
8150
|
+
clinicBranchId?: string;
|
|
8151
|
+
}): Promise<any>;
|
|
8152
|
+
/**
|
|
8153
|
+
* Calculate no-show metrics grouped by entity on-demand
|
|
8154
|
+
*/
|
|
8155
|
+
calculateNoShows(groupBy: EntityType, dateRange?: AnalyticsDateRange, options?: {
|
|
8156
|
+
storeInCache?: boolean;
|
|
8157
|
+
clinicBranchId?: string;
|
|
8158
|
+
}): Promise<any>;
|
|
8159
|
+
}
|
|
8160
|
+
|
|
6813
8161
|
declare class UserService extends BaseService {
|
|
6814
8162
|
private patientService;
|
|
6815
8163
|
private clinicAdminService;
|
|
@@ -7726,4 +9074,4 @@ declare const getFirebaseApp: () => Promise<FirebaseApp>;
|
|
|
7726
9074
|
declare const getFirebaseStorage: () => Promise<FirebaseStorage>;
|
|
7727
9075
|
declare const getFirebaseFunctions: () => Promise<Functions>;
|
|
7728
9076
|
|
|
7729
|
-
export { AESTHETIC_ANALYSIS_COLLECTION, APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type AestheticAnalysisStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentProductMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AssessmentScales, AuthService, type BaseDocumentElement, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, CALENDAR_COLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicBranchSetupData, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFindingDetail, type ClinicalFindings, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DynamicTextElement, DynamicVariable, type EmergencyContact, EnvironmentalAllergySubtype, type ExtendedProcedureInfo, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, type NextStepsRecommendation, type Notification, NotificationService, NotificationStatus, NotificationType, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, type ParagraphElement, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedureProduct, type ProcedureRecommendationNotification, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, ProductService, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type RecommendedProcedure, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, type RequirementSourceProcedure, RequirementType, type Review, type ReviewRequestNotification, ReviewService, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZoneItemData, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
|
|
9077
|
+
export { AESTHETIC_ANALYSIS_COLLECTION, ANALYTICS_COLLECTION, APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type AestheticAnalysisStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, AnalyticsCloudService, type AnalyticsDateRange, type AnalyticsFilters, type AnalyticsMetadata, type AnalyticsPeriod, AnalyticsService, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentProductMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AppointmentTrend, type AssessmentScales, AuthService, type BaseDocumentElement, type BaseMetrics, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, CALENDAR_COLLECTION, CANCELLATION_ANALYTICS_SUBCOLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_ANALYTICS_SUBCOLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type CancellationMetrics, type CancellationRateTrend, type CancellationReasonStats, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicAnalytics, type ClinicBranchSetupData, type ClinicComparisonMetrics, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFindingDetail, type ClinicalFindings, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CostPerPatientMetrics, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DASHBOARD_ANALYTICS_SUBCOLLECTION, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DashboardAnalytics, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DurationTrend, type DynamicTextElement, DynamicVariable, type EmergencyContact, type EntityType, EnvironmentalAllergySubtype, type ExtendedProcedureInfo, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type GroupedAnalyticsBase, type GroupedPatientBehaviorMetrics, type GroupedPatientRetentionMetrics, type GroupedPractitionerPerformanceMetrics, type GroupedProcedurePerformanceMetrics, type GroupedProductUsageMetrics, type GroupedRevenueMetrics, type GroupedTimeEfficiencyMetrics, type GroupingPeriod, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, NO_SHOW_ANALYTICS_SUBCOLLECTION, type NextStepsRecommendation, type NoShowMetrics, type Notification, NotificationService, NotificationStatus, NotificationType, type OverallReviewAverages, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_ANALYTICS_SUBCOLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, PROCEDURE_ANALYTICS_SUBCOLLECTION, type ParagraphElement, type PatientAnalytics, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLifetimeValueMetrics, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientRetentionMetrics, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PaymentStatusBreakdown, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerAnalytics, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureAnalytics, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedurePopularity, type ProcedureProduct, type ProcedureProfitability, type ProcedureRecommendationNotification, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, type ProductRevenueMetrics, ProductService, type ProductUsageByProcedure, type ProductUsageMetrics, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVENUE_ANALYTICS_SUBCOLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type ReadStoredAnalyticsOptions, type RecommendedProcedure, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, type RequirementSourceProcedure, RequirementType, type RevenueMetrics, type RevenueTrend, type Review, type ReviewAnalyticsMetrics, ReviewAnalyticsService, type ReviewDetail, type ReviewMetrics, type ReviewRequestNotification, ReviewService, type ReviewTrend, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StoredCancellationMetrics, type StoredClinicAnalytics, type StoredDashboardAnalytics, type StoredNoShowMetrics, type StoredPractitionerAnalytics, type StoredProcedureAnalytics, type StoredRevenueMetrics, type StoredTimeEfficiencyMetrics, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, TIME_EFFICIENCY_ANALYTICS_SUBCOLLECTION, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeEfficiencyMetrics, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, type TrendPeriod, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZoneItemData, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
|