@blackcode_sa/metaestetics-api 1.14.46 → 1.14.49
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 +1 -0
- package/dist/admin/index.d.ts +1 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +61 -15
- package/dist/index.mjs +233 -187
- package/package.json +1 -1
- package/src/services/appointment/appointment.service.ts +75 -19
- package/src/services/appointment/utils/zone-photo.utils.ts +5 -2
- package/src/types/appointment/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -3393,7 +3393,7 @@ var AnalyticsCloudService = class {
|
|
|
3393
3393
|
|
|
3394
3394
|
// src/services/appointment/appointment.service.ts
|
|
3395
3395
|
import {
|
|
3396
|
-
Timestamp as
|
|
3396
|
+
Timestamp as Timestamp7,
|
|
3397
3397
|
serverTimestamp as serverTimestamp7,
|
|
3398
3398
|
arrayUnion,
|
|
3399
3399
|
arrayRemove,
|
|
@@ -5243,12 +5243,13 @@ async function getRecommendedProceduresUtil(db, appointmentId) {
|
|
|
5243
5243
|
}
|
|
5244
5244
|
|
|
5245
5245
|
// src/services/appointment/utils/zone-photo.utils.ts
|
|
5246
|
-
import { updateDoc as updateDoc6, serverTimestamp as serverTimestamp6, doc as doc9 } from "firebase/firestore";
|
|
5246
|
+
import { updateDoc as updateDoc6, serverTimestamp as serverTimestamp6, doc as doc9, Timestamp as Timestamp6 } from "firebase/firestore";
|
|
5247
5247
|
function addVisibilityAudit(updates, doctorId) {
|
|
5248
5248
|
if (updates.showToPatient !== void 0 || updates.beforeNoteVisibleToPatient !== void 0 || updates.afterNoteVisibleToPatient !== void 0) {
|
|
5249
5249
|
return {
|
|
5250
5250
|
...updates,
|
|
5251
|
-
visibilityUpdatedAt:
|
|
5251
|
+
visibilityUpdatedAt: Timestamp6.now(),
|
|
5252
|
+
// Use client-side timestamp (Firestore limitation)
|
|
5252
5253
|
visibilityUpdatedBy: doctorId
|
|
5253
5254
|
};
|
|
5254
5255
|
}
|
|
@@ -5685,13 +5686,13 @@ var AppointmentService = class extends BaseService {
|
|
|
5685
5686
|
}
|
|
5686
5687
|
updateData.cancellationReason = details.cancellationReason;
|
|
5687
5688
|
updateData.canceledBy = details.canceledBy;
|
|
5688
|
-
updateData.cancellationTime =
|
|
5689
|
+
updateData.cancellationTime = Timestamp7.now();
|
|
5689
5690
|
}
|
|
5690
5691
|
if (newStatus === "confirmed" /* CONFIRMED */) {
|
|
5691
|
-
updateData.confirmationTime =
|
|
5692
|
+
updateData.confirmationTime = Timestamp7.now();
|
|
5692
5693
|
}
|
|
5693
5694
|
if (newStatus === "rescheduled_by_clinic" /* RESCHEDULED_BY_CLINIC */) {
|
|
5694
|
-
updateData.rescheduleTime =
|
|
5695
|
+
updateData.rescheduleTime = Timestamp7.now();
|
|
5695
5696
|
}
|
|
5696
5697
|
return this.updateAppointment(appointmentId, updateData);
|
|
5697
5698
|
}
|
|
@@ -5743,7 +5744,7 @@ var AppointmentService = class extends BaseService {
|
|
|
5743
5744
|
status: "rescheduled_by_clinic" /* RESCHEDULED_BY_CLINIC */,
|
|
5744
5745
|
appointmentStartTime: startTimestamp,
|
|
5745
5746
|
appointmentEndTime: endTimestamp,
|
|
5746
|
-
rescheduleTime:
|
|
5747
|
+
rescheduleTime: Timestamp7.now(),
|
|
5747
5748
|
confirmationTime: null,
|
|
5748
5749
|
updatedAt: serverTimestamp7()
|
|
5749
5750
|
};
|
|
@@ -5763,19 +5764,19 @@ var AppointmentService = class extends BaseService {
|
|
|
5763
5764
|
return value;
|
|
5764
5765
|
}
|
|
5765
5766
|
if (typeof value === "number") {
|
|
5766
|
-
return
|
|
5767
|
+
return Timestamp7.fromMillis(value);
|
|
5767
5768
|
}
|
|
5768
5769
|
if (typeof value === "string") {
|
|
5769
|
-
return
|
|
5770
|
+
return Timestamp7.fromDate(new Date(value));
|
|
5770
5771
|
}
|
|
5771
5772
|
if (value instanceof Date) {
|
|
5772
|
-
return
|
|
5773
|
+
return Timestamp7.fromDate(value);
|
|
5773
5774
|
}
|
|
5774
5775
|
if (value && typeof value._seconds === "number") {
|
|
5775
|
-
return new
|
|
5776
|
+
return new Timestamp7(value._seconds, value._nanoseconds || 0);
|
|
5776
5777
|
}
|
|
5777
5778
|
if (value && typeof value.seconds === "number") {
|
|
5778
|
-
return new
|
|
5779
|
+
return new Timestamp7(value.seconds, value.nanoseconds || 0);
|
|
5779
5780
|
}
|
|
5780
5781
|
throw new Error(`Invalid timestamp format: ${typeof value}, value: ${JSON.stringify(value)}`);
|
|
5781
5782
|
}
|
|
@@ -5844,7 +5845,7 @@ var AppointmentService = class extends BaseService {
|
|
|
5844
5845
|
}
|
|
5845
5846
|
const updateData = {
|
|
5846
5847
|
status: "in_progress" /* IN_PROGRESS */,
|
|
5847
|
-
procedureActualStartTime:
|
|
5848
|
+
procedureActualStartTime: Timestamp7.now(),
|
|
5848
5849
|
// Set actual start time
|
|
5849
5850
|
updatedAt: serverTimestamp7()
|
|
5850
5851
|
};
|
|
@@ -5860,7 +5861,7 @@ var AppointmentService = class extends BaseService {
|
|
|
5860
5861
|
const appointment = await this.getAppointmentById(appointmentId);
|
|
5861
5862
|
if (!appointment) throw new Error(`Appointment ${appointmentId} not found.`);
|
|
5862
5863
|
let calculatedDurationMinutes = actualDurationMinutesInput;
|
|
5863
|
-
const procedureCompletionTime =
|
|
5864
|
+
const procedureCompletionTime = Timestamp7.now();
|
|
5864
5865
|
if (calculatedDurationMinutes === void 0 && appointment.procedureActualStartTime) {
|
|
5865
5866
|
const startTimeMillis = appointment.procedureActualStartTime.toMillis();
|
|
5866
5867
|
const endTimeMillis = procedureCompletionTime.toMillis();
|
|
@@ -5892,7 +5893,7 @@ var AppointmentService = class extends BaseService {
|
|
|
5892
5893
|
console.log(`[APPOINTMENT_SERVICE] Admin marking no-show for: ${appointmentId}`);
|
|
5893
5894
|
const appointment = await this.getAppointmentById(appointmentId);
|
|
5894
5895
|
if (!appointment) throw new Error(`Appointment ${appointmentId} not found.`);
|
|
5895
|
-
if (
|
|
5896
|
+
if (Timestamp7.now().toMillis() < appointment.appointmentStartTime.toMillis()) {
|
|
5896
5897
|
throw new Error("Cannot mark no-show before appointment start time.");
|
|
5897
5898
|
}
|
|
5898
5899
|
return this.updateAppointmentStatus(appointmentId, "no_show" /* NO_SHOW */, {
|
|
@@ -5910,7 +5911,7 @@ var AppointmentService = class extends BaseService {
|
|
|
5910
5911
|
const newMediaItem = {
|
|
5911
5912
|
...mediaItemData,
|
|
5912
5913
|
id: this.generateId(),
|
|
5913
|
-
uploadedAt:
|
|
5914
|
+
uploadedAt: Timestamp7.now(),
|
|
5914
5915
|
uploadedBy: currentUser.uid
|
|
5915
5916
|
};
|
|
5916
5917
|
const updateData = {
|
|
@@ -5948,7 +5949,7 @@ var AppointmentService = class extends BaseService {
|
|
|
5948
5949
|
const newReviewInfo = {
|
|
5949
5950
|
...reviewData,
|
|
5950
5951
|
reviewId: this.generateId(),
|
|
5951
|
-
reviewedAt:
|
|
5952
|
+
reviewedAt: Timestamp7.now()
|
|
5952
5953
|
};
|
|
5953
5954
|
const updateData = {
|
|
5954
5955
|
reviewInfo: newReviewInfo,
|
|
@@ -6006,9 +6007,9 @@ var AppointmentService = class extends BaseService {
|
|
|
6006
6007
|
const constraints = [];
|
|
6007
6008
|
constraints.push(where6("patientId", "==", patientId));
|
|
6008
6009
|
constraints.push(where6("status", "in", upcomingStatuses));
|
|
6009
|
-
constraints.push(where6("appointmentStartTime", ">=",
|
|
6010
|
+
constraints.push(where6("appointmentStartTime", ">=", Timestamp7.fromDate(effectiveStartDate)));
|
|
6010
6011
|
if (options == null ? void 0 : options.endDate) {
|
|
6011
|
-
constraints.push(where6("appointmentStartTime", "<=",
|
|
6012
|
+
constraints.push(where6("appointmentStartTime", "<=", Timestamp7.fromDate(options.endDate)));
|
|
6012
6013
|
}
|
|
6013
6014
|
constraints.push(orderBy3("appointmentStartTime", "asc"));
|
|
6014
6015
|
if (options == null ? void 0 : options.limit) {
|
|
@@ -6062,10 +6063,10 @@ var AppointmentService = class extends BaseService {
|
|
|
6062
6063
|
constraints.push(where6("status", "in", pastStatuses));
|
|
6063
6064
|
if (options == null ? void 0 : options.startDate) {
|
|
6064
6065
|
constraints.push(
|
|
6065
|
-
where6("appointmentStartTime", ">=",
|
|
6066
|
+
where6("appointmentStartTime", ">=", Timestamp7.fromDate(options.startDate))
|
|
6066
6067
|
);
|
|
6067
6068
|
}
|
|
6068
|
-
constraints.push(where6("appointmentStartTime", "<=",
|
|
6069
|
+
constraints.push(where6("appointmentStartTime", "<=", Timestamp7.fromDate(effectiveEndDate)));
|
|
6069
6070
|
constraints.push(orderBy3("appointmentStartTime", "desc"));
|
|
6070
6071
|
if (options == null ? void 0 : options.limit) {
|
|
6071
6072
|
constraints.push(limit3(options.limit));
|
|
@@ -6890,6 +6891,28 @@ var AppointmentService = class extends BaseService {
|
|
|
6890
6891
|
throw error;
|
|
6891
6892
|
}
|
|
6892
6893
|
}
|
|
6894
|
+
/**
|
|
6895
|
+
* Updates visibility of notes for a zone item (product or standalone note)
|
|
6896
|
+
*
|
|
6897
|
+
* @param appointmentId ID of the appointment
|
|
6898
|
+
* @param zoneId Zone ID
|
|
6899
|
+
* @param itemIndex Index of the item in the zone
|
|
6900
|
+
* @param notesVisibleToPatient Whether the notes should be visible to patient
|
|
6901
|
+
* @returns The updated appointment
|
|
6902
|
+
*/
|
|
6903
|
+
async updateZoneItemNoteVisibility(appointmentId, zoneId, itemIndex, notesVisibleToPatient) {
|
|
6904
|
+
try {
|
|
6905
|
+
console.log(
|
|
6906
|
+
`[APPOINTMENT_SERVICE] Updating zone item note visibility at index ${itemIndex} for zone ${zoneId} to ${notesVisibleToPatient}`
|
|
6907
|
+
);
|
|
6908
|
+
return await updateZoneItemUtil(this.db, appointmentId, zoneId, itemIndex, {
|
|
6909
|
+
notesVisibleToPatient
|
|
6910
|
+
});
|
|
6911
|
+
} catch (error) {
|
|
6912
|
+
console.error(`[APPOINTMENT_SERVICE] Error updating zone item note visibility:`, error);
|
|
6913
|
+
throw error;
|
|
6914
|
+
}
|
|
6915
|
+
}
|
|
6893
6916
|
/**
|
|
6894
6917
|
* Gets a specific photo entry from a zone
|
|
6895
6918
|
*
|
|
@@ -6918,7 +6941,13 @@ var AppointmentService = class extends BaseService {
|
|
|
6918
6941
|
* @returns The updated appointment
|
|
6919
6942
|
*/
|
|
6920
6943
|
async updateFinalizationNotes(appointmentId, sharedNotes, internalNotes) {
|
|
6944
|
+
var _a, _b, _c;
|
|
6921
6945
|
try {
|
|
6946
|
+
console.log("\u{1F50D} [APPOINTMENT_SERVICE] updateFinalizationNotes called:", {
|
|
6947
|
+
appointmentId,
|
|
6948
|
+
sharedNotes,
|
|
6949
|
+
internalNotes
|
|
6950
|
+
});
|
|
6922
6951
|
const appointment = await this.getAppointmentById(appointmentId);
|
|
6923
6952
|
if (!appointment) {
|
|
6924
6953
|
throw new Error(`Appointment ${appointmentId} not found`);
|
|
@@ -6935,23 +6964,40 @@ var AppointmentService = class extends BaseService {
|
|
|
6935
6964
|
finalizationNotesInternal: null,
|
|
6936
6965
|
finalizationNotes: null
|
|
6937
6966
|
};
|
|
6967
|
+
console.log("\u{1F50D} [APPOINTMENT_SERVICE] Current metadata:", {
|
|
6968
|
+
finalizationNotesShared: currentMetadata.finalizationNotesShared,
|
|
6969
|
+
finalizationNotesInternal: currentMetadata.finalizationNotesInternal,
|
|
6970
|
+
finalizationNotes: currentMetadata.finalizationNotes
|
|
6971
|
+
});
|
|
6972
|
+
const metadataUpdate = {
|
|
6973
|
+
selectedZones: currentMetadata.selectedZones,
|
|
6974
|
+
zonePhotos: currentMetadata.zonePhotos,
|
|
6975
|
+
zonesData: currentMetadata.zonesData || null,
|
|
6976
|
+
appointmentProducts: currentMetadata.appointmentProducts || [],
|
|
6977
|
+
extendedProcedures: currentMetadata.extendedProcedures || [],
|
|
6978
|
+
recommendedProcedures: currentMetadata.recommendedProcedures || [],
|
|
6979
|
+
finalbilling: currentMetadata.finalbilling,
|
|
6980
|
+
finalizationNotesShared: sharedNotes !== void 0 ? sharedNotes : currentMetadata.finalizationNotesShared,
|
|
6981
|
+
finalizationNotesInternal: internalNotes !== void 0 ? internalNotes : currentMetadata.finalizationNotesInternal,
|
|
6982
|
+
// Keep deprecated field for backward compatibility during migration
|
|
6983
|
+
finalizationNotes: sharedNotes !== void 0 ? sharedNotes : currentMetadata.finalizationNotes || currentMetadata.finalizationNotesShared
|
|
6984
|
+
};
|
|
6985
|
+
console.log("\u{1F50D} [APPOINTMENT_SERVICE] Update data metadata:", {
|
|
6986
|
+
finalizationNotesShared: metadataUpdate.finalizationNotesShared,
|
|
6987
|
+
finalizationNotesInternal: metadataUpdate.finalizationNotesInternal,
|
|
6988
|
+
finalizationNotes: metadataUpdate.finalizationNotes
|
|
6989
|
+
});
|
|
6938
6990
|
const updateData = {
|
|
6939
|
-
metadata:
|
|
6940
|
-
selectedZones: currentMetadata.selectedZones,
|
|
6941
|
-
zonePhotos: currentMetadata.zonePhotos,
|
|
6942
|
-
zonesData: currentMetadata.zonesData || null,
|
|
6943
|
-
appointmentProducts: currentMetadata.appointmentProducts || [],
|
|
6944
|
-
extendedProcedures: currentMetadata.extendedProcedures || [],
|
|
6945
|
-
recommendedProcedures: currentMetadata.recommendedProcedures || [],
|
|
6946
|
-
finalbilling: currentMetadata.finalbilling,
|
|
6947
|
-
finalizationNotesShared: sharedNotes !== void 0 ? sharedNotes : currentMetadata.finalizationNotesShared,
|
|
6948
|
-
finalizationNotesInternal: internalNotes !== void 0 ? internalNotes : currentMetadata.finalizationNotesInternal,
|
|
6949
|
-
// Keep deprecated field for backward compatibility during migration
|
|
6950
|
-
finalizationNotes: sharedNotes !== void 0 ? sharedNotes : currentMetadata.finalizationNotes || currentMetadata.finalizationNotesShared
|
|
6951
|
-
},
|
|
6991
|
+
metadata: metadataUpdate,
|
|
6952
6992
|
updatedAt: serverTimestamp7()
|
|
6953
6993
|
};
|
|
6954
|
-
|
|
6994
|
+
const result = await this.updateAppointment(appointmentId, updateData);
|
|
6995
|
+
console.log("\u{1F50D} [APPOINTMENT_SERVICE] After update, result metadata:", {
|
|
6996
|
+
finalizationNotesShared: (_a = result.metadata) == null ? void 0 : _a.finalizationNotesShared,
|
|
6997
|
+
finalizationNotesInternal: (_b = result.metadata) == null ? void 0 : _b.finalizationNotesInternal,
|
|
6998
|
+
finalizationNotes: (_c = result.metadata) == null ? void 0 : _c.finalizationNotes
|
|
6999
|
+
});
|
|
7000
|
+
return result;
|
|
6955
7001
|
} catch (error) {
|
|
6956
7002
|
console.error(`[APPOINTMENT_SERVICE] Error updating finalization notes:`, error);
|
|
6957
7003
|
throw error;
|
|
@@ -7698,7 +7744,7 @@ import {
|
|
|
7698
7744
|
where as where14,
|
|
7699
7745
|
updateDoc as updateDoc17,
|
|
7700
7746
|
deleteDoc as deleteDoc5,
|
|
7701
|
-
Timestamp as
|
|
7747
|
+
Timestamp as Timestamp19,
|
|
7702
7748
|
setDoc as setDoc12,
|
|
7703
7749
|
serverTimestamp as serverTimestamp18
|
|
7704
7750
|
} from "firebase/firestore";
|
|
@@ -7806,7 +7852,7 @@ import {
|
|
|
7806
7852
|
updateDoc as updateDoc15,
|
|
7807
7853
|
serverTimestamp as serverTimestamp16
|
|
7808
7854
|
} from "firebase/firestore";
|
|
7809
|
-
import { Timestamp as
|
|
7855
|
+
import { Timestamp as Timestamp16 } from "firebase/firestore";
|
|
7810
7856
|
|
|
7811
7857
|
// src/services/patient/utils/clinic.utils.ts
|
|
7812
7858
|
import {
|
|
@@ -7835,7 +7881,7 @@ import { getDoc as getDoc12, updateDoc as updateDoc8, setDoc as setDoc4, serverT
|
|
|
7835
7881
|
|
|
7836
7882
|
// src/validations/patient.schema.ts
|
|
7837
7883
|
import { z as z7 } from "zod";
|
|
7838
|
-
import { Timestamp as
|
|
7884
|
+
import { Timestamp as Timestamp9 } from "firebase/firestore";
|
|
7839
7885
|
|
|
7840
7886
|
// src/validations/patient/medical-info.schema.ts
|
|
7841
7887
|
import { z as z6 } from "zod";
|
|
@@ -7862,23 +7908,23 @@ var BlockingCondition = /* @__PURE__ */ ((BlockingCondition2) => {
|
|
|
7862
7908
|
|
|
7863
7909
|
// src/validations/common.schema.ts
|
|
7864
7910
|
import { z as z5 } from "zod";
|
|
7865
|
-
import { Timestamp as
|
|
7911
|
+
import { Timestamp as Timestamp8 } from "firebase/firestore";
|
|
7866
7912
|
var timestampSchema = z5.union([
|
|
7867
7913
|
z5.object({
|
|
7868
7914
|
seconds: z5.number(),
|
|
7869
7915
|
nanoseconds: z5.number()
|
|
7870
7916
|
}),
|
|
7871
|
-
z5.instanceof(
|
|
7917
|
+
z5.instanceof(Timestamp8),
|
|
7872
7918
|
z5.instanceof(Date)
|
|
7873
7919
|
// Add support for Date objects that Firestore returns on client
|
|
7874
7920
|
]).transform((data) => {
|
|
7875
|
-
if (data instanceof
|
|
7921
|
+
if (data instanceof Timestamp8) {
|
|
7876
7922
|
return data;
|
|
7877
7923
|
}
|
|
7878
7924
|
if (data instanceof Date) {
|
|
7879
|
-
return
|
|
7925
|
+
return Timestamp8.fromDate(data);
|
|
7880
7926
|
}
|
|
7881
|
-
return new
|
|
7927
|
+
return new Timestamp8(data.seconds, data.nanoseconds);
|
|
7882
7928
|
});
|
|
7883
7929
|
|
|
7884
7930
|
// src/validations/patient/medical-info.schema.ts
|
|
@@ -8034,8 +8080,8 @@ var patientLocationInfoSchema = z7.object({
|
|
|
8034
8080
|
patientId: z7.string(),
|
|
8035
8081
|
userRef: z7.string().optional(),
|
|
8036
8082
|
locationData: locationDataSchema,
|
|
8037
|
-
createdAt: z7.instanceof(
|
|
8038
|
-
updatedAt: z7.instanceof(
|
|
8083
|
+
createdAt: z7.instanceof(Timestamp9),
|
|
8084
|
+
updatedAt: z7.instanceof(Timestamp9)
|
|
8039
8085
|
});
|
|
8040
8086
|
var createPatientLocationInfoSchema = z7.object({
|
|
8041
8087
|
patientId: z7.string(),
|
|
@@ -8048,26 +8094,26 @@ var patientSensitiveInfoSchema = z7.object({
|
|
|
8048
8094
|
photoUrl: z7.string().nullable().optional(),
|
|
8049
8095
|
firstName: z7.string().min(2),
|
|
8050
8096
|
lastName: z7.string().min(2),
|
|
8051
|
-
dateOfBirth: z7.instanceof(
|
|
8097
|
+
dateOfBirth: z7.instanceof(Timestamp9).nullable(),
|
|
8052
8098
|
gender: z7.nativeEnum(Gender),
|
|
8053
8099
|
email: z7.string().email().optional(),
|
|
8054
8100
|
phoneNumber: z7.string().optional(),
|
|
8055
8101
|
alternativePhoneNumber: z7.string().optional(),
|
|
8056
8102
|
addressData: addressDataSchema.optional(),
|
|
8057
8103
|
emergencyContacts: z7.array(emergencyContactSchema).optional(),
|
|
8058
|
-
createdAt: z7.instanceof(
|
|
8059
|
-
updatedAt: z7.instanceof(
|
|
8104
|
+
createdAt: z7.instanceof(Timestamp9),
|
|
8105
|
+
updatedAt: z7.instanceof(Timestamp9)
|
|
8060
8106
|
});
|
|
8061
8107
|
var patientDoctorSchema = z7.object({
|
|
8062
8108
|
userRef: z7.string(),
|
|
8063
|
-
assignedAt: z7.instanceof(
|
|
8109
|
+
assignedAt: z7.instanceof(Timestamp9),
|
|
8064
8110
|
assignedBy: z7.string().optional(),
|
|
8065
8111
|
isActive: z7.boolean(),
|
|
8066
8112
|
notes: z7.string().optional()
|
|
8067
8113
|
});
|
|
8068
8114
|
var patientClinicSchema = z7.object({
|
|
8069
8115
|
clinicId: z7.string(),
|
|
8070
|
-
assignedAt: z7.instanceof(
|
|
8116
|
+
assignedAt: z7.instanceof(Timestamp9),
|
|
8071
8117
|
assignedBy: z7.string().optional(),
|
|
8072
8118
|
isActive: z7.boolean(),
|
|
8073
8119
|
notes: z7.string().optional()
|
|
@@ -8083,14 +8129,14 @@ var patientProfileSchema = z7.object({
|
|
|
8083
8129
|
isManual: z7.boolean().default(false),
|
|
8084
8130
|
// Default to false if missing
|
|
8085
8131
|
phoneNumber: z7.string().nullable().optional(),
|
|
8086
|
-
dateOfBirth: z7.instanceof(
|
|
8132
|
+
dateOfBirth: z7.instanceof(Timestamp9).nullable().optional(),
|
|
8087
8133
|
doctors: z7.array(patientDoctorSchema),
|
|
8088
8134
|
clinics: z7.array(patientClinicSchema),
|
|
8089
8135
|
doctorIds: z7.array(z7.string()),
|
|
8090
8136
|
clinicIds: z7.array(z7.string()),
|
|
8091
8137
|
dismissedNextStepsRecommendations: z7.array(z7.string()).optional(),
|
|
8092
|
-
createdAt: z7.instanceof(
|
|
8093
|
-
updatedAt: z7.instanceof(
|
|
8138
|
+
createdAt: z7.instanceof(Timestamp9),
|
|
8139
|
+
updatedAt: z7.instanceof(Timestamp9)
|
|
8094
8140
|
});
|
|
8095
8141
|
var createPatientProfileSchema = z7.object({
|
|
8096
8142
|
userRef: z7.string().optional(),
|
|
@@ -8111,7 +8157,7 @@ var createPatientSensitiveInfoSchema = z7.object({
|
|
|
8111
8157
|
photoUrl: mediaResourceSchema.nullable().optional(),
|
|
8112
8158
|
firstName: z7.string().min(2),
|
|
8113
8159
|
lastName: z7.string().min(2),
|
|
8114
|
-
dateOfBirth: z7.instanceof(
|
|
8160
|
+
dateOfBirth: z7.instanceof(Timestamp9).nullable(),
|
|
8115
8161
|
gender: z7.nativeEnum(Gender),
|
|
8116
8162
|
email: z7.string().email().optional(),
|
|
8117
8163
|
phoneNumber: z7.string().optional(),
|
|
@@ -8123,7 +8169,7 @@ var createManualPatientSchema = z7.object({
|
|
|
8123
8169
|
clinicId: z7.string().min(1, "Clinic ID is required"),
|
|
8124
8170
|
firstName: z7.string().min(2, "First name is required"),
|
|
8125
8171
|
lastName: z7.string().min(2, "Last name is required"),
|
|
8126
|
-
dateOfBirth: z7.instanceof(
|
|
8172
|
+
dateOfBirth: z7.instanceof(Timestamp9).nullable(),
|
|
8127
8173
|
gender: z7.nativeEnum(Gender),
|
|
8128
8174
|
phoneNumber: z7.string().optional(),
|
|
8129
8175
|
email: z7.string().email().optional(),
|
|
@@ -8304,13 +8350,13 @@ import {
|
|
|
8304
8350
|
updateDoc as updateDoc7,
|
|
8305
8351
|
setDoc as setDoc3,
|
|
8306
8352
|
deleteDoc as deleteDoc3,
|
|
8307
|
-
Timestamp as
|
|
8353
|
+
Timestamp as Timestamp11,
|
|
8308
8354
|
serverTimestamp as serverTimestamp8
|
|
8309
8355
|
} from "firebase/firestore";
|
|
8310
8356
|
|
|
8311
8357
|
// src/validations/clinic.schema.ts
|
|
8312
8358
|
import { z as z10 } from "zod";
|
|
8313
|
-
import { Timestamp as
|
|
8359
|
+
import { Timestamp as Timestamp10 } from "firebase/firestore";
|
|
8314
8360
|
|
|
8315
8361
|
// src/validations/reviews.schema.ts
|
|
8316
8362
|
import { z as z8 } from "zod";
|
|
@@ -8570,8 +8616,8 @@ var clinicAdminSchema = z10.object({
|
|
|
8570
8616
|
clinicsManagedInfo: z10.array(clinicInfoSchema),
|
|
8571
8617
|
contactInfo: contactPersonSchema,
|
|
8572
8618
|
roleTitle: z10.string(),
|
|
8573
|
-
createdAt: z10.instanceof(Date).or(z10.instanceof(
|
|
8574
|
-
updatedAt: z10.instanceof(Date).or(z10.instanceof(
|
|
8619
|
+
createdAt: z10.instanceof(Date).or(z10.instanceof(Timestamp10)),
|
|
8620
|
+
updatedAt: z10.instanceof(Date).or(z10.instanceof(Timestamp10)),
|
|
8575
8621
|
isActive: z10.boolean()
|
|
8576
8622
|
});
|
|
8577
8623
|
var adminTokenSchema = z10.object({
|
|
@@ -8580,9 +8626,9 @@ var adminTokenSchema = z10.object({
|
|
|
8580
8626
|
email: z10.string().email().optional().nullable(),
|
|
8581
8627
|
status: z10.nativeEnum(AdminTokenStatus),
|
|
8582
8628
|
usedByUserRef: z10.string().optional(),
|
|
8583
|
-
createdAt: z10.instanceof(Date).or(z10.instanceof(
|
|
8629
|
+
createdAt: z10.instanceof(Date).or(z10.instanceof(Timestamp10)),
|
|
8584
8630
|
// Timestamp
|
|
8585
|
-
expiresAt: z10.instanceof(Date).or(z10.instanceof(
|
|
8631
|
+
expiresAt: z10.instanceof(Date).or(z10.instanceof(Timestamp10))
|
|
8586
8632
|
// Timestamp
|
|
8587
8633
|
});
|
|
8588
8634
|
var stripeTransactionDataSchema = z10.object({
|
|
@@ -8603,9 +8649,9 @@ var billingInfoSchema = z10.object({
|
|
|
8603
8649
|
planType: z10.string(),
|
|
8604
8650
|
stripeSubscriptionId: z10.string().nullable(),
|
|
8605
8651
|
stripePriceId: z10.string().nullable(),
|
|
8606
|
-
currentPeriodStart: z10.instanceof(Date).or(z10.instanceof(
|
|
8607
|
-
currentPeriodEnd: z10.instanceof(Date).or(z10.instanceof(
|
|
8608
|
-
updatedAt: z10.instanceof(Date).or(z10.instanceof(
|
|
8652
|
+
currentPeriodStart: z10.instanceof(Date).or(z10.instanceof(Timestamp10)).nullable(),
|
|
8653
|
+
currentPeriodEnd: z10.instanceof(Date).or(z10.instanceof(Timestamp10)).nullable(),
|
|
8654
|
+
updatedAt: z10.instanceof(Date).or(z10.instanceof(Timestamp10))
|
|
8609
8655
|
});
|
|
8610
8656
|
var billingTransactionSchema = z10.object({
|
|
8611
8657
|
id: z10.string(),
|
|
@@ -8617,8 +8663,8 @@ var billingTransactionSchema = z10.object({
|
|
|
8617
8663
|
stripeData: stripeTransactionDataSchema,
|
|
8618
8664
|
planDetails: planDetailsSchema,
|
|
8619
8665
|
metadata: z10.record(z10.any()).optional(),
|
|
8620
|
-
timestamp: z10.instanceof(Date).or(z10.instanceof(
|
|
8621
|
-
createdAt: z10.instanceof(Date).or(z10.instanceof(
|
|
8666
|
+
timestamp: z10.instanceof(Date).or(z10.instanceof(Timestamp10)),
|
|
8667
|
+
createdAt: z10.instanceof(Date).or(z10.instanceof(Timestamp10))
|
|
8622
8668
|
});
|
|
8623
8669
|
var createBillingTransactionSchema = z10.object({
|
|
8624
8670
|
type: z10.nativeEnum(BillingTransactionType),
|
|
@@ -8646,9 +8692,9 @@ var clinicGroupSchema = z10.object({
|
|
|
8646
8692
|
adminsInfo: z10.array(adminInfoSchema),
|
|
8647
8693
|
adminTokens: z10.array(adminTokenSchema),
|
|
8648
8694
|
ownerId: z10.string().nullable(),
|
|
8649
|
-
createdAt: z10.instanceof(Date).or(z10.instanceof(
|
|
8695
|
+
createdAt: z10.instanceof(Date).or(z10.instanceof(Timestamp10)),
|
|
8650
8696
|
// Timestamp
|
|
8651
|
-
updatedAt: z10.instanceof(Date).or(z10.instanceof(
|
|
8697
|
+
updatedAt: z10.instanceof(Date).or(z10.instanceof(Timestamp10)),
|
|
8652
8698
|
// Timestamp
|
|
8653
8699
|
isActive: z10.boolean(),
|
|
8654
8700
|
logo: mediaResourceSchema.optional().nullable(),
|
|
@@ -8691,9 +8737,9 @@ var clinicSchema = z10.object({
|
|
|
8691
8737
|
// Use the correct schema for aggregated procedure info
|
|
8692
8738
|
reviewInfo: clinicReviewInfoSchema,
|
|
8693
8739
|
admins: z10.array(z10.string()),
|
|
8694
|
-
createdAt: z10.instanceof(Date).or(z10.instanceof(
|
|
8740
|
+
createdAt: z10.instanceof(Date).or(z10.instanceof(Timestamp10)),
|
|
8695
8741
|
// Timestamp
|
|
8696
|
-
updatedAt: z10.instanceof(Date).or(z10.instanceof(
|
|
8742
|
+
updatedAt: z10.instanceof(Date).or(z10.instanceof(Timestamp10)),
|
|
8697
8743
|
// Timestamp
|
|
8698
8744
|
isActive: z10.boolean(),
|
|
8699
8745
|
isVerified: z10.boolean(),
|
|
@@ -8937,8 +8983,8 @@ async function createClinicAdmin(db, data, clinicGroupService) {
|
|
|
8937
8983
|
try {
|
|
8938
8984
|
clinicAdminSchema.parse({
|
|
8939
8985
|
...adminData,
|
|
8940
|
-
createdAt:
|
|
8941
|
-
updatedAt:
|
|
8986
|
+
createdAt: Timestamp11.now(),
|
|
8987
|
+
updatedAt: Timestamp11.now()
|
|
8942
8988
|
});
|
|
8943
8989
|
console.log("[CLINIC_ADMIN] Admin object validation passed");
|
|
8944
8990
|
} catch (schemaError) {
|
|
@@ -9589,13 +9635,13 @@ import {
|
|
|
9589
9635
|
arrayUnion as arrayUnion2,
|
|
9590
9636
|
arrayRemove as arrayRemove2,
|
|
9591
9637
|
serverTimestamp as serverTimestamp12,
|
|
9592
|
-
Timestamp as
|
|
9638
|
+
Timestamp as Timestamp12
|
|
9593
9639
|
} from "firebase/firestore";
|
|
9594
9640
|
var addDoctorUtil = async (db, patientId, doctorRef, assignedBy) => {
|
|
9595
9641
|
var _a;
|
|
9596
9642
|
const newDoctor = {
|
|
9597
9643
|
userRef: doctorRef,
|
|
9598
|
-
assignedAt:
|
|
9644
|
+
assignedAt: Timestamp12.now(),
|
|
9599
9645
|
assignedBy,
|
|
9600
9646
|
isActive: true
|
|
9601
9647
|
};
|
|
@@ -9614,7 +9660,7 @@ var addDoctorUtil = async (db, patientId, doctorRef, assignedBy) => {
|
|
|
9614
9660
|
updatedDoctors[existingDoctorIndex] = {
|
|
9615
9661
|
...updatedDoctors[existingDoctorIndex],
|
|
9616
9662
|
isActive: true,
|
|
9617
|
-
assignedAt:
|
|
9663
|
+
assignedAt: Timestamp12.now(),
|
|
9618
9664
|
assignedBy
|
|
9619
9665
|
};
|
|
9620
9666
|
updates.doctors = updatedDoctors;
|
|
@@ -9642,7 +9688,7 @@ var addClinicUtil = async (db, patientId, clinicId, assignedBy) => {
|
|
|
9642
9688
|
var _a;
|
|
9643
9689
|
const newClinic = {
|
|
9644
9690
|
clinicId,
|
|
9645
|
-
assignedAt:
|
|
9691
|
+
assignedAt: Timestamp12.now(),
|
|
9646
9692
|
assignedBy,
|
|
9647
9693
|
isActive: true
|
|
9648
9694
|
};
|
|
@@ -9661,7 +9707,7 @@ var addClinicUtil = async (db, patientId, clinicId, assignedBy) => {
|
|
|
9661
9707
|
updatedClinics[existingClinicIndex] = {
|
|
9662
9708
|
...updatedClinics[existingClinicIndex],
|
|
9663
9709
|
isActive: true,
|
|
9664
|
-
assignedAt:
|
|
9710
|
+
assignedAt: Timestamp12.now(),
|
|
9665
9711
|
assignedBy
|
|
9666
9712
|
};
|
|
9667
9713
|
updates.clinics = updatedClinics;
|
|
@@ -9980,7 +10026,7 @@ import {
|
|
|
9980
10026
|
arrayRemove as arrayRemove4,
|
|
9981
10027
|
serverTimestamp as serverTimestamp14,
|
|
9982
10028
|
increment,
|
|
9983
|
-
Timestamp as
|
|
10029
|
+
Timestamp as Timestamp14,
|
|
9984
10030
|
collection as collection11,
|
|
9985
10031
|
query as query11,
|
|
9986
10032
|
where as where11,
|
|
@@ -10023,8 +10069,8 @@ var createPatientProfileUtil = async (db, data, generateId2) => {
|
|
|
10023
10069
|
};
|
|
10024
10070
|
patientProfileSchema.parse({
|
|
10025
10071
|
...patientData,
|
|
10026
|
-
createdAt:
|
|
10027
|
-
updatedAt:
|
|
10072
|
+
createdAt: Timestamp14.now(),
|
|
10073
|
+
updatedAt: Timestamp14.now()
|
|
10028
10074
|
});
|
|
10029
10075
|
await setDoc8(getPatientDocRef(db, patientId), patientData);
|
|
10030
10076
|
console.log(`[createPatientProfileUtil] Creating sensitive info document`);
|
|
@@ -10178,12 +10224,12 @@ var testCreateSubDocuments = async (db, patientId, userRef) => {
|
|
|
10178
10224
|
photoUrl: "",
|
|
10179
10225
|
firstName: "Name",
|
|
10180
10226
|
lastName: "Surname",
|
|
10181
|
-
dateOfBirth:
|
|
10227
|
+
dateOfBirth: Timestamp14.now(),
|
|
10182
10228
|
gender: "prefer_not_to_say" /* PREFER_NOT_TO_SAY */,
|
|
10183
10229
|
email: "test@example.com",
|
|
10184
10230
|
phoneNumber: "",
|
|
10185
|
-
createdAt:
|
|
10186
|
-
updatedAt:
|
|
10231
|
+
createdAt: Timestamp14.now(),
|
|
10232
|
+
updatedAt: Timestamp14.now()
|
|
10187
10233
|
};
|
|
10188
10234
|
await setDoc8(sensitiveInfoRef, defaultSensitiveInfo);
|
|
10189
10235
|
console.log(
|
|
@@ -10197,7 +10243,7 @@ var testCreateSubDocuments = async (db, patientId, userRef) => {
|
|
|
10197
10243
|
const defaultMedicalInfo = {
|
|
10198
10244
|
...DEFAULT_MEDICAL_INFO,
|
|
10199
10245
|
patientId,
|
|
10200
|
-
lastUpdated:
|
|
10246
|
+
lastUpdated: Timestamp14.now(),
|
|
10201
10247
|
updatedBy: userRef
|
|
10202
10248
|
};
|
|
10203
10249
|
await setDoc8(medicalInfoRef, defaultMedicalInfo);
|
|
@@ -10315,7 +10361,7 @@ import {
|
|
|
10315
10361
|
where as where12,
|
|
10316
10362
|
setDoc as setDoc9,
|
|
10317
10363
|
updateDoc as updateDoc13,
|
|
10318
|
-
Timestamp as
|
|
10364
|
+
Timestamp as Timestamp15,
|
|
10319
10365
|
collectionGroup
|
|
10320
10366
|
} from "firebase/firestore";
|
|
10321
10367
|
|
|
@@ -10365,8 +10411,8 @@ var createPatientTokenUtil = async (db, data, createdBy, generateId2) => {
|
|
|
10365
10411
|
clinicId: validatedData.clinicId,
|
|
10366
10412
|
status: "active" /* ACTIVE */,
|
|
10367
10413
|
createdBy,
|
|
10368
|
-
createdAt:
|
|
10369
|
-
expiresAt:
|
|
10414
|
+
createdAt: Timestamp15.now(),
|
|
10415
|
+
expiresAt: Timestamp15.fromDate(expiration)
|
|
10370
10416
|
};
|
|
10371
10417
|
patientTokenSchema.parse(token);
|
|
10372
10418
|
const tokenRef = doc17(
|
|
@@ -10392,7 +10438,7 @@ var validatePatientTokenUtil = async (db, tokenString) => {
|
|
|
10392
10438
|
tokensRef,
|
|
10393
10439
|
where12("token", "==", tokenString),
|
|
10394
10440
|
where12("status", "==", "active" /* ACTIVE */),
|
|
10395
|
-
where12("expiresAt", ">",
|
|
10441
|
+
where12("expiresAt", ">", Timestamp15.now())
|
|
10396
10442
|
);
|
|
10397
10443
|
const tokenSnapshot = await getDocs12(q);
|
|
10398
10444
|
if (!tokenSnapshot.empty) {
|
|
@@ -10412,7 +10458,7 @@ var markPatientTokenAsUsedUtil = async (db, tokenId, patientId, userId) => {
|
|
|
10412
10458
|
await updateDoc13(tokenRef, {
|
|
10413
10459
|
status: "used" /* USED */,
|
|
10414
10460
|
usedBy: userId,
|
|
10415
|
-
usedAt:
|
|
10461
|
+
usedAt: Timestamp15.now()
|
|
10416
10462
|
});
|
|
10417
10463
|
};
|
|
10418
10464
|
var getActiveInviteTokensByClinicUtil = async (db, clinicId) => {
|
|
@@ -10420,7 +10466,7 @@ var getActiveInviteTokensByClinicUtil = async (db, clinicId) => {
|
|
|
10420
10466
|
collectionGroup(db, INVITE_TOKENS_COLLECTION),
|
|
10421
10467
|
where12("clinicId", "==", clinicId),
|
|
10422
10468
|
where12("status", "==", "active" /* ACTIVE */),
|
|
10423
|
-
where12("expiresAt", ">",
|
|
10469
|
+
where12("expiresAt", ">", Timestamp15.now())
|
|
10424
10470
|
);
|
|
10425
10471
|
const querySnapshot = await getDocs12(tokensQuery);
|
|
10426
10472
|
if (querySnapshot.empty) {
|
|
@@ -10438,7 +10484,7 @@ var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
|
|
|
10438
10484
|
const q = query12(
|
|
10439
10485
|
tokensRef,
|
|
10440
10486
|
where12("status", "==", "active" /* ACTIVE */),
|
|
10441
|
-
where12("expiresAt", ">",
|
|
10487
|
+
where12("expiresAt", ">", Timestamp15.now())
|
|
10442
10488
|
);
|
|
10443
10489
|
const querySnapshot = await getDocs12(q);
|
|
10444
10490
|
if (querySnapshot.empty) {
|
|
@@ -10648,7 +10694,7 @@ var PatientService = class extends BaseService {
|
|
|
10648
10694
|
}
|
|
10649
10695
|
const patientId = this.generateId();
|
|
10650
10696
|
const batch = writeBatch(this.db);
|
|
10651
|
-
const now =
|
|
10697
|
+
const now = Timestamp16.now();
|
|
10652
10698
|
const patientProfileRef = getPatientDocRef(this.db, patientId);
|
|
10653
10699
|
const newProfile = {
|
|
10654
10700
|
id: patientId,
|
|
@@ -11334,7 +11380,7 @@ import {
|
|
|
11334
11380
|
updateDoc as updateDoc16,
|
|
11335
11381
|
setDoc as setDoc11,
|
|
11336
11382
|
deleteDoc as deleteDoc4,
|
|
11337
|
-
Timestamp as
|
|
11383
|
+
Timestamp as Timestamp18,
|
|
11338
11384
|
serverTimestamp as serverTimestamp17,
|
|
11339
11385
|
limit as limit7,
|
|
11340
11386
|
startAfter as startAfter6,
|
|
@@ -11345,7 +11391,7 @@ import {
|
|
|
11345
11391
|
|
|
11346
11392
|
// src/validations/practitioner.schema.ts
|
|
11347
11393
|
import { z as z16 } from "zod";
|
|
11348
|
-
import { Timestamp as
|
|
11394
|
+
import { Timestamp as Timestamp17 } from "firebase/firestore";
|
|
11349
11395
|
|
|
11350
11396
|
// src/backoffice/types/static/certification.types.ts
|
|
11351
11397
|
var CertificationLevel = /* @__PURE__ */ ((CertificationLevel2) => {
|
|
@@ -11378,7 +11424,7 @@ var practitionerBasicInfoSchema = z16.object({
|
|
|
11378
11424
|
title: z16.string().min(2).max(100),
|
|
11379
11425
|
email: z16.string().email(),
|
|
11380
11426
|
phoneNumber: z16.string().regex(/^\+?[1-9]\d{1,14}$/, "Invalid phone number").nullable(),
|
|
11381
|
-
dateOfBirth: z16.instanceof(
|
|
11427
|
+
dateOfBirth: z16.instanceof(Timestamp17).or(z16.date()).nullable(),
|
|
11382
11428
|
gender: z16.enum(["male", "female", "other"]),
|
|
11383
11429
|
profileImageUrl: mediaResourceSchema.optional().nullable(),
|
|
11384
11430
|
bio: z16.string().max(1e3).optional(),
|
|
@@ -11389,8 +11435,8 @@ var practitionerCertificationSchema = z16.object({
|
|
|
11389
11435
|
specialties: z16.array(z16.nativeEnum(CertificationSpecialty)),
|
|
11390
11436
|
licenseNumber: z16.string().min(3).max(50),
|
|
11391
11437
|
issuingAuthority: z16.string().min(2).max(100),
|
|
11392
|
-
issueDate: z16.instanceof(
|
|
11393
|
-
expiryDate: z16.instanceof(
|
|
11438
|
+
issueDate: z16.instanceof(Timestamp17).or(z16.date()),
|
|
11439
|
+
expiryDate: z16.instanceof(Timestamp17).or(z16.date()).optional().nullable(),
|
|
11394
11440
|
verificationStatus: z16.enum(["pending", "verified", "rejected"])
|
|
11395
11441
|
});
|
|
11396
11442
|
var timeSlotSchema = z16.object({
|
|
@@ -11407,8 +11453,8 @@ var practitionerWorkingHoursSchema = z16.object({
|
|
|
11407
11453
|
friday: timeSlotSchema,
|
|
11408
11454
|
saturday: timeSlotSchema,
|
|
11409
11455
|
sunday: timeSlotSchema,
|
|
11410
|
-
createdAt: z16.instanceof(
|
|
11411
|
-
updatedAt: z16.instanceof(
|
|
11456
|
+
createdAt: z16.instanceof(Timestamp17).or(z16.date()),
|
|
11457
|
+
updatedAt: z16.instanceof(Timestamp17).or(z16.date())
|
|
11412
11458
|
});
|
|
11413
11459
|
var practitionerClinicWorkingHoursSchema = z16.object({
|
|
11414
11460
|
clinicId: z16.string().min(1),
|
|
@@ -11422,8 +11468,8 @@ var practitionerClinicWorkingHoursSchema = z16.object({
|
|
|
11422
11468
|
sunday: timeSlotSchema
|
|
11423
11469
|
}),
|
|
11424
11470
|
isActive: z16.boolean(),
|
|
11425
|
-
createdAt: z16.instanceof(
|
|
11426
|
-
updatedAt: z16.instanceof(
|
|
11471
|
+
createdAt: z16.instanceof(Timestamp17).or(z16.date()),
|
|
11472
|
+
updatedAt: z16.instanceof(Timestamp17).or(z16.date())
|
|
11427
11473
|
});
|
|
11428
11474
|
var practitionerSchema = z16.object({
|
|
11429
11475
|
id: z16.string().min(1),
|
|
@@ -11440,8 +11486,8 @@ var practitionerSchema = z16.object({
|
|
|
11440
11486
|
isActive: z16.boolean(),
|
|
11441
11487
|
isVerified: z16.boolean(),
|
|
11442
11488
|
status: z16.nativeEnum(PractitionerStatus),
|
|
11443
|
-
createdAt: z16.instanceof(
|
|
11444
|
-
updatedAt: z16.instanceof(
|
|
11489
|
+
createdAt: z16.instanceof(Timestamp17).or(z16.date()),
|
|
11490
|
+
updatedAt: z16.instanceof(Timestamp17).or(z16.date())
|
|
11445
11491
|
});
|
|
11446
11492
|
var createPractitionerSchema = z16.object({
|
|
11447
11493
|
userRef: z16.string().min(1),
|
|
@@ -11475,10 +11521,10 @@ var practitionerTokenSchema = z16.object({
|
|
|
11475
11521
|
clinicId: z16.string().min(1),
|
|
11476
11522
|
status: z16.nativeEnum(PractitionerTokenStatus),
|
|
11477
11523
|
createdBy: z16.string().min(1),
|
|
11478
|
-
createdAt: z16.instanceof(
|
|
11479
|
-
expiresAt: z16.instanceof(
|
|
11524
|
+
createdAt: z16.instanceof(Timestamp17).or(z16.date()),
|
|
11525
|
+
expiresAt: z16.instanceof(Timestamp17).or(z16.date()),
|
|
11480
11526
|
usedBy: z16.string().optional(),
|
|
11481
|
-
usedAt: z16.instanceof(
|
|
11527
|
+
usedAt: z16.instanceof(Timestamp17).or(z16.date()).optional()
|
|
11482
11528
|
});
|
|
11483
11529
|
var createPractitionerTokenSchema = z16.object({
|
|
11484
11530
|
practitionerId: z16.string().min(1),
|
|
@@ -11623,8 +11669,8 @@ var PractitionerService = class extends BaseService {
|
|
|
11623
11669
|
};
|
|
11624
11670
|
practitionerSchema.parse({
|
|
11625
11671
|
...practitioner,
|
|
11626
|
-
createdAt:
|
|
11627
|
-
updatedAt:
|
|
11672
|
+
createdAt: Timestamp18.now(),
|
|
11673
|
+
updatedAt: Timestamp18.now()
|
|
11628
11674
|
});
|
|
11629
11675
|
const practitionerRef = doc20(
|
|
11630
11676
|
this.db,
|
|
@@ -11730,8 +11776,8 @@ var PractitionerService = class extends BaseService {
|
|
|
11730
11776
|
practitionerSchema.parse({
|
|
11731
11777
|
...practitionerData,
|
|
11732
11778
|
userRef: "temp-for-validation",
|
|
11733
|
-
createdAt:
|
|
11734
|
-
updatedAt:
|
|
11779
|
+
createdAt: Timestamp18.now(),
|
|
11780
|
+
updatedAt: Timestamp18.now()
|
|
11735
11781
|
});
|
|
11736
11782
|
await setDoc11(
|
|
11737
11783
|
doc20(this.db, PRACTITIONERS_COLLECTION, practitionerData.id),
|
|
@@ -11751,8 +11797,8 @@ var PractitionerService = class extends BaseService {
|
|
|
11751
11797
|
clinicId,
|
|
11752
11798
|
status: "active" /* ACTIVE */,
|
|
11753
11799
|
createdBy,
|
|
11754
|
-
createdAt:
|
|
11755
|
-
expiresAt:
|
|
11800
|
+
createdAt: Timestamp18.now(),
|
|
11801
|
+
expiresAt: Timestamp18.fromDate(expiration)
|
|
11756
11802
|
};
|
|
11757
11803
|
practitionerTokenSchema.parse(token);
|
|
11758
11804
|
const tokenPath = `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${token.id}`;
|
|
@@ -11822,8 +11868,8 @@ var PractitionerService = class extends BaseService {
|
|
|
11822
11868
|
clinicId: validatedData.clinicId,
|
|
11823
11869
|
status: "active" /* ACTIVE */,
|
|
11824
11870
|
createdBy,
|
|
11825
|
-
createdAt:
|
|
11826
|
-
expiresAt:
|
|
11871
|
+
createdAt: Timestamp18.now(),
|
|
11872
|
+
expiresAt: Timestamp18.fromDate(expiration)
|
|
11827
11873
|
};
|
|
11828
11874
|
practitionerTokenSchema.parse(token);
|
|
11829
11875
|
const tokenPath = `${PRACTITIONERS_COLLECTION}/${validatedData.practitionerId}/${REGISTER_TOKENS_COLLECTION}/${token.id}`;
|
|
@@ -11849,7 +11895,7 @@ var PractitionerService = class extends BaseService {
|
|
|
11849
11895
|
);
|
|
11850
11896
|
const conditions = [
|
|
11851
11897
|
where13("status", "==", "active" /* ACTIVE */),
|
|
11852
|
-
where13("expiresAt", ">",
|
|
11898
|
+
where13("expiresAt", ">", Timestamp18.now())
|
|
11853
11899
|
];
|
|
11854
11900
|
if (clinicId) {
|
|
11855
11901
|
conditions.push(where13("clinicId", "==", clinicId));
|
|
@@ -11876,14 +11922,14 @@ var PractitionerService = class extends BaseService {
|
|
|
11876
11922
|
`[PRACTITIONER] Validating token for practitioner ${practitionerId}`,
|
|
11877
11923
|
{
|
|
11878
11924
|
tokenString,
|
|
11879
|
-
timestamp:
|
|
11925
|
+
timestamp: Timestamp18.now().toDate()
|
|
11880
11926
|
}
|
|
11881
11927
|
);
|
|
11882
11928
|
const q = query13(
|
|
11883
11929
|
tokensRef,
|
|
11884
11930
|
where13("token", "==", tokenString),
|
|
11885
11931
|
where13("status", "==", "active" /* ACTIVE */),
|
|
11886
|
-
where13("expiresAt", ">",
|
|
11932
|
+
where13("expiresAt", ">", Timestamp18.now())
|
|
11887
11933
|
);
|
|
11888
11934
|
try {
|
|
11889
11935
|
const tokenSnapshot = await getDocs13(q);
|
|
@@ -11926,7 +11972,7 @@ var PractitionerService = class extends BaseService {
|
|
|
11926
11972
|
await updateDoc16(tokenRef, {
|
|
11927
11973
|
status: "used" /* USED */,
|
|
11928
11974
|
usedBy: userId,
|
|
11929
|
-
usedAt:
|
|
11975
|
+
usedAt: Timestamp18.now()
|
|
11930
11976
|
});
|
|
11931
11977
|
}
|
|
11932
11978
|
/**
|
|
@@ -13339,7 +13385,7 @@ var UserService = class extends BaseService {
|
|
|
13339
13385
|
email: "",
|
|
13340
13386
|
phoneNumber: "",
|
|
13341
13387
|
title: "",
|
|
13342
|
-
dateOfBirth:
|
|
13388
|
+
dateOfBirth: Timestamp19.now(),
|
|
13343
13389
|
gender: "other",
|
|
13344
13390
|
languages: ["Serbian"]
|
|
13345
13391
|
},
|
|
@@ -13348,7 +13394,7 @@ var UserService = class extends BaseService {
|
|
|
13348
13394
|
specialties: [],
|
|
13349
13395
|
licenseNumber: "",
|
|
13350
13396
|
issuingAuthority: "",
|
|
13351
|
-
issueDate:
|
|
13397
|
+
issueDate: Timestamp19.now(),
|
|
13352
13398
|
verificationStatus: "pending"
|
|
13353
13399
|
},
|
|
13354
13400
|
isActive: true,
|
|
@@ -13497,7 +13543,7 @@ var UserService = class extends BaseService {
|
|
|
13497
13543
|
}
|
|
13498
13544
|
const updateData = {
|
|
13499
13545
|
acquisitionSource: data.acquisitionSource,
|
|
13500
|
-
acquisitionSourceTimestamp:
|
|
13546
|
+
acquisitionSourceTimestamp: Timestamp19.now(),
|
|
13501
13547
|
updatedAt: serverTimestamp18()
|
|
13502
13548
|
};
|
|
13503
13549
|
if (data.acquisitionSource === "other" /* OTHER */) {
|
|
@@ -13685,7 +13731,7 @@ import {
|
|
|
13685
13731
|
where as where16,
|
|
13686
13732
|
updateDoc as updateDoc18,
|
|
13687
13733
|
setDoc as setDoc13,
|
|
13688
|
-
Timestamp as
|
|
13734
|
+
Timestamp as Timestamp20
|
|
13689
13735
|
} from "firebase/firestore";
|
|
13690
13736
|
import { geohashForLocation as geohashForLocation2 } from "geofire-common";
|
|
13691
13737
|
import { z as z19 } from "zod";
|
|
@@ -13809,7 +13855,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
|
|
|
13809
13855
|
throw geohashError;
|
|
13810
13856
|
}
|
|
13811
13857
|
}
|
|
13812
|
-
const now =
|
|
13858
|
+
const now = Timestamp20.now();
|
|
13813
13859
|
console.log("[CLINIC_GROUP] Preparing clinic group data object");
|
|
13814
13860
|
const groupId = doc22(collection16(db, CLINIC_GROUPS_COLLECTION)).id;
|
|
13815
13861
|
console.log("[CLINIC_GROUP] Logo value:", {
|
|
@@ -13948,7 +13994,7 @@ async function updateClinicGroup(db, groupId, data, app) {
|
|
|
13948
13994
|
}
|
|
13949
13995
|
updatedData = {
|
|
13950
13996
|
...updatedData,
|
|
13951
|
-
updatedAt:
|
|
13997
|
+
updatedAt: Timestamp20.now()
|
|
13952
13998
|
};
|
|
13953
13999
|
console.log("[CLINIC_GROUP] Updating clinic group in Firestore");
|
|
13954
14000
|
await updateDoc18(doc22(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
|
|
@@ -14032,10 +14078,10 @@ async function createAdminToken(db, groupId, creatorAdminId, app, data) {
|
|
|
14032
14078
|
if (!group.admins.includes(creatorAdminId)) {
|
|
14033
14079
|
throw new Error("Admin does not belong to this clinic group");
|
|
14034
14080
|
}
|
|
14035
|
-
const now =
|
|
14081
|
+
const now = Timestamp20.now();
|
|
14036
14082
|
const expiresInDays = (data == null ? void 0 : data.expiresInDays) || 7;
|
|
14037
14083
|
const email = (data == null ? void 0 : data.email) || null;
|
|
14038
|
-
const expiresAt = new
|
|
14084
|
+
const expiresAt = new Timestamp20(
|
|
14039
14085
|
now.seconds + expiresInDays * 24 * 60 * 60,
|
|
14040
14086
|
now.nanoseconds
|
|
14041
14087
|
);
|
|
@@ -14069,7 +14115,7 @@ async function verifyAndUseAdminToken(db, groupId, token, userRef, app) {
|
|
|
14069
14115
|
if (adminToken.status !== "active" /* ACTIVE */) {
|
|
14070
14116
|
throw new Error("Admin token is not active");
|
|
14071
14117
|
}
|
|
14072
|
-
const now =
|
|
14118
|
+
const now = Timestamp20.now();
|
|
14073
14119
|
if (adminToken.expiresAt.seconds < now.seconds) {
|
|
14074
14120
|
const updatedTokens2 = group.adminTokens.map(
|
|
14075
14121
|
(t) => t.id === adminToken.id ? { ...t, status: "expired" /* EXPIRED */ } : t
|
|
@@ -14358,7 +14404,7 @@ import {
|
|
|
14358
14404
|
where as where17,
|
|
14359
14405
|
updateDoc as updateDoc19,
|
|
14360
14406
|
setDoc as setDoc14,
|
|
14361
|
-
Timestamp as
|
|
14407
|
+
Timestamp as Timestamp21,
|
|
14362
14408
|
limit as limit9,
|
|
14363
14409
|
startAfter as startAfter8
|
|
14364
14410
|
} from "firebase/firestore";
|
|
@@ -14569,7 +14615,7 @@ async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app
|
|
|
14569
14615
|
}
|
|
14570
14616
|
updatedData = {
|
|
14571
14617
|
...updatedData,
|
|
14572
|
-
updatedAt:
|
|
14618
|
+
updatedAt: Timestamp21.now()
|
|
14573
14619
|
};
|
|
14574
14620
|
console.log("[CLINIC] Updating clinic in Firestore");
|
|
14575
14621
|
try {
|
|
@@ -16784,7 +16830,7 @@ var AuthService = class extends BaseService {
|
|
|
16784
16830
|
};
|
|
16785
16831
|
|
|
16786
16832
|
// src/services/calendar/calendar.v2.service.ts
|
|
16787
|
-
import { Timestamp as
|
|
16833
|
+
import { Timestamp as Timestamp30, serverTimestamp as serverTimestamp26 } from "firebase/firestore";
|
|
16788
16834
|
import {
|
|
16789
16835
|
doc as doc32,
|
|
16790
16836
|
getDoc as getDoc33,
|
|
@@ -16808,7 +16854,7 @@ import {
|
|
|
16808
16854
|
query as query22,
|
|
16809
16855
|
where as where22,
|
|
16810
16856
|
orderBy as orderBy8,
|
|
16811
|
-
Timestamp as
|
|
16857
|
+
Timestamp as Timestamp24,
|
|
16812
16858
|
serverTimestamp as serverTimestamp21
|
|
16813
16859
|
} from "firebase/firestore";
|
|
16814
16860
|
|
|
@@ -16864,8 +16910,8 @@ async function createClinicCalendarEventUtil(db, clinicId, eventData, generateId
|
|
|
16864
16910
|
await setDoc17(eventRef, newEvent);
|
|
16865
16911
|
return {
|
|
16866
16912
|
...newEvent,
|
|
16867
|
-
createdAt:
|
|
16868
|
-
updatedAt:
|
|
16913
|
+
createdAt: Timestamp24.now(),
|
|
16914
|
+
updatedAt: Timestamp24.now()
|
|
16869
16915
|
};
|
|
16870
16916
|
}
|
|
16871
16917
|
async function updateClinicCalendarEventUtil(db, clinicId, eventId, updateData) {
|
|
@@ -16912,7 +16958,7 @@ import {
|
|
|
16912
16958
|
query as query23,
|
|
16913
16959
|
where as where23,
|
|
16914
16960
|
orderBy as orderBy9,
|
|
16915
|
-
Timestamp as
|
|
16961
|
+
Timestamp as Timestamp25,
|
|
16916
16962
|
serverTimestamp as serverTimestamp22
|
|
16917
16963
|
} from "firebase/firestore";
|
|
16918
16964
|
async function createPatientCalendarEventUtil(db, patientId, eventData, generateId2) {
|
|
@@ -16927,8 +16973,8 @@ async function createPatientCalendarEventUtil(db, patientId, eventData, generate
|
|
|
16927
16973
|
await setDoc18(eventRef, newEvent);
|
|
16928
16974
|
return {
|
|
16929
16975
|
...newEvent,
|
|
16930
|
-
createdAt:
|
|
16931
|
-
updatedAt:
|
|
16976
|
+
createdAt: Timestamp25.now(),
|
|
16977
|
+
updatedAt: Timestamp25.now()
|
|
16932
16978
|
};
|
|
16933
16979
|
}
|
|
16934
16980
|
async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData) {
|
|
@@ -16956,7 +17002,7 @@ import {
|
|
|
16956
17002
|
query as query24,
|
|
16957
17003
|
where as where24,
|
|
16958
17004
|
orderBy as orderBy10,
|
|
16959
|
-
Timestamp as
|
|
17005
|
+
Timestamp as Timestamp26,
|
|
16960
17006
|
serverTimestamp as serverTimestamp23
|
|
16961
17007
|
} from "firebase/firestore";
|
|
16962
17008
|
async function createPractitionerCalendarEventUtil(db, practitionerId, eventData, generateId2) {
|
|
@@ -16975,8 +17021,8 @@ async function createPractitionerCalendarEventUtil(db, practitionerId, eventData
|
|
|
16975
17021
|
await setDoc19(eventRef, newEvent);
|
|
16976
17022
|
return {
|
|
16977
17023
|
...newEvent,
|
|
16978
|
-
createdAt:
|
|
16979
|
-
updatedAt:
|
|
17024
|
+
createdAt: Timestamp26.now(),
|
|
17025
|
+
updatedAt: Timestamp26.now()
|
|
16980
17026
|
};
|
|
16981
17027
|
}
|
|
16982
17028
|
async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId, updateData) {
|
|
@@ -17059,7 +17105,7 @@ import {
|
|
|
17059
17105
|
query as query25,
|
|
17060
17106
|
where as where25,
|
|
17061
17107
|
orderBy as orderBy11,
|
|
17062
|
-
Timestamp as
|
|
17108
|
+
Timestamp as Timestamp27,
|
|
17063
17109
|
serverTimestamp as serverTimestamp24
|
|
17064
17110
|
} from "firebase/firestore";
|
|
17065
17111
|
async function searchCalendarEventsUtil(db, params) {
|
|
@@ -17139,7 +17185,7 @@ async function searchCalendarEventsUtil(db, params) {
|
|
|
17139
17185
|
}
|
|
17140
17186
|
if (filters.dateRange) {
|
|
17141
17187
|
const MAX_EVENT_DURATION_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
17142
|
-
const extendedStart =
|
|
17188
|
+
const extendedStart = Timestamp27.fromMillis(
|
|
17143
17189
|
filters.dateRange.start.toMillis() - MAX_EVENT_DURATION_MS
|
|
17144
17190
|
);
|
|
17145
17191
|
constraints.push(where25("eventTime.start", ">=", extendedStart));
|
|
@@ -17186,7 +17232,7 @@ import {
|
|
|
17186
17232
|
deleteDoc as deleteDoc14,
|
|
17187
17233
|
query as query26,
|
|
17188
17234
|
orderBy as orderBy12,
|
|
17189
|
-
Timestamp as
|
|
17235
|
+
Timestamp as Timestamp28,
|
|
17190
17236
|
serverTimestamp as serverTimestamp25
|
|
17191
17237
|
} from "firebase/firestore";
|
|
17192
17238
|
async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendarData, generateId2) {
|
|
@@ -17205,8 +17251,8 @@ async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendar
|
|
|
17205
17251
|
await setDoc21(calendarRef, newCalendar);
|
|
17206
17252
|
return {
|
|
17207
17253
|
...newCalendar,
|
|
17208
|
-
createdAt:
|
|
17209
|
-
updatedAt:
|
|
17254
|
+
createdAt: Timestamp28.now(),
|
|
17255
|
+
updatedAt: Timestamp28.now()
|
|
17210
17256
|
};
|
|
17211
17257
|
}
|
|
17212
17258
|
async function createPatientSyncedCalendarUtil(db, patientId, calendarData, generateId2) {
|
|
@@ -17221,8 +17267,8 @@ async function createPatientSyncedCalendarUtil(db, patientId, calendarData, gene
|
|
|
17221
17267
|
await setDoc21(calendarRef, newCalendar);
|
|
17222
17268
|
return {
|
|
17223
17269
|
...newCalendar,
|
|
17224
|
-
createdAt:
|
|
17225
|
-
updatedAt:
|
|
17270
|
+
createdAt: Timestamp28.now(),
|
|
17271
|
+
updatedAt: Timestamp28.now()
|
|
17226
17272
|
};
|
|
17227
17273
|
}
|
|
17228
17274
|
async function createClinicSyncedCalendarUtil(db, clinicId, calendarData, generateId2) {
|
|
@@ -17237,8 +17283,8 @@ async function createClinicSyncedCalendarUtil(db, clinicId, calendarData, genera
|
|
|
17237
17283
|
await setDoc21(calendarRef, newCalendar);
|
|
17238
17284
|
return {
|
|
17239
17285
|
...newCalendar,
|
|
17240
|
-
createdAt:
|
|
17241
|
-
updatedAt:
|
|
17286
|
+
createdAt: Timestamp28.now(),
|
|
17287
|
+
updatedAt: Timestamp28.now()
|
|
17242
17288
|
};
|
|
17243
17289
|
}
|
|
17244
17290
|
async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId) {
|
|
@@ -17357,7 +17403,7 @@ async function deleteClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
|
17357
17403
|
}
|
|
17358
17404
|
async function updateLastSyncedTimestampUtil(db, entityType, entityId, calendarId) {
|
|
17359
17405
|
const updateData = {
|
|
17360
|
-
lastSyncedAt:
|
|
17406
|
+
lastSyncedAt: Timestamp28.now()
|
|
17361
17407
|
};
|
|
17362
17408
|
switch (entityType) {
|
|
17363
17409
|
case "practitioner":
|
|
@@ -17387,7 +17433,7 @@ async function updateLastSyncedTimestampUtil(db, entityType, entityId, calendarI
|
|
|
17387
17433
|
}
|
|
17388
17434
|
|
|
17389
17435
|
// src/services/calendar/utils/google-calendar.utils.ts
|
|
17390
|
-
import { Timestamp as
|
|
17436
|
+
import { Timestamp as Timestamp29 } from "firebase/firestore";
|
|
17391
17437
|
var GOOGLE_CALENDAR_API_URL = "https://www.googleapis.com/calendar/v3";
|
|
17392
17438
|
var GOOGLE_OAUTH_URL = "https://oauth2.googleapis.com/token";
|
|
17393
17439
|
var CLIENT_ID = "your-client-id";
|
|
@@ -17507,7 +17553,7 @@ async function ensureValidToken(db, entityType, entityId, syncedCalendar) {
|
|
|
17507
17553
|
tokenExpiry.setSeconds(tokenExpiry.getSeconds() + expiresIn);
|
|
17508
17554
|
const updateData = {
|
|
17509
17555
|
accessToken,
|
|
17510
|
-
tokenExpiry:
|
|
17556
|
+
tokenExpiry: Timestamp29.fromDate(tokenExpiry)
|
|
17511
17557
|
};
|
|
17512
17558
|
switch (entityType) {
|
|
17513
17559
|
case "practitioner":
|
|
@@ -17682,8 +17728,8 @@ function convertGoogleEventToCalendarEventUtil(googleEvent, entityId, entityType
|
|
|
17682
17728
|
eventName: googleEvent.summary || "External Event",
|
|
17683
17729
|
eventLocation: googleEvent.location,
|
|
17684
17730
|
eventTime: {
|
|
17685
|
-
start:
|
|
17686
|
-
end:
|
|
17731
|
+
start: Timestamp29.fromDate(start),
|
|
17732
|
+
end: Timestamp29.fromDate(end)
|
|
17687
17733
|
},
|
|
17688
17734
|
description: googleEvent.description || "",
|
|
17689
17735
|
// External events are always set as CONFIRMED - status updates will happen externally
|
|
@@ -17697,7 +17743,7 @@ function convertGoogleEventToCalendarEventUtil(googleEvent, entityId, entityType
|
|
|
17697
17743
|
{
|
|
17698
17744
|
eventId: googleEvent.id,
|
|
17699
17745
|
syncedCalendarProvider: "google" /* GOOGLE */,
|
|
17700
|
-
syncedAt:
|
|
17746
|
+
syncedAt: Timestamp29.now()
|
|
17701
17747
|
}
|
|
17702
17748
|
]
|
|
17703
17749
|
};
|
|
@@ -18475,7 +18521,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18475
18521
|
return 0;
|
|
18476
18522
|
}
|
|
18477
18523
|
let importedEventsCount = 0;
|
|
18478
|
-
const currentTime =
|
|
18524
|
+
const currentTime = Timestamp30.now();
|
|
18479
18525
|
for (const calendar of activeCalendars) {
|
|
18480
18526
|
try {
|
|
18481
18527
|
let externalEvents = [];
|
|
@@ -18558,8 +18604,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18558
18604
|
await setDoc22(eventRef, newEvent);
|
|
18559
18605
|
return {
|
|
18560
18606
|
...newEvent,
|
|
18561
|
-
createdAt:
|
|
18562
|
-
updatedAt:
|
|
18607
|
+
createdAt: Timestamp30.now(),
|
|
18608
|
+
updatedAt: Timestamp30.now()
|
|
18563
18609
|
};
|
|
18564
18610
|
} catch (error) {
|
|
18565
18611
|
console.error(
|
|
@@ -18645,8 +18691,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18645
18691
|
const q = query27(
|
|
18646
18692
|
eventsRef,
|
|
18647
18693
|
where27("syncStatus", "==", "external" /* EXTERNAL */),
|
|
18648
|
-
where27("eventTime.start", ">=",
|
|
18649
|
-
where27("eventTime.start", "<=",
|
|
18694
|
+
where27("eventTime.start", ">=", Timestamp30.fromDate(startDate)),
|
|
18695
|
+
where27("eventTime.start", "<=", Timestamp30.fromDate(endDate))
|
|
18650
18696
|
);
|
|
18651
18697
|
const eventsSnapshot = await getDocs27(q);
|
|
18652
18698
|
const events = eventsSnapshot.docs.map((doc47) => ({
|
|
@@ -18765,8 +18811,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18765
18811
|
await updateDoc27(eventRef, {
|
|
18766
18812
|
eventName: externalEvent.summary || "External Event",
|
|
18767
18813
|
eventTime: {
|
|
18768
|
-
start:
|
|
18769
|
-
end:
|
|
18814
|
+
start: Timestamp30.fromDate(startTime),
|
|
18815
|
+
end: Timestamp30.fromDate(endTime)
|
|
18770
18816
|
},
|
|
18771
18817
|
description: externalEvent.description || "",
|
|
18772
18818
|
updatedAt: serverTimestamp26()
|
|
@@ -18844,8 +18890,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18844
18890
|
*/
|
|
18845
18891
|
async getPractitionerUpcomingAppointments(doctorId, startDate, endDate, status = "confirmed" /* CONFIRMED */) {
|
|
18846
18892
|
const dateRange = {
|
|
18847
|
-
start:
|
|
18848
|
-
end:
|
|
18893
|
+
start: Timestamp30.fromDate(startDate),
|
|
18894
|
+
end: Timestamp30.fromDate(endDate)
|
|
18849
18895
|
};
|
|
18850
18896
|
const searchParams = {
|
|
18851
18897
|
searchLocation: "practitioner" /* PRACTITIONER */,
|
|
@@ -18867,8 +18913,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18867
18913
|
*/
|
|
18868
18914
|
async getPatientAppointments(patientId, startDate, endDate, status) {
|
|
18869
18915
|
const dateRange = {
|
|
18870
|
-
start:
|
|
18871
|
-
end:
|
|
18916
|
+
start: Timestamp30.fromDate(startDate),
|
|
18917
|
+
end: Timestamp30.fromDate(endDate)
|
|
18872
18918
|
};
|
|
18873
18919
|
const searchParams = {
|
|
18874
18920
|
searchLocation: "patient" /* PATIENT */,
|
|
@@ -18893,8 +18939,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18893
18939
|
*/
|
|
18894
18940
|
async getClinicAppointments(clinicId, startDate, endDate, doctorId, status) {
|
|
18895
18941
|
const dateRange = {
|
|
18896
|
-
start:
|
|
18897
|
-
end:
|
|
18942
|
+
start: Timestamp30.fromDate(startDate),
|
|
18943
|
+
end: Timestamp30.fromDate(endDate)
|
|
18898
18944
|
};
|
|
18899
18945
|
const searchParams = {
|
|
18900
18946
|
searchLocation: "clinic" /* CLINIC */,
|
|
@@ -19158,7 +19204,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
19158
19204
|
const newSyncEvent = {
|
|
19159
19205
|
eventId: result.eventIds[0],
|
|
19160
19206
|
syncedCalendarProvider: calendar.provider,
|
|
19161
|
-
syncedAt:
|
|
19207
|
+
syncedAt: Timestamp30.now()
|
|
19162
19208
|
};
|
|
19163
19209
|
await this.updateEventWithSyncId(
|
|
19164
19210
|
entityType === "doctor" ? appointment.practitionerProfileId : appointment.patientProfileId,
|
|
@@ -19287,8 +19333,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
19287
19333
|
const q = query27(
|
|
19288
19334
|
appointmentsRef,
|
|
19289
19335
|
where27("practitionerProfileId", "==", doctorId),
|
|
19290
|
-
where27("eventTime.start", ">=",
|
|
19291
|
-
where27("eventTime.start", "<=",
|
|
19336
|
+
where27("eventTime.start", ">=", Timestamp30.fromDate(startOfDay)),
|
|
19337
|
+
where27("eventTime.start", "<=", Timestamp30.fromDate(endOfDay)),
|
|
19292
19338
|
where27("status", "in", [
|
|
19293
19339
|
"confirmed" /* CONFIRMED */,
|
|
19294
19340
|
"pending" /* PENDING */
|
|
@@ -19389,7 +19435,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
19389
19435
|
fullName: `${sensitiveData.firstName} ${sensitiveData.lastName}`,
|
|
19390
19436
|
email: sensitiveData.email || "",
|
|
19391
19437
|
phone: sensitiveData.phoneNumber || null,
|
|
19392
|
-
dateOfBirth: sensitiveData.dateOfBirth ||
|
|
19438
|
+
dateOfBirth: sensitiveData.dateOfBirth || Timestamp30.now(),
|
|
19393
19439
|
gender: sensitiveData.gender || "other" /* OTHER */
|
|
19394
19440
|
};
|
|
19395
19441
|
} else if (patientDoc.exists()) {
|
|
@@ -19398,7 +19444,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
19398
19444
|
fullName: patientDoc.data().displayName,
|
|
19399
19445
|
email: ((_a = patientDoc.data().contactInfo) == null ? void 0 : _a.email) || "",
|
|
19400
19446
|
phone: patientDoc.data().phoneNumber || null,
|
|
19401
|
-
dateOfBirth: patientDoc.data().dateOfBirth ||
|
|
19447
|
+
dateOfBirth: patientDoc.data().dateOfBirth || Timestamp30.now(),
|
|
19402
19448
|
gender: patientDoc.data().gender || "other" /* OTHER */
|
|
19403
19449
|
};
|
|
19404
19450
|
}
|
|
@@ -19420,7 +19466,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
19420
19466
|
};
|
|
19421
19467
|
|
|
19422
19468
|
// src/services/calendar/calendar.v3.service.ts
|
|
19423
|
-
import { Timestamp as
|
|
19469
|
+
import { Timestamp as Timestamp31, serverTimestamp as serverTimestamp27 } from "firebase/firestore";
|
|
19424
19470
|
import { doc as doc33, getDoc as getDoc34, setDoc as setDoc23, updateDoc as updateDoc28, deleteDoc as deleteDoc15 } from "firebase/firestore";
|
|
19425
19471
|
var CalendarServiceV3 = class extends BaseService {
|
|
19426
19472
|
/**
|
|
@@ -19466,8 +19512,8 @@ var CalendarServiceV3 = class extends BaseService {
|
|
|
19466
19512
|
await setDoc23(eventRef, eventData);
|
|
19467
19513
|
return {
|
|
19468
19514
|
...eventData,
|
|
19469
|
-
createdAt:
|
|
19470
|
-
updatedAt:
|
|
19515
|
+
createdAt: Timestamp31.now(),
|
|
19516
|
+
updatedAt: Timestamp31.now()
|
|
19471
19517
|
};
|
|
19472
19518
|
}
|
|
19473
19519
|
/**
|
|
@@ -19732,7 +19778,7 @@ import {
|
|
|
19732
19778
|
updateDoc as updateDoc29,
|
|
19733
19779
|
setDoc as setDoc24,
|
|
19734
19780
|
deleteDoc as deleteDoc16,
|
|
19735
|
-
Timestamp as
|
|
19781
|
+
Timestamp as Timestamp32,
|
|
19736
19782
|
serverTimestamp as serverTimestamp28,
|
|
19737
19783
|
orderBy as orderBy13,
|
|
19738
19784
|
limit as limit12
|
|
@@ -19798,7 +19844,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
19798
19844
|
message: message || null,
|
|
19799
19845
|
status: "pending" /* PENDING */
|
|
19800
19846
|
};
|
|
19801
|
-
const now =
|
|
19847
|
+
const now = Timestamp32.now();
|
|
19802
19848
|
const invite = {
|
|
19803
19849
|
id: inviteId,
|
|
19804
19850
|
...inviteData,
|
|
@@ -19894,7 +19940,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
19894
19940
|
}
|
|
19895
19941
|
const updateData = {
|
|
19896
19942
|
status: "accepted" /* ACCEPTED */,
|
|
19897
|
-
acceptedAt:
|
|
19943
|
+
acceptedAt: Timestamp32.now(),
|
|
19898
19944
|
updatedAt: serverTimestamp28()
|
|
19899
19945
|
};
|
|
19900
19946
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
@@ -19926,7 +19972,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
19926
19972
|
const updateData = {
|
|
19927
19973
|
status: "rejected" /* REJECTED */,
|
|
19928
19974
|
rejectionReason: rejectionReason || null,
|
|
19929
|
-
rejectedAt:
|
|
19975
|
+
rejectedAt: Timestamp32.now(),
|
|
19930
19976
|
updatedAt: serverTimestamp28()
|
|
19931
19977
|
};
|
|
19932
19978
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
@@ -19958,7 +20004,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
19958
20004
|
const updateData = {
|
|
19959
20005
|
status: "cancelled" /* CANCELLED */,
|
|
19960
20006
|
cancelReason: cancelReason || null,
|
|
19961
|
-
cancelledAt:
|
|
20007
|
+
cancelledAt: Timestamp32.now(),
|
|
19962
20008
|
updatedAt: serverTimestamp28()
|
|
19963
20009
|
};
|
|
19964
20010
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
@@ -20875,7 +20921,7 @@ import {
|
|
|
20875
20921
|
updateDoc as updateDoc32,
|
|
20876
20922
|
deleteDoc as deleteDoc18,
|
|
20877
20923
|
orderBy as orderBy16,
|
|
20878
|
-
Timestamp as
|
|
20924
|
+
Timestamp as Timestamp34,
|
|
20879
20925
|
addDoc as addDoc3,
|
|
20880
20926
|
writeBatch as writeBatch5
|
|
20881
20927
|
} from "firebase/firestore";
|
|
@@ -20885,7 +20931,7 @@ var NotificationService = class extends BaseService {
|
|
|
20885
20931
|
*/
|
|
20886
20932
|
async createNotification(notification) {
|
|
20887
20933
|
const notificationsRef = collection31(this.db, NOTIFICATIONS_COLLECTION);
|
|
20888
|
-
const now =
|
|
20934
|
+
const now = Timestamp34.now();
|
|
20889
20935
|
const notificationData = {
|
|
20890
20936
|
...notification,
|
|
20891
20937
|
createdAt: now,
|
|
@@ -20960,7 +21006,7 @@ var NotificationService = class extends BaseService {
|
|
|
20960
21006
|
);
|
|
20961
21007
|
await updateDoc32(notificationRef, {
|
|
20962
21008
|
isRead: true,
|
|
20963
|
-
updatedAt:
|
|
21009
|
+
updatedAt: Timestamp34.now()
|
|
20964
21010
|
});
|
|
20965
21011
|
}
|
|
20966
21012
|
/**
|
|
@@ -20977,7 +21023,7 @@ var NotificationService = class extends BaseService {
|
|
|
20977
21023
|
);
|
|
20978
21024
|
batch.update(notificationRef, {
|
|
20979
21025
|
isRead: true,
|
|
20980
|
-
updatedAt:
|
|
21026
|
+
updatedAt: Timestamp34.now()
|
|
20981
21027
|
});
|
|
20982
21028
|
});
|
|
20983
21029
|
await batch.commit();
|
|
@@ -20993,7 +21039,7 @@ var NotificationService = class extends BaseService {
|
|
|
20993
21039
|
);
|
|
20994
21040
|
await updateDoc32(notificationRef, {
|
|
20995
21041
|
status,
|
|
20996
|
-
updatedAt:
|
|
21042
|
+
updatedAt: Timestamp34.now()
|
|
20997
21043
|
});
|
|
20998
21044
|
}
|
|
20999
21045
|
/**
|
|
@@ -21048,7 +21094,7 @@ import {
|
|
|
21048
21094
|
where as where32,
|
|
21049
21095
|
doc as doc38,
|
|
21050
21096
|
updateDoc as updateDoc33,
|
|
21051
|
-
Timestamp as
|
|
21097
|
+
Timestamp as Timestamp35,
|
|
21052
21098
|
orderBy as orderBy17,
|
|
21053
21099
|
limit as limit15,
|
|
21054
21100
|
startAfter as startAfter13,
|
|
@@ -21183,7 +21229,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
21183
21229
|
`Instruction ${instructionId} is in status ${instructionToUpdate.status} and cannot be marked as completed.`
|
|
21184
21230
|
);
|
|
21185
21231
|
}
|
|
21186
|
-
const now =
|
|
21232
|
+
const now = Timestamp35.now();
|
|
21187
21233
|
const updatedInstructions = [...instance.instructions];
|
|
21188
21234
|
updatedInstructions[instructionIndex] = {
|
|
21189
21235
|
...instructionToUpdate,
|