@blackcode_sa/metaestetics-api 1.7.24 → 1.7.26
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.js +75 -37
- package/dist/admin/index.mjs +75 -37
- package/dist/index.js +11 -11
- package/dist/index.mjs +11 -11
- package/package.json +1 -1
- package/src/admin/aggregation/clinic/clinic.aggregation.service.ts +106 -45
- package/src/validations/appointment.schema.ts +44 -11
package/dist/admin/index.js
CHANGED
|
@@ -987,14 +987,19 @@ var ClinicAggregationService = class {
|
|
|
987
987
|
);
|
|
988
988
|
for (const practitionerId of practitionerIds) {
|
|
989
989
|
const practitionerRef = this.db.collection(PRACTITIONERS_COLLECTION).doc(practitionerId);
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
990
|
+
const practitionerDoc = await practitionerRef.get();
|
|
991
|
+
if (practitionerDoc.exists) {
|
|
992
|
+
const practitionerData = practitionerDoc.data();
|
|
993
|
+
const currentClinicsInfo = (practitionerData == null ? void 0 : practitionerData.clinicsInfo) || [];
|
|
994
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
995
|
+
(clinic) => clinic.id !== clinicId
|
|
996
|
+
);
|
|
997
|
+
const updatedClinicsInfo = [...filteredClinicsInfo, clinicInfo];
|
|
998
|
+
batch.update(practitionerRef, {
|
|
999
|
+
clinicsInfo: updatedClinicsInfo,
|
|
1000
|
+
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
998
1003
|
}
|
|
999
1004
|
try {
|
|
1000
1005
|
await batch.commit();
|
|
@@ -1058,28 +1063,35 @@ var ClinicAggregationService = class {
|
|
|
1058
1063
|
);
|
|
1059
1064
|
return;
|
|
1060
1065
|
}
|
|
1061
|
-
const batch = this.db.batch();
|
|
1062
1066
|
const clinicId = clinicInfo.id;
|
|
1063
1067
|
const groupRef = this.db.collection(CLINIC_GROUPS_COLLECTION).doc(clinicGroupId);
|
|
1064
1068
|
console.log(
|
|
1065
1069
|
`[ClinicAggregationService] Starting update of ClinicInfo (ID: ${clinicId}) in Clinic Group ${clinicGroupId}.`
|
|
1066
1070
|
);
|
|
1067
|
-
batch.update(groupRef, {
|
|
1068
|
-
clinicsInfo: admin3.firestore.FieldValue.arrayRemove({ id: clinicId }),
|
|
1069
|
-
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
1070
|
-
});
|
|
1071
|
-
batch.update(groupRef, {
|
|
1072
|
-
clinicsInfo: admin3.firestore.FieldValue.arrayUnion(clinicInfo),
|
|
1073
|
-
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
1074
|
-
});
|
|
1075
1071
|
try {
|
|
1076
|
-
await
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1072
|
+
const clinicGroupDoc = await groupRef.get();
|
|
1073
|
+
if (clinicGroupDoc.exists) {
|
|
1074
|
+
const clinicGroupData = clinicGroupDoc.data();
|
|
1075
|
+
const currentClinicsInfo = (clinicGroupData == null ? void 0 : clinicGroupData.clinicsInfo) || [];
|
|
1076
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
1077
|
+
(clinic) => clinic.id !== clinicId
|
|
1078
|
+
);
|
|
1079
|
+
const updatedClinicsInfo = [...filteredClinicsInfo, clinicInfo];
|
|
1080
|
+
await groupRef.update({
|
|
1081
|
+
clinicsInfo: updatedClinicsInfo,
|
|
1082
|
+
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
1083
|
+
});
|
|
1084
|
+
console.log(
|
|
1085
|
+
`[ClinicAggregationService] Successfully updated ClinicInfo (ID: ${clinicId}) in Clinic Group ${clinicGroupId}.`
|
|
1086
|
+
);
|
|
1087
|
+
} else {
|
|
1088
|
+
console.warn(
|
|
1089
|
+
`[ClinicAggregationService] Clinic Group ${clinicGroupId} not found. Cannot update clinic info.`
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1080
1092
|
} catch (error) {
|
|
1081
1093
|
console.error(
|
|
1082
|
-
`[ClinicAggregationService] Error
|
|
1094
|
+
`[ClinicAggregationService] Error updating ClinicInfo (ID: ${clinicId}) in Clinic Group ${clinicGroupId}:`,
|
|
1083
1095
|
error
|
|
1084
1096
|
);
|
|
1085
1097
|
throw error;
|
|
@@ -1223,12 +1235,23 @@ var ClinicAggregationService = class {
|
|
|
1223
1235
|
);
|
|
1224
1236
|
for (const practitionerId of practitionerIds) {
|
|
1225
1237
|
const practitionerRef = this.db.collection(PRACTITIONERS_COLLECTION).doc(practitionerId);
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1238
|
+
const practitionerDoc = await practitionerRef.get();
|
|
1239
|
+
if (practitionerDoc.exists) {
|
|
1240
|
+
const practitionerData = practitionerDoc.data();
|
|
1241
|
+
const currentClinicIds = (practitionerData == null ? void 0 : practitionerData.clinics) || [];
|
|
1242
|
+
const currentClinicsInfo = (practitionerData == null ? void 0 : practitionerData.clinicsInfo) || [];
|
|
1243
|
+
const filteredClinicIds = currentClinicIds.filter(
|
|
1244
|
+
(id) => id !== clinicId
|
|
1245
|
+
);
|
|
1246
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
1247
|
+
(clinic) => clinic.id !== clinicId
|
|
1248
|
+
);
|
|
1249
|
+
batch.update(practitionerRef, {
|
|
1250
|
+
clinics: filteredClinicIds,
|
|
1251
|
+
clinicsInfo: filteredClinicsInfo,
|
|
1252
|
+
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1232
1255
|
}
|
|
1233
1256
|
try {
|
|
1234
1257
|
await batch.commit();
|
|
@@ -1295,15 +1318,30 @@ var ClinicAggregationService = class {
|
|
|
1295
1318
|
`[ClinicAggregationService] Removing Clinic (ID: ${clinicId}) from Clinic Group ${clinicGroupId}.`
|
|
1296
1319
|
);
|
|
1297
1320
|
try {
|
|
1298
|
-
await groupRef.
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1321
|
+
const clinicGroupDoc = await groupRef.get();
|
|
1322
|
+
if (clinicGroupDoc.exists) {
|
|
1323
|
+
const clinicGroupData = clinicGroupDoc.data();
|
|
1324
|
+
const currentClinicIds = (clinicGroupData == null ? void 0 : clinicGroupData.clinics) || [];
|
|
1325
|
+
const currentClinicsInfo = (clinicGroupData == null ? void 0 : clinicGroupData.clinicsInfo) || [];
|
|
1326
|
+
const filteredClinicIds = currentClinicIds.filter(
|
|
1327
|
+
(id) => id !== clinicId
|
|
1328
|
+
);
|
|
1329
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
1330
|
+
(clinic) => clinic.id !== clinicId
|
|
1331
|
+
);
|
|
1332
|
+
await groupRef.update({
|
|
1333
|
+
clinics: filteredClinicIds,
|
|
1334
|
+
clinicsInfo: filteredClinicsInfo,
|
|
1335
|
+
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
1336
|
+
});
|
|
1337
|
+
console.log(
|
|
1338
|
+
`[ClinicAggregationService] Successfully removed Clinic (ID: ${clinicId}) from Clinic Group ${clinicGroupId}.`
|
|
1339
|
+
);
|
|
1340
|
+
} else {
|
|
1341
|
+
console.warn(
|
|
1342
|
+
`[ClinicAggregationService] Clinic Group ${clinicGroupId} not found. Cannot remove clinic.`
|
|
1343
|
+
);
|
|
1344
|
+
}
|
|
1307
1345
|
} catch (error) {
|
|
1308
1346
|
console.error(
|
|
1309
1347
|
`[ClinicAggregationService] Error removing Clinic (ID: ${clinicId}) from Clinic Group ${clinicGroupId}:`,
|
package/dist/admin/index.mjs
CHANGED
|
@@ -930,14 +930,19 @@ var ClinicAggregationService = class {
|
|
|
930
930
|
);
|
|
931
931
|
for (const practitionerId of practitionerIds) {
|
|
932
932
|
const practitionerRef = this.db.collection(PRACTITIONERS_COLLECTION).doc(practitionerId);
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
933
|
+
const practitionerDoc = await practitionerRef.get();
|
|
934
|
+
if (practitionerDoc.exists) {
|
|
935
|
+
const practitionerData = practitionerDoc.data();
|
|
936
|
+
const currentClinicsInfo = (practitionerData == null ? void 0 : practitionerData.clinicsInfo) || [];
|
|
937
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
938
|
+
(clinic) => clinic.id !== clinicId
|
|
939
|
+
);
|
|
940
|
+
const updatedClinicsInfo = [...filteredClinicsInfo, clinicInfo];
|
|
941
|
+
batch.update(practitionerRef, {
|
|
942
|
+
clinicsInfo: updatedClinicsInfo,
|
|
943
|
+
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
944
|
+
});
|
|
945
|
+
}
|
|
941
946
|
}
|
|
942
947
|
try {
|
|
943
948
|
await batch.commit();
|
|
@@ -1001,28 +1006,35 @@ var ClinicAggregationService = class {
|
|
|
1001
1006
|
);
|
|
1002
1007
|
return;
|
|
1003
1008
|
}
|
|
1004
|
-
const batch = this.db.batch();
|
|
1005
1009
|
const clinicId = clinicInfo.id;
|
|
1006
1010
|
const groupRef = this.db.collection(CLINIC_GROUPS_COLLECTION).doc(clinicGroupId);
|
|
1007
1011
|
console.log(
|
|
1008
1012
|
`[ClinicAggregationService] Starting update of ClinicInfo (ID: ${clinicId}) in Clinic Group ${clinicGroupId}.`
|
|
1009
1013
|
);
|
|
1010
|
-
batch.update(groupRef, {
|
|
1011
|
-
clinicsInfo: admin3.firestore.FieldValue.arrayRemove({ id: clinicId }),
|
|
1012
|
-
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
1013
|
-
});
|
|
1014
|
-
batch.update(groupRef, {
|
|
1015
|
-
clinicsInfo: admin3.firestore.FieldValue.arrayUnion(clinicInfo),
|
|
1016
|
-
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
1017
|
-
});
|
|
1018
1014
|
try {
|
|
1019
|
-
await
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1015
|
+
const clinicGroupDoc = await groupRef.get();
|
|
1016
|
+
if (clinicGroupDoc.exists) {
|
|
1017
|
+
const clinicGroupData = clinicGroupDoc.data();
|
|
1018
|
+
const currentClinicsInfo = (clinicGroupData == null ? void 0 : clinicGroupData.clinicsInfo) || [];
|
|
1019
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
1020
|
+
(clinic) => clinic.id !== clinicId
|
|
1021
|
+
);
|
|
1022
|
+
const updatedClinicsInfo = [...filteredClinicsInfo, clinicInfo];
|
|
1023
|
+
await groupRef.update({
|
|
1024
|
+
clinicsInfo: updatedClinicsInfo,
|
|
1025
|
+
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
1026
|
+
});
|
|
1027
|
+
console.log(
|
|
1028
|
+
`[ClinicAggregationService] Successfully updated ClinicInfo (ID: ${clinicId}) in Clinic Group ${clinicGroupId}.`
|
|
1029
|
+
);
|
|
1030
|
+
} else {
|
|
1031
|
+
console.warn(
|
|
1032
|
+
`[ClinicAggregationService] Clinic Group ${clinicGroupId} not found. Cannot update clinic info.`
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1023
1035
|
} catch (error) {
|
|
1024
1036
|
console.error(
|
|
1025
|
-
`[ClinicAggregationService] Error
|
|
1037
|
+
`[ClinicAggregationService] Error updating ClinicInfo (ID: ${clinicId}) in Clinic Group ${clinicGroupId}:`,
|
|
1026
1038
|
error
|
|
1027
1039
|
);
|
|
1028
1040
|
throw error;
|
|
@@ -1166,12 +1178,23 @@ var ClinicAggregationService = class {
|
|
|
1166
1178
|
);
|
|
1167
1179
|
for (const practitionerId of practitionerIds) {
|
|
1168
1180
|
const practitionerRef = this.db.collection(PRACTITIONERS_COLLECTION).doc(practitionerId);
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1181
|
+
const practitionerDoc = await practitionerRef.get();
|
|
1182
|
+
if (practitionerDoc.exists) {
|
|
1183
|
+
const practitionerData = practitionerDoc.data();
|
|
1184
|
+
const currentClinicIds = (practitionerData == null ? void 0 : practitionerData.clinics) || [];
|
|
1185
|
+
const currentClinicsInfo = (practitionerData == null ? void 0 : practitionerData.clinicsInfo) || [];
|
|
1186
|
+
const filteredClinicIds = currentClinicIds.filter(
|
|
1187
|
+
(id) => id !== clinicId
|
|
1188
|
+
);
|
|
1189
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
1190
|
+
(clinic) => clinic.id !== clinicId
|
|
1191
|
+
);
|
|
1192
|
+
batch.update(practitionerRef, {
|
|
1193
|
+
clinics: filteredClinicIds,
|
|
1194
|
+
clinicsInfo: filteredClinicsInfo,
|
|
1195
|
+
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1175
1198
|
}
|
|
1176
1199
|
try {
|
|
1177
1200
|
await batch.commit();
|
|
@@ -1238,15 +1261,30 @@ var ClinicAggregationService = class {
|
|
|
1238
1261
|
`[ClinicAggregationService] Removing Clinic (ID: ${clinicId}) from Clinic Group ${clinicGroupId}.`
|
|
1239
1262
|
);
|
|
1240
1263
|
try {
|
|
1241
|
-
await groupRef.
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1264
|
+
const clinicGroupDoc = await groupRef.get();
|
|
1265
|
+
if (clinicGroupDoc.exists) {
|
|
1266
|
+
const clinicGroupData = clinicGroupDoc.data();
|
|
1267
|
+
const currentClinicIds = (clinicGroupData == null ? void 0 : clinicGroupData.clinics) || [];
|
|
1268
|
+
const currentClinicsInfo = (clinicGroupData == null ? void 0 : clinicGroupData.clinicsInfo) || [];
|
|
1269
|
+
const filteredClinicIds = currentClinicIds.filter(
|
|
1270
|
+
(id) => id !== clinicId
|
|
1271
|
+
);
|
|
1272
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
1273
|
+
(clinic) => clinic.id !== clinicId
|
|
1274
|
+
);
|
|
1275
|
+
await groupRef.update({
|
|
1276
|
+
clinics: filteredClinicIds,
|
|
1277
|
+
clinicsInfo: filteredClinicsInfo,
|
|
1278
|
+
updatedAt: admin3.firestore.FieldValue.serverTimestamp()
|
|
1279
|
+
});
|
|
1280
|
+
console.log(
|
|
1281
|
+
`[ClinicAggregationService] Successfully removed Clinic (ID: ${clinicId}) from Clinic Group ${clinicGroupId}.`
|
|
1282
|
+
);
|
|
1283
|
+
} else {
|
|
1284
|
+
console.warn(
|
|
1285
|
+
`[ClinicAggregationService] Clinic Group ${clinicGroupId} not found. Cannot remove clinic.`
|
|
1286
|
+
);
|
|
1287
|
+
}
|
|
1250
1288
|
} catch (error) {
|
|
1251
1289
|
console.error(
|
|
1252
1290
|
`[ClinicAggregationService] Error removing Clinic (ID: ${clinicId}) from Clinic Group ${clinicGroupId}:`,
|
package/dist/index.js
CHANGED
|
@@ -523,7 +523,7 @@ var appointmentMediaItemSchema = import_zod2.z.object({
|
|
|
523
523
|
url: import_zod2.z.string().url("Media URL must be a valid URL"),
|
|
524
524
|
fileName: import_zod2.z.string().optional(),
|
|
525
525
|
uploadedAt: import_zod2.z.any().refine(
|
|
526
|
-
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
526
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
527
527
|
"uploadedAt must be a valid timestamp or Date object"
|
|
528
528
|
),
|
|
529
529
|
uploadedBy: import_zod2.z.string().min(MIN_STRING_LENGTH, "Uploaded by user ID is required"),
|
|
@@ -557,11 +557,11 @@ var linkedFormInfoSchema = import_zod2.z.object({
|
|
|
557
557
|
status: filledDocumentStatusSchema,
|
|
558
558
|
path: import_zod2.z.string().min(MIN_STRING_LENGTH, "Form path is required"),
|
|
559
559
|
submittedAt: import_zod2.z.any().refine(
|
|
560
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
560
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
561
561
|
"submittedAt must be a valid timestamp or Date object"
|
|
562
562
|
).optional(),
|
|
563
563
|
completedAt: import_zod2.z.any().refine(
|
|
564
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
564
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
565
565
|
"completedAt must be a valid timestamp or Date object"
|
|
566
566
|
).optional()
|
|
567
567
|
});
|
|
@@ -570,14 +570,14 @@ var patientReviewInfoSchema = import_zod2.z.object({
|
|
|
570
570
|
rating: import_zod2.z.number().min(1).max(5, "Rating must be between 1 and 5"),
|
|
571
571
|
comment: import_zod2.z.string().max(MAX_STRING_LENGTH_LONG, "Comment too long").optional(),
|
|
572
572
|
reviewedAt: import_zod2.z.any().refine(
|
|
573
|
-
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
573
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
574
574
|
"reviewedAt must be a valid timestamp or Date object"
|
|
575
575
|
)
|
|
576
576
|
});
|
|
577
577
|
var finalizedDetailsSchema = import_zod2.z.object({
|
|
578
578
|
by: import_zod2.z.string().min(MIN_STRING_LENGTH, "Finalized by user ID is required"),
|
|
579
579
|
at: import_zod2.z.any().refine(
|
|
580
|
-
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
580
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
581
581
|
"Finalized at must be a valid timestamp or Date object"
|
|
582
582
|
),
|
|
583
583
|
notes: import_zod2.z.string().max(MAX_STRING_LENGTH_LONG, "Finalization notes too long").optional()
|
|
@@ -588,11 +588,11 @@ var createAppointmentSchema = import_zod2.z.object({
|
|
|
588
588
|
patientId: import_zod2.z.string().min(MIN_STRING_LENGTH, "Patient ID is required"),
|
|
589
589
|
procedureId: import_zod2.z.string().min(MIN_STRING_LENGTH, "Procedure ID is required"),
|
|
590
590
|
appointmentStartTime: import_zod2.z.any().refine(
|
|
591
|
-
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
591
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
592
592
|
"Appointment start time must be a valid timestamp or Date object"
|
|
593
593
|
),
|
|
594
594
|
appointmentEndTime: import_zod2.z.any().refine(
|
|
595
|
-
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
595
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
596
596
|
"Appointment end time must be a valid timestamp or Date object"
|
|
597
597
|
),
|
|
598
598
|
cost: import_zod2.z.number().min(0, "Cost must be a non-negative number"),
|
|
@@ -622,11 +622,11 @@ var updateAppointmentSchema = import_zod2.z.object({
|
|
|
622
622
|
linkedFormIds: import_zod2.z.union([import_zod2.z.array(import_zod2.z.string()), import_zod2.z.any()]).optional(),
|
|
623
623
|
pendingUserFormsIds: import_zod2.z.union([import_zod2.z.array(import_zod2.z.string()), import_zod2.z.any()]).optional(),
|
|
624
624
|
appointmentStartTime: import_zod2.z.any().refine(
|
|
625
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
625
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
626
626
|
"Appointment start time must be a valid timestamp or Date object"
|
|
627
627
|
).optional(),
|
|
628
628
|
appointmentEndTime: import_zod2.z.any().refine(
|
|
629
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
629
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
630
630
|
"Appointment end time must be a valid timestamp or Date object"
|
|
631
631
|
).optional(),
|
|
632
632
|
calendarEventId: import_zod2.z.string().min(MIN_STRING_LENGTH).optional(),
|
|
@@ -670,11 +670,11 @@ var searchAppointmentsSchema = import_zod2.z.object({
|
|
|
670
670
|
practitionerId: import_zod2.z.string().optional(),
|
|
671
671
|
clinicBranchId: import_zod2.z.string().optional(),
|
|
672
672
|
startDate: import_zod2.z.any().refine(
|
|
673
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
673
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
674
674
|
"Start date must be a valid timestamp or Date object"
|
|
675
675
|
).optional(),
|
|
676
676
|
endDate: import_zod2.z.any().refine(
|
|
677
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
677
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
678
678
|
"End date must be a valid timestamp or Date object"
|
|
679
679
|
).optional(),
|
|
680
680
|
status: import_zod2.z.union([
|
package/dist/index.mjs
CHANGED
|
@@ -281,7 +281,7 @@ var appointmentMediaItemSchema = z2.object({
|
|
|
281
281
|
url: z2.string().url("Media URL must be a valid URL"),
|
|
282
282
|
fileName: z2.string().optional(),
|
|
283
283
|
uploadedAt: z2.any().refine(
|
|
284
|
-
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
284
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
285
285
|
"uploadedAt must be a valid timestamp or Date object"
|
|
286
286
|
),
|
|
287
287
|
uploadedBy: z2.string().min(MIN_STRING_LENGTH, "Uploaded by user ID is required"),
|
|
@@ -315,11 +315,11 @@ var linkedFormInfoSchema = z2.object({
|
|
|
315
315
|
status: filledDocumentStatusSchema,
|
|
316
316
|
path: z2.string().min(MIN_STRING_LENGTH, "Form path is required"),
|
|
317
317
|
submittedAt: z2.any().refine(
|
|
318
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
318
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
319
319
|
"submittedAt must be a valid timestamp or Date object"
|
|
320
320
|
).optional(),
|
|
321
321
|
completedAt: z2.any().refine(
|
|
322
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
322
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
323
323
|
"completedAt must be a valid timestamp or Date object"
|
|
324
324
|
).optional()
|
|
325
325
|
});
|
|
@@ -328,14 +328,14 @@ var patientReviewInfoSchema = z2.object({
|
|
|
328
328
|
rating: z2.number().min(1).max(5, "Rating must be between 1 and 5"),
|
|
329
329
|
comment: z2.string().max(MAX_STRING_LENGTH_LONG, "Comment too long").optional(),
|
|
330
330
|
reviewedAt: z2.any().refine(
|
|
331
|
-
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
331
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
332
332
|
"reviewedAt must be a valid timestamp or Date object"
|
|
333
333
|
)
|
|
334
334
|
});
|
|
335
335
|
var finalizedDetailsSchema = z2.object({
|
|
336
336
|
by: z2.string().min(MIN_STRING_LENGTH, "Finalized by user ID is required"),
|
|
337
337
|
at: z2.any().refine(
|
|
338
|
-
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
338
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
339
339
|
"Finalized at must be a valid timestamp or Date object"
|
|
340
340
|
),
|
|
341
341
|
notes: z2.string().max(MAX_STRING_LENGTH_LONG, "Finalization notes too long").optional()
|
|
@@ -346,11 +346,11 @@ var createAppointmentSchema = z2.object({
|
|
|
346
346
|
patientId: z2.string().min(MIN_STRING_LENGTH, "Patient ID is required"),
|
|
347
347
|
procedureId: z2.string().min(MIN_STRING_LENGTH, "Procedure ID is required"),
|
|
348
348
|
appointmentStartTime: z2.any().refine(
|
|
349
|
-
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
349
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
350
350
|
"Appointment start time must be a valid timestamp or Date object"
|
|
351
351
|
),
|
|
352
352
|
appointmentEndTime: z2.any().refine(
|
|
353
|
-
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
353
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
354
354
|
"Appointment end time must be a valid timestamp or Date object"
|
|
355
355
|
),
|
|
356
356
|
cost: z2.number().min(0, "Cost must be a non-negative number"),
|
|
@@ -380,11 +380,11 @@ var updateAppointmentSchema = z2.object({
|
|
|
380
380
|
linkedFormIds: z2.union([z2.array(z2.string()), z2.any()]).optional(),
|
|
381
381
|
pendingUserFormsIds: z2.union([z2.array(z2.string()), z2.any()]).optional(),
|
|
382
382
|
appointmentStartTime: z2.any().refine(
|
|
383
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
383
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
384
384
|
"Appointment start time must be a valid timestamp or Date object"
|
|
385
385
|
).optional(),
|
|
386
386
|
appointmentEndTime: z2.any().refine(
|
|
387
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
387
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
388
388
|
"Appointment end time must be a valid timestamp or Date object"
|
|
389
389
|
).optional(),
|
|
390
390
|
calendarEventId: z2.string().min(MIN_STRING_LENGTH).optional(),
|
|
@@ -428,11 +428,11 @@ var searchAppointmentsSchema = z2.object({
|
|
|
428
428
|
practitionerId: z2.string().optional(),
|
|
429
429
|
clinicBranchId: z2.string().optional(),
|
|
430
430
|
startDate: z2.any().refine(
|
|
431
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
431
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
432
432
|
"Start date must be a valid timestamp or Date object"
|
|
433
433
|
).optional(),
|
|
434
434
|
endDate: z2.any().refine(
|
|
435
|
-
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || typeof val === "number",
|
|
435
|
+
(val) => val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0 || (val == null ? void 0 : val.seconds) !== void 0 || typeof val === "number" || typeof val === "string" || val && typeof val.toMillis === "function",
|
|
436
436
|
"End date must be a valid timestamp or Date object"
|
|
437
437
|
).optional(),
|
|
438
438
|
status: z2.union([
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as admin from "firebase-admin";
|
|
2
2
|
import { ClinicInfo } from "../../../types/profile"; // Corrected path
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
PRACTITIONERS_COLLECTION,
|
|
5
|
+
Practitioner,
|
|
6
|
+
} from "../../../types/practitioner"; // Corrected path
|
|
4
7
|
import { PROCEDURES_COLLECTION } from "../../../types/procedure"; // Added procedure collection
|
|
5
|
-
import { CLINIC_GROUPS_COLLECTION } from "../../../types/clinic"; // Added clinic group collection
|
|
8
|
+
import { CLINIC_GROUPS_COLLECTION, ClinicGroup } from "../../../types/clinic"; // Added clinic group collection
|
|
6
9
|
import { ClinicLocation } from "../../../types/clinic"; // Added ClinicLocation type
|
|
7
10
|
import { CALENDAR_COLLECTION } from "../../../types/calendar"; // Added calendar collection
|
|
8
11
|
import { PATIENTS_COLLECTION } from "../../../types/patient"; // Added patient collection
|
|
@@ -103,16 +106,27 @@ export class ClinicAggregationService {
|
|
|
103
106
|
.collection(PRACTITIONERS_COLLECTION)
|
|
104
107
|
.doc(practitionerId);
|
|
105
108
|
|
|
106
|
-
// Remove old clinic info based on ID matcher
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
// Remove old clinic info based on ID matcher and add updated info
|
|
110
|
+
// First, get the current practitioner data to filter clinicsInfo manually
|
|
111
|
+
const practitionerDoc = await practitionerRef.get();
|
|
112
|
+
if (practitionerDoc.exists) {
|
|
113
|
+
const practitionerData = practitionerDoc.data() as Practitioner;
|
|
114
|
+
const currentClinicsInfo = practitionerData?.clinicsInfo || [];
|
|
115
|
+
|
|
116
|
+
// Filter out the clinic info with matching ID
|
|
117
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
118
|
+
(clinic: any) => clinic.id !== clinicId
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// Add the updated clinic info to the filtered array
|
|
122
|
+
const updatedClinicsInfo = [...filteredClinicsInfo, clinicInfo];
|
|
123
|
+
|
|
124
|
+
// Update with the complete new array
|
|
125
|
+
batch.update(practitionerRef, {
|
|
126
|
+
clinicsInfo: updatedClinicsInfo,
|
|
127
|
+
updatedAt: admin.firestore.FieldValue.serverTimestamp(),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
116
130
|
}
|
|
117
131
|
|
|
118
132
|
try {
|
|
@@ -194,7 +208,6 @@ export class ClinicAggregationService {
|
|
|
194
208
|
return;
|
|
195
209
|
}
|
|
196
210
|
|
|
197
|
-
const batch = this.db.batch();
|
|
198
211
|
const clinicId = clinicInfo.id;
|
|
199
212
|
const groupRef = this.db
|
|
200
213
|
.collection(CLINIC_GROUPS_COLLECTION)
|
|
@@ -204,25 +217,38 @@ export class ClinicAggregationService {
|
|
|
204
217
|
`[ClinicAggregationService] Starting update of ClinicInfo (ID: ${clinicId}) in Clinic Group ${clinicGroupId}.`
|
|
205
218
|
);
|
|
206
219
|
|
|
207
|
-
// Remove old clinic info based on ID matcher
|
|
208
|
-
batch.update(groupRef, {
|
|
209
|
-
clinicsInfo: admin.firestore.FieldValue.arrayRemove({ id: clinicId }),
|
|
210
|
-
updatedAt: admin.firestore.FieldValue.serverTimestamp(),
|
|
211
|
-
});
|
|
212
|
-
// Add updated clinic info
|
|
213
|
-
batch.update(groupRef, {
|
|
214
|
-
clinicsInfo: admin.firestore.FieldValue.arrayUnion(clinicInfo),
|
|
215
|
-
updatedAt: admin.firestore.FieldValue.serverTimestamp(),
|
|
216
|
-
});
|
|
217
|
-
|
|
218
220
|
try {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
// Get current clinic group data to filter clinicsInfo manually
|
|
222
|
+
const clinicGroupDoc = await groupRef.get();
|
|
223
|
+
if (clinicGroupDoc.exists) {
|
|
224
|
+
const clinicGroupData = clinicGroupDoc.data() as ClinicGroup;
|
|
225
|
+
const currentClinicsInfo = clinicGroupData?.clinicsInfo || [];
|
|
226
|
+
|
|
227
|
+
// Filter out the clinic info with matching ID
|
|
228
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
229
|
+
(clinic: any) => clinic.id !== clinicId
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
// Add the updated clinic info to the filtered array
|
|
233
|
+
const updatedClinicsInfo = [...filteredClinicsInfo, clinicInfo];
|
|
234
|
+
|
|
235
|
+
// Update with the complete new array
|
|
236
|
+
await groupRef.update({
|
|
237
|
+
clinicsInfo: updatedClinicsInfo,
|
|
238
|
+
updatedAt: admin.firestore.FieldValue.serverTimestamp(),
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
console.log(
|
|
242
|
+
`[ClinicAggregationService] Successfully updated ClinicInfo (ID: ${clinicId}) in Clinic Group ${clinicGroupId}.`
|
|
243
|
+
);
|
|
244
|
+
} else {
|
|
245
|
+
console.warn(
|
|
246
|
+
`[ClinicAggregationService] Clinic Group ${clinicGroupId} not found. Cannot update clinic info.`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
223
249
|
} catch (error) {
|
|
224
250
|
console.error(
|
|
225
|
-
`[ClinicAggregationService] Error
|
|
251
|
+
`[ClinicAggregationService] Error updating ClinicInfo (ID: ${clinicId}) in Clinic Group ${clinicGroupId}:`,
|
|
226
252
|
error
|
|
227
253
|
);
|
|
228
254
|
throw error;
|
|
@@ -427,13 +453,28 @@ export class ClinicAggregationService {
|
|
|
427
453
|
.collection(PRACTITIONERS_COLLECTION)
|
|
428
454
|
.doc(practitionerId);
|
|
429
455
|
|
|
430
|
-
//
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
456
|
+
// Get current practitioner data to filter manually
|
|
457
|
+
const practitionerDoc = await practitionerRef.get();
|
|
458
|
+
if (practitionerDoc.exists) {
|
|
459
|
+
const practitionerData = practitionerDoc.data() as Practitioner;
|
|
460
|
+
const currentClinicIds = practitionerData?.clinics || [];
|
|
461
|
+
const currentClinicsInfo = practitionerData?.clinicsInfo || [];
|
|
462
|
+
|
|
463
|
+
// Filter out the clinic ID and clinic info with matching ID
|
|
464
|
+
const filteredClinicIds = currentClinicIds.filter(
|
|
465
|
+
(id: string) => id !== clinicId
|
|
466
|
+
);
|
|
467
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
468
|
+
(clinic: any) => clinic.id !== clinicId
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
// Update with the filtered arrays
|
|
472
|
+
batch.update(practitionerRef, {
|
|
473
|
+
clinics: filteredClinicIds,
|
|
474
|
+
clinicsInfo: filteredClinicsInfo,
|
|
475
|
+
updatedAt: admin.firestore.FieldValue.serverTimestamp(),
|
|
476
|
+
});
|
|
477
|
+
}
|
|
437
478
|
}
|
|
438
479
|
|
|
439
480
|
try {
|
|
@@ -518,16 +559,36 @@ export class ClinicAggregationService {
|
|
|
518
559
|
);
|
|
519
560
|
|
|
520
561
|
try {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
562
|
+
// Get current clinic group data to filter manually
|
|
563
|
+
const clinicGroupDoc = await groupRef.get();
|
|
564
|
+
if (clinicGroupDoc.exists) {
|
|
565
|
+
const clinicGroupData = clinicGroupDoc.data() as ClinicGroup;
|
|
566
|
+
const currentClinicIds = clinicGroupData?.clinics || [];
|
|
567
|
+
const currentClinicsInfo = clinicGroupData?.clinicsInfo || [];
|
|
568
|
+
|
|
569
|
+
// Filter out the clinic ID and clinic info with matching ID
|
|
570
|
+
const filteredClinicIds = currentClinicIds.filter(
|
|
571
|
+
(id: string) => id !== clinicId
|
|
572
|
+
);
|
|
573
|
+
const filteredClinicsInfo = currentClinicsInfo.filter(
|
|
574
|
+
(clinic: any) => clinic.id !== clinicId
|
|
575
|
+
);
|
|
527
576
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
577
|
+
// Update with the filtered arrays
|
|
578
|
+
await groupRef.update({
|
|
579
|
+
clinics: filteredClinicIds,
|
|
580
|
+
clinicsInfo: filteredClinicsInfo,
|
|
581
|
+
updatedAt: admin.firestore.FieldValue.serverTimestamp(),
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
console.log(
|
|
585
|
+
`[ClinicAggregationService] Successfully removed Clinic (ID: ${clinicId}) from Clinic Group ${clinicGroupId}.`
|
|
586
|
+
);
|
|
587
|
+
} else {
|
|
588
|
+
console.warn(
|
|
589
|
+
`[ClinicAggregationService] Clinic Group ${clinicGroupId} not found. Cannot remove clinic.`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
531
592
|
} catch (error) {
|
|
532
593
|
console.error(
|
|
533
594
|
`[ClinicAggregationService] Error removing Clinic (ID: ${clinicId}) from Clinic Group ${clinicGroupId}:`,
|
|
@@ -30,7 +30,10 @@ export const appointmentMediaItemSchema = z.object({
|
|
|
30
30
|
(val) =>
|
|
31
31
|
val instanceof Date ||
|
|
32
32
|
val?._seconds !== undefined ||
|
|
33
|
-
|
|
33
|
+
val?.seconds !== undefined ||
|
|
34
|
+
typeof val === "number" ||
|
|
35
|
+
typeof val === "string" ||
|
|
36
|
+
(val && typeof val.toMillis === "function"),
|
|
34
37
|
"uploadedAt must be a valid timestamp or Date object"
|
|
35
38
|
),
|
|
36
39
|
uploadedBy: z
|
|
@@ -80,7 +83,10 @@ export const linkedFormInfoSchema = z.object({
|
|
|
80
83
|
val === undefined ||
|
|
81
84
|
val instanceof Date ||
|
|
82
85
|
val?._seconds !== undefined ||
|
|
83
|
-
|
|
86
|
+
val?.seconds !== undefined ||
|
|
87
|
+
typeof val === "number" ||
|
|
88
|
+
typeof val === "string" ||
|
|
89
|
+
(val && typeof val.toMillis === "function"),
|
|
84
90
|
"submittedAt must be a valid timestamp or Date object"
|
|
85
91
|
)
|
|
86
92
|
.optional(),
|
|
@@ -91,7 +97,10 @@ export const linkedFormInfoSchema = z.object({
|
|
|
91
97
|
val === undefined ||
|
|
92
98
|
val instanceof Date ||
|
|
93
99
|
val?._seconds !== undefined ||
|
|
94
|
-
|
|
100
|
+
val?.seconds !== undefined ||
|
|
101
|
+
typeof val === "number" ||
|
|
102
|
+
typeof val === "string" ||
|
|
103
|
+
(val && typeof val.toMillis === "function"),
|
|
95
104
|
"completedAt must be a valid timestamp or Date object"
|
|
96
105
|
)
|
|
97
106
|
.optional(),
|
|
@@ -110,7 +119,10 @@ export const patientReviewInfoSchema = z.object({
|
|
|
110
119
|
(val) =>
|
|
111
120
|
val instanceof Date ||
|
|
112
121
|
val?._seconds !== undefined ||
|
|
113
|
-
|
|
122
|
+
val?.seconds !== undefined ||
|
|
123
|
+
typeof val === "number" ||
|
|
124
|
+
typeof val === "string" ||
|
|
125
|
+
(val && typeof val.toMillis === "function"),
|
|
114
126
|
"reviewedAt must be a valid timestamp or Date object"
|
|
115
127
|
),
|
|
116
128
|
});
|
|
@@ -123,7 +135,10 @@ export const finalizedDetailsSchema = z.object({
|
|
|
123
135
|
(val) =>
|
|
124
136
|
val instanceof Date ||
|
|
125
137
|
val?._seconds !== undefined ||
|
|
126
|
-
|
|
138
|
+
val?.seconds !== undefined ||
|
|
139
|
+
typeof val === "number" ||
|
|
140
|
+
typeof val === "string" ||
|
|
141
|
+
(val && typeof val.toMillis === "function"),
|
|
127
142
|
"Finalized at must be a valid timestamp or Date object"
|
|
128
143
|
),
|
|
129
144
|
notes: z
|
|
@@ -153,7 +168,10 @@ export const createAppointmentSchema = z
|
|
|
153
168
|
(val) =>
|
|
154
169
|
val instanceof Date ||
|
|
155
170
|
val?._seconds !== undefined ||
|
|
156
|
-
|
|
171
|
+
val?.seconds !== undefined ||
|
|
172
|
+
typeof val === "number" ||
|
|
173
|
+
typeof val === "string" ||
|
|
174
|
+
(val && typeof val.toMillis === "function"),
|
|
157
175
|
"Appointment start time must be a valid timestamp or Date object"
|
|
158
176
|
),
|
|
159
177
|
appointmentEndTime: z
|
|
@@ -162,7 +180,10 @@ export const createAppointmentSchema = z
|
|
|
162
180
|
(val) =>
|
|
163
181
|
val instanceof Date ||
|
|
164
182
|
val?._seconds !== undefined ||
|
|
165
|
-
|
|
183
|
+
val?.seconds !== undefined ||
|
|
184
|
+
typeof val === "number" ||
|
|
185
|
+
typeof val === "string" ||
|
|
186
|
+
(val && typeof val.toMillis === "function"),
|
|
166
187
|
"Appointment end time must be a valid timestamp or Date object"
|
|
167
188
|
),
|
|
168
189
|
cost: z.number().min(0, "Cost must be a non-negative number"),
|
|
@@ -228,7 +249,10 @@ export const updateAppointmentSchema = z
|
|
|
228
249
|
val === undefined ||
|
|
229
250
|
val instanceof Date ||
|
|
230
251
|
val?._seconds !== undefined ||
|
|
231
|
-
|
|
252
|
+
val?.seconds !== undefined ||
|
|
253
|
+
typeof val === "number" ||
|
|
254
|
+
typeof val === "string" ||
|
|
255
|
+
(val && typeof val.toMillis === "function"),
|
|
232
256
|
"Appointment start time must be a valid timestamp or Date object"
|
|
233
257
|
)
|
|
234
258
|
.optional(),
|
|
@@ -239,7 +263,10 @@ export const updateAppointmentSchema = z
|
|
|
239
263
|
val === undefined ||
|
|
240
264
|
val instanceof Date ||
|
|
241
265
|
val?._seconds !== undefined ||
|
|
242
|
-
|
|
266
|
+
val?.seconds !== undefined ||
|
|
267
|
+
typeof val === "number" ||
|
|
268
|
+
typeof val === "string" ||
|
|
269
|
+
(val && typeof val.toMillis === "function"),
|
|
243
270
|
"Appointment end time must be a valid timestamp or Date object"
|
|
244
271
|
)
|
|
245
272
|
.optional(),
|
|
@@ -311,7 +338,10 @@ export const searchAppointmentsSchema = z
|
|
|
311
338
|
val === undefined ||
|
|
312
339
|
val instanceof Date ||
|
|
313
340
|
val?._seconds !== undefined ||
|
|
314
|
-
|
|
341
|
+
val?.seconds !== undefined ||
|
|
342
|
+
typeof val === "number" ||
|
|
343
|
+
typeof val === "string" ||
|
|
344
|
+
(val && typeof val.toMillis === "function"),
|
|
315
345
|
"Start date must be a valid timestamp or Date object"
|
|
316
346
|
)
|
|
317
347
|
.optional(),
|
|
@@ -322,7 +352,10 @@ export const searchAppointmentsSchema = z
|
|
|
322
352
|
val === undefined ||
|
|
323
353
|
val instanceof Date ||
|
|
324
354
|
val?._seconds !== undefined ||
|
|
325
|
-
|
|
355
|
+
val?.seconds !== undefined ||
|
|
356
|
+
typeof val === "number" ||
|
|
357
|
+
typeof val === "string" ||
|
|
358
|
+
(val && typeof val.toMillis === "function"),
|
|
326
359
|
"End date must be a valid timestamp or Date object"
|
|
327
360
|
)
|
|
328
361
|
.optional(),
|