@blackcode_sa/metaestetics-api 1.14.50 → 1.14.51
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/index.js
CHANGED
|
@@ -5019,6 +5019,7 @@ async function initializeFormsForExtendedProcedure(db, appointmentId, procedureI
|
|
|
5019
5019
|
try {
|
|
5020
5020
|
const docRef = await (0, import_firestore9.addDoc)(formsCollectionRef, filledDocumentData);
|
|
5021
5021
|
const filledDocumentId = docRef.id;
|
|
5022
|
+
await (0, import_firestore9.updateDoc)(docRef, { id: filledDocumentId });
|
|
5022
5023
|
if (isUserForm && isRequired) {
|
|
5023
5024
|
pendingUserFormsIds.push(filledDocumentId);
|
|
5024
5025
|
}
|
|
@@ -20471,7 +20472,11 @@ var FilledDocumentService = class extends BaseService {
|
|
|
20471
20472
|
if (!docSnap.exists()) {
|
|
20472
20473
|
return null;
|
|
20473
20474
|
}
|
|
20474
|
-
|
|
20475
|
+
const data = docSnap.data();
|
|
20476
|
+
if (!data.id) {
|
|
20477
|
+
data.id = docSnap.id;
|
|
20478
|
+
}
|
|
20479
|
+
return data;
|
|
20475
20480
|
}
|
|
20476
20481
|
/**
|
|
20477
20482
|
* Update values or status in a filled document within an appointment's subcollection.
|
|
@@ -20572,9 +20577,13 @@ var FilledDocumentService = class extends BaseService {
|
|
|
20572
20577
|
const querySnapshot = await (0, import_firestore55.getDocs)(q);
|
|
20573
20578
|
const documents = [];
|
|
20574
20579
|
let lastVisible = null;
|
|
20575
|
-
querySnapshot.forEach((
|
|
20576
|
-
|
|
20577
|
-
|
|
20580
|
+
querySnapshot.forEach((docSnapshot) => {
|
|
20581
|
+
const data = docSnapshot.data();
|
|
20582
|
+
if (!data.id) {
|
|
20583
|
+
data.id = docSnapshot.id;
|
|
20584
|
+
}
|
|
20585
|
+
documents.push(data);
|
|
20586
|
+
lastVisible = docSnapshot;
|
|
20578
20587
|
});
|
|
20579
20588
|
return {
|
|
20580
20589
|
documents,
|
package/dist/index.mjs
CHANGED
|
@@ -4839,10 +4839,10 @@ async function updateSubzonesUtil(db, appointmentId, zoneId, itemIndex, subzones
|
|
|
4839
4839
|
}
|
|
4840
4840
|
|
|
4841
4841
|
// src/services/appointment/utils/extended-procedure.utils.ts
|
|
4842
|
-
import { updateDoc as
|
|
4842
|
+
import { updateDoc as updateDoc5, serverTimestamp as serverTimestamp4, doc as doc7, getDoc as getDoc7 } from "firebase/firestore";
|
|
4843
4843
|
|
|
4844
4844
|
// src/services/appointment/utils/form-initialization.utils.ts
|
|
4845
|
-
import { collection as collection5, doc as doc6, addDoc, deleteDoc as deleteDoc2, getDocs as getDocs5, query as query5, where as where5, serverTimestamp as serverTimestamp3, getDoc as getDoc6 } from "firebase/firestore";
|
|
4845
|
+
import { collection as collection5, doc as doc6, addDoc, deleteDoc as deleteDoc2, getDocs as getDocs5, query as query5, where as where5, serverTimestamp as serverTimestamp3, getDoc as getDoc6, updateDoc as updateDoc4 } from "firebase/firestore";
|
|
4846
4846
|
async function initializeFormsForExtendedProcedure(db, appointmentId, procedureId, technologyTemplates, patientId, practitionerId, clinicId) {
|
|
4847
4847
|
const initializedFormsInfo = [];
|
|
4848
4848
|
const pendingUserFormsIds = [];
|
|
@@ -4905,6 +4905,7 @@ async function initializeFormsForExtendedProcedure(db, appointmentId, procedureI
|
|
|
4905
4905
|
try {
|
|
4906
4906
|
const docRef = await addDoc(formsCollectionRef, filledDocumentData);
|
|
4907
4907
|
const filledDocumentId = docRef.id;
|
|
4908
|
+
await updateDoc4(docRef, { id: filledDocumentId });
|
|
4908
4909
|
if (isUserForm && isRequired) {
|
|
4909
4910
|
pendingUserFormsIds.push(filledDocumentId);
|
|
4910
4911
|
}
|
|
@@ -5095,7 +5096,7 @@ async function addExtendedProcedureUtil(db, appointmentId, procedureId) {
|
|
|
5095
5096
|
}
|
|
5096
5097
|
const extendedProcedures = [...metadata.extendedProcedures || [], extendedProcedureInfo];
|
|
5097
5098
|
const appointmentRef = doc7(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5098
|
-
await
|
|
5099
|
+
await updateDoc5(appointmentRef, {
|
|
5099
5100
|
"metadata.extendedProcedures": extendedProcedures,
|
|
5100
5101
|
"metadata.appointmentProducts": updatedProducts,
|
|
5101
5102
|
linkedFormIds: updatedLinkedFormIds,
|
|
@@ -5144,7 +5145,7 @@ async function removeExtendedProcedureUtil(db, appointmentId, procedureId) {
|
|
|
5144
5145
|
(formId) => !removedFormIds.includes(formId)
|
|
5145
5146
|
);
|
|
5146
5147
|
const appointmentRef = doc7(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5147
|
-
await
|
|
5148
|
+
await updateDoc5(appointmentRef, {
|
|
5148
5149
|
"metadata.extendedProcedures": metadata.extendedProcedures,
|
|
5149
5150
|
"metadata.appointmentProducts": updatedProducts,
|
|
5150
5151
|
"metadata.zonesData": updatedZonesData,
|
|
@@ -5167,7 +5168,7 @@ async function getAppointmentProductsUtil(db, appointmentId) {
|
|
|
5167
5168
|
}
|
|
5168
5169
|
|
|
5169
5170
|
// src/services/appointment/utils/recommended-procedure.utils.ts
|
|
5170
|
-
import { updateDoc as
|
|
5171
|
+
import { updateDoc as updateDoc6, serverTimestamp as serverTimestamp5, doc as doc8 } from "firebase/firestore";
|
|
5171
5172
|
import { getDoc as getDoc8 } from "firebase/firestore";
|
|
5172
5173
|
async function createExtendedProcedureInfoForRecommended(db, procedureId) {
|
|
5173
5174
|
const procedureRef = doc8(db, PROCEDURES_COLLECTION, procedureId);
|
|
@@ -5205,7 +5206,7 @@ async function addRecommendedProcedureUtil(db, appointmentId, procedureId, note,
|
|
|
5205
5206
|
};
|
|
5206
5207
|
const recommendedProcedures = [...metadata.recommendedProcedures || [], recommendedProcedure];
|
|
5207
5208
|
const appointmentRef = doc8(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5208
|
-
await
|
|
5209
|
+
await updateDoc6(appointmentRef, {
|
|
5209
5210
|
"metadata.recommendedProcedures": recommendedProcedures,
|
|
5210
5211
|
updatedAt: serverTimestamp5()
|
|
5211
5212
|
});
|
|
@@ -5223,7 +5224,7 @@ async function removeRecommendedProcedureUtil(db, appointmentId, recommendationI
|
|
|
5223
5224
|
const updatedRecommendedProcedures = [...metadata.recommendedProcedures];
|
|
5224
5225
|
updatedRecommendedProcedures.splice(recommendationIndex, 1);
|
|
5225
5226
|
const appointmentRef = doc8(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5226
|
-
await
|
|
5227
|
+
await updateDoc6(appointmentRef, {
|
|
5227
5228
|
"metadata.recommendedProcedures": updatedRecommendedProcedures,
|
|
5228
5229
|
updatedAt: serverTimestamp5()
|
|
5229
5230
|
});
|
|
@@ -5246,7 +5247,7 @@ async function updateRecommendedProcedureUtil(db, appointmentId, recommendationI
|
|
|
5246
5247
|
...updates.timeframe !== void 0 && { timeframe: updates.timeframe }
|
|
5247
5248
|
};
|
|
5248
5249
|
const appointmentRef = doc8(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5249
|
-
await
|
|
5250
|
+
await updateDoc6(appointmentRef, {
|
|
5250
5251
|
"metadata.recommendedProcedures": updatedRecommendedProcedures,
|
|
5251
5252
|
updatedAt: serverTimestamp5()
|
|
5252
5253
|
});
|
|
@@ -5259,7 +5260,7 @@ async function getRecommendedProceduresUtil(db, appointmentId) {
|
|
|
5259
5260
|
}
|
|
5260
5261
|
|
|
5261
5262
|
// src/services/appointment/utils/zone-photo.utils.ts
|
|
5262
|
-
import { updateDoc as
|
|
5263
|
+
import { updateDoc as updateDoc7, serverTimestamp as serverTimestamp6, doc as doc9, Timestamp as Timestamp6 } from "firebase/firestore";
|
|
5263
5264
|
function addVisibilityAudit(updates, doctorId) {
|
|
5264
5265
|
if (updates.showToPatient !== void 0 || updates.beforeNoteVisibleToPatient !== void 0 || updates.afterNoteVisibleToPatient !== void 0) {
|
|
5265
5266
|
return {
|
|
@@ -5290,7 +5291,7 @@ async function updateZonePhotoEntryUtil(db, appointmentId, zoneId, photoIndex, u
|
|
|
5290
5291
|
...updatesWithAudit
|
|
5291
5292
|
};
|
|
5292
5293
|
const appointmentRef = doc9(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5293
|
-
await
|
|
5294
|
+
await updateDoc7(appointmentRef, {
|
|
5294
5295
|
"metadata.zonePhotos": updatedZonePhotos,
|
|
5295
5296
|
updatedAt: serverTimestamp6()
|
|
5296
5297
|
});
|
|
@@ -7758,7 +7759,7 @@ import {
|
|
|
7758
7759
|
getDocs as getDocs14,
|
|
7759
7760
|
query as query14,
|
|
7760
7761
|
where as where14,
|
|
7761
|
-
updateDoc as
|
|
7762
|
+
updateDoc as updateDoc18,
|
|
7762
7763
|
deleteDoc as deleteDoc5,
|
|
7763
7764
|
Timestamp as Timestamp19,
|
|
7764
7765
|
setDoc as setDoc12,
|
|
@@ -7865,7 +7866,7 @@ import {
|
|
|
7865
7866
|
doc as doc19,
|
|
7866
7867
|
getDoc as getDoc21,
|
|
7867
7868
|
writeBatch,
|
|
7868
|
-
updateDoc as
|
|
7869
|
+
updateDoc as updateDoc16,
|
|
7869
7870
|
serverTimestamp as serverTimestamp16
|
|
7870
7871
|
} from "firebase/firestore";
|
|
7871
7872
|
import { Timestamp as Timestamp16 } from "firebase/firestore";
|
|
@@ -7893,7 +7894,7 @@ import {
|
|
|
7893
7894
|
} from "firebase/firestore";
|
|
7894
7895
|
|
|
7895
7896
|
// src/services/patient/utils/sensitive.utils.ts
|
|
7896
|
-
import { getDoc as getDoc12, updateDoc as
|
|
7897
|
+
import { getDoc as getDoc12, updateDoc as updateDoc9, setDoc as setDoc4, serverTimestamp as serverTimestamp9 } from "firebase/firestore";
|
|
7897
7898
|
|
|
7898
7899
|
// src/validations/patient.schema.ts
|
|
7899
7900
|
import { z as z7 } from "zod";
|
|
@@ -8363,7 +8364,7 @@ import {
|
|
|
8363
8364
|
getDocs as getDocs8,
|
|
8364
8365
|
query as query8,
|
|
8365
8366
|
where as where8,
|
|
8366
|
-
updateDoc as
|
|
8367
|
+
updateDoc as updateDoc8,
|
|
8367
8368
|
setDoc as setDoc3,
|
|
8368
8369
|
deleteDoc as deleteDoc3,
|
|
8369
8370
|
Timestamp as Timestamp11,
|
|
@@ -9098,7 +9099,7 @@ async function updateClinicAdmin(db, adminId, data) {
|
|
|
9098
9099
|
...data,
|
|
9099
9100
|
updatedAt: serverTimestamp8()
|
|
9100
9101
|
};
|
|
9101
|
-
await
|
|
9102
|
+
await updateDoc8(doc12(db, CLINIC_ADMINS_COLLECTION, adminId), updatedData);
|
|
9102
9103
|
const updatedAdmin = await getClinicAdmin(db, adminId);
|
|
9103
9104
|
if (!updatedAdmin) {
|
|
9104
9105
|
throw new Error("Failed to retrieve updated admin");
|
|
@@ -9340,7 +9341,7 @@ var updateSensitiveInfoUtil = async (db, patientId, data, requesterId, requester
|
|
|
9340
9341
|
photoUrl: processedPhotoUrl,
|
|
9341
9342
|
updatedAt: serverTimestamp9()
|
|
9342
9343
|
};
|
|
9343
|
-
await
|
|
9344
|
+
await updateDoc9(getSensitiveInfoDocRef(db, patientId), updateData);
|
|
9344
9345
|
const updatedDoc = await getDoc12(getSensitiveInfoDocRef(db, patientId));
|
|
9345
9346
|
if (!updatedDoc.exists()) {
|
|
9346
9347
|
throw new Error("Failed to retrieve updated sensitive information");
|
|
@@ -9367,7 +9368,7 @@ var claimPatientSensitiveInfoUtil = async (db, patientId, userId) => {
|
|
|
9367
9368
|
if (sensitiveData.userRef) {
|
|
9368
9369
|
throw new Error("Patient sensitive information has already been claimed");
|
|
9369
9370
|
}
|
|
9370
|
-
await
|
|
9371
|
+
await updateDoc9(getSensitiveInfoDocRef(db, patientId), {
|
|
9371
9372
|
userRef: userId,
|
|
9372
9373
|
updatedAt: serverTimestamp9()
|
|
9373
9374
|
});
|
|
@@ -9565,7 +9566,7 @@ var getPatientsByClinicWithDetailsUtil = async (db, clinicId, options) => {
|
|
|
9565
9566
|
// src/services/patient/utils/location.utils.ts
|
|
9566
9567
|
import {
|
|
9567
9568
|
getDoc as getDoc15,
|
|
9568
|
-
updateDoc as
|
|
9569
|
+
updateDoc as updateDoc10,
|
|
9569
9570
|
setDoc as setDoc6,
|
|
9570
9571
|
serverTimestamp as serverTimestamp11
|
|
9571
9572
|
} from "firebase/firestore";
|
|
@@ -9581,7 +9582,7 @@ var updatePatientLocationUtil = async (db, patientId, latitude, longitude) => {
|
|
|
9581
9582
|
locationData,
|
|
9582
9583
|
updatedAt: serverTimestamp11()
|
|
9583
9584
|
};
|
|
9584
|
-
await
|
|
9585
|
+
await updateDoc10(getLocationInfoDocRef(db, patientId), updateData);
|
|
9585
9586
|
};
|
|
9586
9587
|
var createLocationInfoUtil = async (db, data, requesterId) => {
|
|
9587
9588
|
try {
|
|
@@ -9636,7 +9637,7 @@ var updateLocationInfoUtil = async (db, patientId, data, requesterId) => {
|
|
|
9636
9637
|
};
|
|
9637
9638
|
}
|
|
9638
9639
|
updateData.updatedAt = serverTimestamp11();
|
|
9639
|
-
await
|
|
9640
|
+
await updateDoc10(getLocationInfoDocRef(db, patientId), updateData);
|
|
9640
9641
|
const updatedInfo = await getLocationInfoUtil(db, patientId, requesterId);
|
|
9641
9642
|
if (!updatedInfo) {
|
|
9642
9643
|
throw new Error("Failed to retrieve updated location information");
|
|
@@ -9647,7 +9648,7 @@ var updateLocationInfoUtil = async (db, patientId, data, requesterId) => {
|
|
|
9647
9648
|
// src/services/patient/utils/medical-stuff.utils.ts
|
|
9648
9649
|
import {
|
|
9649
9650
|
getDoc as getDoc16,
|
|
9650
|
-
updateDoc as
|
|
9651
|
+
updateDoc as updateDoc11,
|
|
9651
9652
|
arrayUnion as arrayUnion2,
|
|
9652
9653
|
arrayRemove as arrayRemove2,
|
|
9653
9654
|
serverTimestamp as serverTimestamp12,
|
|
@@ -9683,7 +9684,7 @@ var addDoctorUtil = async (db, patientId, doctorRef, assignedBy) => {
|
|
|
9683
9684
|
} else {
|
|
9684
9685
|
updates.doctors = arrayUnion2(newDoctor);
|
|
9685
9686
|
}
|
|
9686
|
-
await
|
|
9687
|
+
await updateDoc11(getPatientDocRef(db, patientId), updates);
|
|
9687
9688
|
};
|
|
9688
9689
|
var removeDoctorUtil = async (db, patientId, doctorRef) => {
|
|
9689
9690
|
var _a;
|
|
@@ -9692,7 +9693,7 @@ var removeDoctorUtil = async (db, patientId, doctorRef) => {
|
|
|
9692
9693
|
if (!patientDoc.exists()) throw new Error("Patient profile not found");
|
|
9693
9694
|
const patientData = patientDoc.data();
|
|
9694
9695
|
const updatedDoctors = ((_a = patientData.doctors) == null ? void 0 : _a.filter((doctor) => doctor.userRef !== doctorRef)) || [];
|
|
9695
|
-
await
|
|
9696
|
+
await updateDoc11(patientDocRef, {
|
|
9696
9697
|
doctors: updatedDoctors,
|
|
9697
9698
|
// Set the filtered array
|
|
9698
9699
|
doctorIds: arrayRemove2(doctorRef),
|
|
@@ -9730,7 +9731,7 @@ var addClinicUtil = async (db, patientId, clinicId, assignedBy) => {
|
|
|
9730
9731
|
} else {
|
|
9731
9732
|
updates.clinics = arrayUnion2(newClinic);
|
|
9732
9733
|
}
|
|
9733
|
-
await
|
|
9734
|
+
await updateDoc11(getPatientDocRef(db, patientId), updates);
|
|
9734
9735
|
};
|
|
9735
9736
|
var removeClinicUtil = async (db, patientId, clinicId) => {
|
|
9736
9737
|
var _a;
|
|
@@ -9739,7 +9740,7 @@ var removeClinicUtil = async (db, patientId, clinicId) => {
|
|
|
9739
9740
|
if (!patientDoc.exists()) throw new Error("Patient profile not found");
|
|
9740
9741
|
const patientData = patientDoc.data();
|
|
9741
9742
|
const updatedClinics = ((_a = patientData.clinics) == null ? void 0 : _a.filter((clinic) => clinic.clinicId !== clinicId)) || [];
|
|
9742
|
-
await
|
|
9743
|
+
await updateDoc11(patientDocRef, {
|
|
9743
9744
|
clinics: updatedClinics,
|
|
9744
9745
|
// Set the filtered array
|
|
9745
9746
|
clinicIds: arrayRemove2(clinicId),
|
|
@@ -9751,7 +9752,7 @@ var removeClinicUtil = async (db, patientId, clinicId) => {
|
|
|
9751
9752
|
// src/services/patient/utils/medical.utils.ts
|
|
9752
9753
|
import {
|
|
9753
9754
|
getDoc as getDoc17,
|
|
9754
|
-
updateDoc as
|
|
9755
|
+
updateDoc as updateDoc12,
|
|
9755
9756
|
setDoc as setDoc7,
|
|
9756
9757
|
serverTimestamp as serverTimestamp13,
|
|
9757
9758
|
arrayUnion as arrayUnion3
|
|
@@ -9834,7 +9835,7 @@ var updateVitalStatsUtil = async (db, patientId, data, requesterId, requesterRol
|
|
|
9834
9835
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
9835
9836
|
await ensureMedicalInfoExists(db, patientId, requesterId);
|
|
9836
9837
|
const validatedData = updateVitalStatsSchema.parse(data);
|
|
9837
|
-
await
|
|
9838
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9838
9839
|
vitalStats: validatedData,
|
|
9839
9840
|
lastUpdated: serverTimestamp13(),
|
|
9840
9841
|
updatedBy: requesterId
|
|
@@ -9844,7 +9845,7 @@ var addAllergyUtil = async (db, patientId, data, requesterId, requesterRoles) =>
|
|
|
9844
9845
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
9845
9846
|
await ensureMedicalInfoExists(db, patientId, requesterId);
|
|
9846
9847
|
const validatedData = addAllergySchema.parse(data);
|
|
9847
|
-
await
|
|
9848
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9848
9849
|
allergies: arrayUnion3(validatedData),
|
|
9849
9850
|
lastUpdated: serverTimestamp13(),
|
|
9850
9851
|
updatedBy: requesterId
|
|
@@ -9865,7 +9866,7 @@ var updateAllergyUtil = async (db, patientId, data, requesterId, requesterRoles)
|
|
|
9865
9866
|
...updatedAllergies[allergyIndex],
|
|
9866
9867
|
...updateData
|
|
9867
9868
|
};
|
|
9868
|
-
await
|
|
9869
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9869
9870
|
allergies: updatedAllergies,
|
|
9870
9871
|
lastUpdated: serverTimestamp13(),
|
|
9871
9872
|
updatedBy: requesterId
|
|
@@ -9882,7 +9883,7 @@ var removeAllergyUtil = async (db, patientId, allergyIndex, requesterId, request
|
|
|
9882
9883
|
const updatedAllergies = medicalInfo.allergies.filter(
|
|
9883
9884
|
(_, index) => index !== allergyIndex
|
|
9884
9885
|
);
|
|
9885
|
-
await
|
|
9886
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9886
9887
|
allergies: updatedAllergies,
|
|
9887
9888
|
lastUpdated: serverTimestamp13(),
|
|
9888
9889
|
updatedBy: requesterId
|
|
@@ -9892,7 +9893,7 @@ var addBlockingConditionUtil = async (db, patientId, data, requesterId, requeste
|
|
|
9892
9893
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
9893
9894
|
await ensureMedicalInfoExists(db, patientId, requesterId);
|
|
9894
9895
|
const validatedData = addBlockingConditionSchema.parse(data);
|
|
9895
|
-
await
|
|
9896
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9896
9897
|
blockingConditions: arrayUnion3(validatedData),
|
|
9897
9898
|
lastUpdated: serverTimestamp13(),
|
|
9898
9899
|
updatedBy: requesterId
|
|
@@ -9913,7 +9914,7 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
|
|
|
9913
9914
|
...updatedConditions[conditionIndex],
|
|
9914
9915
|
...updateData
|
|
9915
9916
|
};
|
|
9916
|
-
await
|
|
9917
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9917
9918
|
blockingConditions: updatedConditions,
|
|
9918
9919
|
lastUpdated: serverTimestamp13(),
|
|
9919
9920
|
updatedBy: requesterId
|
|
@@ -9930,7 +9931,7 @@ var removeBlockingConditionUtil = async (db, patientId, conditionIndex, requeste
|
|
|
9930
9931
|
const updatedConditions = medicalInfo.blockingConditions.filter(
|
|
9931
9932
|
(_, index) => index !== conditionIndex
|
|
9932
9933
|
);
|
|
9933
|
-
await
|
|
9934
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9934
9935
|
blockingConditions: updatedConditions,
|
|
9935
9936
|
lastUpdated: serverTimestamp13(),
|
|
9936
9937
|
updatedBy: requesterId
|
|
@@ -9940,7 +9941,7 @@ var addContraindicationUtil = async (db, patientId, data, requesterId, requester
|
|
|
9940
9941
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
9941
9942
|
await ensureMedicalInfoExists(db, patientId, requesterId);
|
|
9942
9943
|
const validatedData = addContraindicationSchema.parse(data);
|
|
9943
|
-
await
|
|
9944
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9944
9945
|
contraindications: arrayUnion3(validatedData),
|
|
9945
9946
|
lastUpdated: serverTimestamp13(),
|
|
9946
9947
|
updatedBy: requesterId
|
|
@@ -9961,7 +9962,7 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
|
|
|
9961
9962
|
...updatedContraindications[contraindicationIndex],
|
|
9962
9963
|
...updateData
|
|
9963
9964
|
};
|
|
9964
|
-
await
|
|
9965
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9965
9966
|
contraindications: updatedContraindications,
|
|
9966
9967
|
lastUpdated: serverTimestamp13(),
|
|
9967
9968
|
updatedBy: requesterId
|
|
@@ -9978,7 +9979,7 @@ var removeContraindicationUtil = async (db, patientId, contraindicationIndex, re
|
|
|
9978
9979
|
const updatedContraindications = medicalInfo.contraindications.filter(
|
|
9979
9980
|
(_, index) => index !== contraindicationIndex
|
|
9980
9981
|
);
|
|
9981
|
-
await
|
|
9982
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9982
9983
|
contraindications: updatedContraindications,
|
|
9983
9984
|
lastUpdated: serverTimestamp13(),
|
|
9984
9985
|
updatedBy: requesterId
|
|
@@ -9988,7 +9989,7 @@ var addMedicationUtil = async (db, patientId, data, requesterId, requesterRoles)
|
|
|
9988
9989
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
9989
9990
|
await ensureMedicalInfoExists(db, patientId, requesterId);
|
|
9990
9991
|
const validatedData = addMedicationSchema.parse(data);
|
|
9991
|
-
await
|
|
9992
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9992
9993
|
currentMedications: arrayUnion3(validatedData),
|
|
9993
9994
|
lastUpdated: serverTimestamp13(),
|
|
9994
9995
|
updatedBy: requesterId
|
|
@@ -10009,7 +10010,7 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
|
|
|
10009
10010
|
...updatedMedications[medicationIndex],
|
|
10010
10011
|
...updateData
|
|
10011
10012
|
};
|
|
10012
|
-
await
|
|
10013
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
10013
10014
|
currentMedications: updatedMedications,
|
|
10014
10015
|
lastUpdated: serverTimestamp13(),
|
|
10015
10016
|
updatedBy: requesterId
|
|
@@ -10026,7 +10027,7 @@ var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, r
|
|
|
10026
10027
|
const updatedMedications = medicalInfo.currentMedications.filter(
|
|
10027
10028
|
(_, index) => index !== medicationIndex
|
|
10028
10029
|
);
|
|
10029
|
-
await
|
|
10030
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
10030
10031
|
currentMedications: updatedMedications,
|
|
10031
10032
|
lastUpdated: serverTimestamp13(),
|
|
10032
10033
|
updatedBy: requesterId
|
|
@@ -10037,7 +10038,7 @@ var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, r
|
|
|
10037
10038
|
import {
|
|
10038
10039
|
getDoc as getDoc18,
|
|
10039
10040
|
setDoc as setDoc8,
|
|
10040
|
-
updateDoc as
|
|
10041
|
+
updateDoc as updateDoc13,
|
|
10041
10042
|
arrayUnion as arrayUnion4,
|
|
10042
10043
|
arrayRemove as arrayRemove4,
|
|
10043
10044
|
serverTimestamp as serverTimestamp14,
|
|
@@ -10174,19 +10175,19 @@ var getPatientProfileByUserRefUtil = async (db, userRef) => {
|
|
|
10174
10175
|
}
|
|
10175
10176
|
};
|
|
10176
10177
|
var addExpoTokenUtil = async (db, patientId, token) => {
|
|
10177
|
-
await
|
|
10178
|
+
await updateDoc13(getPatientDocRef(db, patientId), {
|
|
10178
10179
|
expoTokens: arrayUnion4(token),
|
|
10179
10180
|
updatedAt: serverTimestamp14()
|
|
10180
10181
|
});
|
|
10181
10182
|
};
|
|
10182
10183
|
var removeExpoTokenUtil = async (db, patientId, token) => {
|
|
10183
|
-
await
|
|
10184
|
+
await updateDoc13(getPatientDocRef(db, patientId), {
|
|
10184
10185
|
expoTokens: arrayRemove4(token),
|
|
10185
10186
|
updatedAt: serverTimestamp14()
|
|
10186
10187
|
});
|
|
10187
10188
|
};
|
|
10188
10189
|
var addPointsUtil = async (db, patientId, points) => {
|
|
10189
|
-
await
|
|
10190
|
+
await updateDoc13(getPatientDocRef(db, patientId), {
|
|
10190
10191
|
"gamification.points": increment(points),
|
|
10191
10192
|
updatedAt: serverTimestamp14()
|
|
10192
10193
|
});
|
|
@@ -10197,7 +10198,7 @@ var updatePatientProfileUtil = async (db, patientId, data) => {
|
|
|
10197
10198
|
...data,
|
|
10198
10199
|
updatedAt: serverTimestamp14()
|
|
10199
10200
|
};
|
|
10200
|
-
await
|
|
10201
|
+
await updateDoc13(getPatientDocRef(db, patientId), updateData);
|
|
10201
10202
|
const updatedDoc = await getDoc18(getPatientDocRef(db, patientId));
|
|
10202
10203
|
if (!updatedDoc.exists()) {
|
|
10203
10204
|
throw new Error("Patient profile not found after update");
|
|
@@ -10376,7 +10377,7 @@ import {
|
|
|
10376
10377
|
query as query12,
|
|
10377
10378
|
where as where12,
|
|
10378
10379
|
setDoc as setDoc9,
|
|
10379
|
-
updateDoc as
|
|
10380
|
+
updateDoc as updateDoc14,
|
|
10380
10381
|
Timestamp as Timestamp15,
|
|
10381
10382
|
collectionGroup
|
|
10382
10383
|
} from "firebase/firestore";
|
|
@@ -10471,7 +10472,7 @@ var markPatientTokenAsUsedUtil = async (db, tokenId, patientId, userId) => {
|
|
|
10471
10472
|
INVITE_TOKENS_COLLECTION,
|
|
10472
10473
|
tokenId
|
|
10473
10474
|
);
|
|
10474
|
-
await
|
|
10475
|
+
await updateDoc14(tokenRef, {
|
|
10475
10476
|
status: "used" /* USED */,
|
|
10476
10477
|
usedBy: userId,
|
|
10477
10478
|
usedAt: Timestamp15.now()
|
|
@@ -10510,7 +10511,7 @@ var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
|
|
|
10510
10511
|
};
|
|
10511
10512
|
|
|
10512
10513
|
// src/services/patient/utils/aesthetic-analysis.utils.ts
|
|
10513
|
-
import { getDoc as getDoc20, updateDoc as
|
|
10514
|
+
import { getDoc as getDoc20, updateDoc as updateDoc15, setDoc as setDoc10, serverTimestamp as serverTimestamp15, doc as doc18 } from "firebase/firestore";
|
|
10514
10515
|
|
|
10515
10516
|
// src/validations/patient/aesthetic-analysis.schema.ts
|
|
10516
10517
|
import { z as z15 } from "zod";
|
|
@@ -10665,7 +10666,7 @@ var createOrUpdateAestheticAnalysisUtil = async (db, patientId, data, requesterI
|
|
|
10665
10666
|
updatedAt: serverTimestamp15()
|
|
10666
10667
|
});
|
|
10667
10668
|
} else {
|
|
10668
|
-
await
|
|
10669
|
+
await updateDoc15(docRef, {
|
|
10669
10670
|
...validatedData,
|
|
10670
10671
|
completionPercentage,
|
|
10671
10672
|
status,
|
|
@@ -11011,7 +11012,7 @@ var PatientService = class extends BaseService {
|
|
|
11011
11012
|
"patient_profile_photos",
|
|
11012
11013
|
file instanceof File ? file.name : `profile_photo_${patientId}`
|
|
11013
11014
|
);
|
|
11014
|
-
await
|
|
11015
|
+
await updateDoc16(getSensitiveInfoDocRef(this.db, patientId), {
|
|
11015
11016
|
photoUrl: mediaMetadata.url,
|
|
11016
11017
|
updatedAt: serverTimestamp16()
|
|
11017
11018
|
});
|
|
@@ -11066,7 +11067,7 @@ var PatientService = class extends BaseService {
|
|
|
11066
11067
|
error
|
|
11067
11068
|
);
|
|
11068
11069
|
}
|
|
11069
|
-
await
|
|
11070
|
+
await updateDoc16(getSensitiveInfoDocRef(this.db, patientId), {
|
|
11070
11071
|
photoUrl: null,
|
|
11071
11072
|
updatedAt: serverTimestamp16()
|
|
11072
11073
|
});
|
|
@@ -11393,7 +11394,7 @@ import {
|
|
|
11393
11394
|
getDocs as getDocs13,
|
|
11394
11395
|
query as query13,
|
|
11395
11396
|
where as where13,
|
|
11396
|
-
updateDoc as
|
|
11397
|
+
updateDoc as updateDoc17,
|
|
11397
11398
|
setDoc as setDoc11,
|
|
11398
11399
|
deleteDoc as deleteDoc4,
|
|
11399
11400
|
Timestamp as Timestamp18,
|
|
@@ -11985,7 +11986,7 @@ var PractitionerService = class extends BaseService {
|
|
|
11985
11986
|
this.db,
|
|
11986
11987
|
`${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${tokenId}`
|
|
11987
11988
|
);
|
|
11988
|
-
await
|
|
11989
|
+
await updateDoc17(tokenRef, {
|
|
11989
11990
|
status: "used" /* USED */,
|
|
11990
11991
|
usedBy: userId,
|
|
11991
11992
|
usedAt: Timestamp18.now()
|
|
@@ -12014,7 +12015,7 @@ var PractitionerService = class extends BaseService {
|
|
|
12014
12015
|
if (tokenData.status !== "active" /* ACTIVE */) {
|
|
12015
12016
|
throw new Error("Token is not active and cannot be revoked");
|
|
12016
12017
|
}
|
|
12017
|
-
await
|
|
12018
|
+
await updateDoc17(tokenRef, {
|
|
12018
12019
|
status: "revoked" /* REVOKED */,
|
|
12019
12020
|
updatedAt: serverTimestamp17()
|
|
12020
12021
|
});
|
|
@@ -12412,7 +12413,7 @@ var PractitionerService = class extends BaseService {
|
|
|
12412
12413
|
...processedData,
|
|
12413
12414
|
updatedAt: serverTimestamp17()
|
|
12414
12415
|
};
|
|
12415
|
-
await
|
|
12416
|
+
await updateDoc17(practitionerRef, updateData);
|
|
12416
12417
|
const updatedPractitioner = await this.getPractitioner(practitionerId);
|
|
12417
12418
|
if (!updatedPractitioner) {
|
|
12418
12419
|
throw new Error(
|
|
@@ -12450,7 +12451,7 @@ var PractitionerService = class extends BaseService {
|
|
|
12450
12451
|
);
|
|
12451
12452
|
return;
|
|
12452
12453
|
}
|
|
12453
|
-
await
|
|
12454
|
+
await updateDoc17(practitionerRef, {
|
|
12454
12455
|
clinics: arrayUnion6(clinicId),
|
|
12455
12456
|
updatedAt: serverTimestamp17()
|
|
12456
12457
|
});
|
|
@@ -12476,7 +12477,7 @@ var PractitionerService = class extends BaseService {
|
|
|
12476
12477
|
if (!practitionerDoc.exists()) {
|
|
12477
12478
|
throw new Error(`Practitioner ${practitionerId} not found`);
|
|
12478
12479
|
}
|
|
12479
|
-
await
|
|
12480
|
+
await updateDoc17(practitionerRef, {
|
|
12480
12481
|
clinics: arrayRemove5(clinicId),
|
|
12481
12482
|
updatedAt: serverTimestamp17()
|
|
12482
12483
|
});
|
|
@@ -13293,7 +13294,7 @@ var UserService = class extends BaseService {
|
|
|
13293
13294
|
return this.getUserById(userData.uid);
|
|
13294
13295
|
}
|
|
13295
13296
|
const profiles = await this.createProfilesForRoles(userData.uid, roles, options);
|
|
13296
|
-
await
|
|
13297
|
+
await updateDoc18(doc21(this.db, USERS_COLLECTION, userData.uid), profiles);
|
|
13297
13298
|
return this.getUserById(userData.uid);
|
|
13298
13299
|
}
|
|
13299
13300
|
/**
|
|
@@ -13460,7 +13461,7 @@ var UserService = class extends BaseService {
|
|
|
13460
13461
|
if (!userDoc.exists()) {
|
|
13461
13462
|
throw AUTH_ERRORS.USER_NOT_FOUND;
|
|
13462
13463
|
}
|
|
13463
|
-
await
|
|
13464
|
+
await updateDoc18(userRef, {
|
|
13464
13465
|
lastLoginAt: serverTimestamp18(),
|
|
13465
13466
|
updatedAt: serverTimestamp18()
|
|
13466
13467
|
});
|
|
@@ -13472,7 +13473,7 @@ var UserService = class extends BaseService {
|
|
|
13472
13473
|
if (!userDoc.exists()) {
|
|
13473
13474
|
throw USER_ERRORS.NOT_FOUND;
|
|
13474
13475
|
}
|
|
13475
|
-
await
|
|
13476
|
+
await updateDoc18(userRef, {
|
|
13476
13477
|
email,
|
|
13477
13478
|
isAnonymous: false,
|
|
13478
13479
|
updatedAt: serverTimestamp18()
|
|
@@ -13493,7 +13494,7 @@ var UserService = class extends BaseService {
|
|
|
13493
13494
|
updatedAt: serverTimestamp18()
|
|
13494
13495
|
};
|
|
13495
13496
|
userSchema.parse(updatedUser);
|
|
13496
|
-
await
|
|
13497
|
+
await updateDoc18(userRef, {
|
|
13497
13498
|
...updates,
|
|
13498
13499
|
updatedAt: serverTimestamp18()
|
|
13499
13500
|
});
|
|
@@ -13512,7 +13513,7 @@ var UserService = class extends BaseService {
|
|
|
13512
13513
|
const user = await this.getUserById(uid);
|
|
13513
13514
|
if (user.roles.includes(role)) return;
|
|
13514
13515
|
const profiles = await this.createProfilesForRoles(uid, [role], options);
|
|
13515
|
-
await
|
|
13516
|
+
await updateDoc18(doc21(this.db, USERS_COLLECTION, uid), {
|
|
13516
13517
|
roles: [...user.roles, role],
|
|
13517
13518
|
...profiles,
|
|
13518
13519
|
updatedAt: serverTimestamp18()
|
|
@@ -13541,7 +13542,7 @@ var UserService = class extends BaseService {
|
|
|
13541
13542
|
}
|
|
13542
13543
|
break;
|
|
13543
13544
|
}
|
|
13544
|
-
await
|
|
13545
|
+
await updateDoc18(doc21(this.db, USERS_COLLECTION, uid), {
|
|
13545
13546
|
roles: user.roles.filter((r) => r !== role),
|
|
13546
13547
|
updatedAt: serverTimestamp18()
|
|
13547
13548
|
});
|
|
@@ -13567,7 +13568,7 @@ var UserService = class extends BaseService {
|
|
|
13567
13568
|
} else {
|
|
13568
13569
|
updateData.acquisitionSourceOther = null;
|
|
13569
13570
|
}
|
|
13570
|
-
await
|
|
13571
|
+
await updateDoc18(userRef, updateData);
|
|
13571
13572
|
}
|
|
13572
13573
|
// Delete operations
|
|
13573
13574
|
async deleteUser(uid) {
|
|
@@ -13745,7 +13746,7 @@ import {
|
|
|
13745
13746
|
getDocs as getDocs16,
|
|
13746
13747
|
query as query16,
|
|
13747
13748
|
where as where16,
|
|
13748
|
-
updateDoc as
|
|
13749
|
+
updateDoc as updateDoc19,
|
|
13749
13750
|
setDoc as setDoc13,
|
|
13750
13751
|
Timestamp as Timestamp20
|
|
13751
13752
|
} from "firebase/firestore";
|
|
@@ -14013,7 +14014,7 @@ async function updateClinicGroup(db, groupId, data, app) {
|
|
|
14013
14014
|
updatedAt: Timestamp20.now()
|
|
14014
14015
|
};
|
|
14015
14016
|
console.log("[CLINIC_GROUP] Updating clinic group in Firestore");
|
|
14016
|
-
await
|
|
14017
|
+
await updateDoc19(doc22(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
|
|
14017
14018
|
console.log("[CLINIC_GROUP] Clinic group updated successfully");
|
|
14018
14019
|
const updatedGroup = await getClinicGroup(db, groupId);
|
|
14019
14020
|
if (!updatedGroup) {
|
|
@@ -14398,7 +14399,7 @@ import {
|
|
|
14398
14399
|
doc as doc24,
|
|
14399
14400
|
getDoc as getDoc26,
|
|
14400
14401
|
getDocs as getDocs20,
|
|
14401
|
-
updateDoc as
|
|
14402
|
+
updateDoc as updateDoc21,
|
|
14402
14403
|
serverTimestamp as serverTimestamp20,
|
|
14403
14404
|
writeBatch as writeBatch4,
|
|
14404
14405
|
arrayUnion as arrayUnion7
|
|
@@ -14418,7 +14419,7 @@ import {
|
|
|
14418
14419
|
getDocs as getDocs17,
|
|
14419
14420
|
query as query17,
|
|
14420
14421
|
where as where17,
|
|
14421
|
-
updateDoc as
|
|
14422
|
+
updateDoc as updateDoc20,
|
|
14422
14423
|
setDoc as setDoc14,
|
|
14423
14424
|
Timestamp as Timestamp21,
|
|
14424
14425
|
limit as limit9,
|
|
@@ -14635,7 +14636,7 @@ async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app
|
|
|
14635
14636
|
};
|
|
14636
14637
|
console.log("[CLINIC] Updating clinic in Firestore");
|
|
14637
14638
|
try {
|
|
14638
|
-
await
|
|
14639
|
+
await updateDoc20(doc23(db, CLINICS_COLLECTION, clinicId), updatedData);
|
|
14639
14640
|
console.log("[CLINIC] Clinic updated successfully");
|
|
14640
14641
|
} catch (updateError) {
|
|
14641
14642
|
console.error("[CLINIC] Error updating clinic in Firestore:", updateError);
|
|
@@ -15490,7 +15491,7 @@ var ClinicService = class extends BaseService {
|
|
|
15490
15491
|
};
|
|
15491
15492
|
}
|
|
15492
15493
|
updatePayload.updatedAt = serverTimestamp20();
|
|
15493
|
-
await
|
|
15494
|
+
await updateDoc21(clinicRef, updatePayload);
|
|
15494
15495
|
console.log(`[ClinicService] Clinic ${clinicId} updated successfully`);
|
|
15495
15496
|
const updatedClinic = await this.getClinic(clinicId);
|
|
15496
15497
|
if (!updatedClinic) throw new Error("Failed to retrieve updated clinic");
|
|
@@ -15508,7 +15509,7 @@ var ClinicService = class extends BaseService {
|
|
|
15508
15509
|
*/
|
|
15509
15510
|
async deactivateClinic(clinicId, adminId) {
|
|
15510
15511
|
const clinicRef = doc24(this.db, CLINICS_COLLECTION, clinicId);
|
|
15511
|
-
await
|
|
15512
|
+
await updateDoc21(clinicRef, {
|
|
15512
15513
|
isActive: false,
|
|
15513
15514
|
updatedAt: serverTimestamp20()
|
|
15514
15515
|
});
|
|
@@ -15518,7 +15519,7 @@ var ClinicService = class extends BaseService {
|
|
|
15518
15519
|
*/
|
|
15519
15520
|
async activateClinic(clinicId, adminId) {
|
|
15520
15521
|
const clinicRef = doc24(this.db, CLINICS_COLLECTION, clinicId);
|
|
15521
|
-
await
|
|
15522
|
+
await updateDoc21(clinicRef, {
|
|
15522
15523
|
isActive: true,
|
|
15523
15524
|
updatedAt: serverTimestamp20()
|
|
15524
15525
|
});
|
|
@@ -16855,7 +16856,7 @@ import {
|
|
|
16855
16856
|
where as where27,
|
|
16856
16857
|
getDocs as getDocs27,
|
|
16857
16858
|
setDoc as setDoc22,
|
|
16858
|
-
updateDoc as
|
|
16859
|
+
updateDoc as updateDoc28
|
|
16859
16860
|
} from "firebase/firestore";
|
|
16860
16861
|
|
|
16861
16862
|
// src/services/calendar/utils/clinic.utils.ts
|
|
@@ -16865,7 +16866,7 @@ import {
|
|
|
16865
16866
|
getDoc as getDoc28,
|
|
16866
16867
|
getDocs as getDocs22,
|
|
16867
16868
|
setDoc as setDoc17,
|
|
16868
|
-
updateDoc as
|
|
16869
|
+
updateDoc as updateDoc23,
|
|
16869
16870
|
deleteDoc as deleteDoc10,
|
|
16870
16871
|
query as query22,
|
|
16871
16872
|
where as where22,
|
|
@@ -16936,7 +16937,7 @@ async function updateClinicCalendarEventUtil(db, clinicId, eventId, updateData)
|
|
|
16936
16937
|
...updateData,
|
|
16937
16938
|
updatedAt: serverTimestamp21()
|
|
16938
16939
|
};
|
|
16939
|
-
await
|
|
16940
|
+
await updateDoc23(eventRef, updates);
|
|
16940
16941
|
const updatedDoc = await getDoc28(eventRef);
|
|
16941
16942
|
if (!updatedDoc.exists()) {
|
|
16942
16943
|
throw new Error("Event not found after update");
|
|
@@ -16969,7 +16970,7 @@ import {
|
|
|
16969
16970
|
getDoc as getDoc29,
|
|
16970
16971
|
getDocs as getDocs23,
|
|
16971
16972
|
setDoc as setDoc18,
|
|
16972
|
-
updateDoc as
|
|
16973
|
+
updateDoc as updateDoc24,
|
|
16973
16974
|
deleteDoc as deleteDoc11,
|
|
16974
16975
|
query as query23,
|
|
16975
16976
|
where as where23,
|
|
@@ -16999,7 +17000,7 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
|
|
|
16999
17000
|
...updateData,
|
|
17000
17001
|
updatedAt: serverTimestamp22()
|
|
17001
17002
|
};
|
|
17002
|
-
await
|
|
17003
|
+
await updateDoc24(eventRef, updates);
|
|
17003
17004
|
const updatedDoc = await getDoc29(eventRef);
|
|
17004
17005
|
if (!updatedDoc.exists()) {
|
|
17005
17006
|
throw new Error("Event not found after update");
|
|
@@ -17013,7 +17014,7 @@ import {
|
|
|
17013
17014
|
getDoc as getDoc30,
|
|
17014
17015
|
getDocs as getDocs24,
|
|
17015
17016
|
setDoc as setDoc19,
|
|
17016
|
-
updateDoc as
|
|
17017
|
+
updateDoc as updateDoc25,
|
|
17017
17018
|
deleteDoc as deleteDoc12,
|
|
17018
17019
|
query as query24,
|
|
17019
17020
|
where as where24,
|
|
@@ -17051,7 +17052,7 @@ async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId,
|
|
|
17051
17052
|
...updateData,
|
|
17052
17053
|
updatedAt: serverTimestamp23()
|
|
17053
17054
|
};
|
|
17054
|
-
await
|
|
17055
|
+
await updateDoc25(eventRef, updates);
|
|
17055
17056
|
const updatedDoc = await getDoc30(eventRef);
|
|
17056
17057
|
if (!updatedDoc.exists()) {
|
|
17057
17058
|
throw new Error("Event not found after update");
|
|
@@ -17116,7 +17117,7 @@ import {
|
|
|
17116
17117
|
getDoc as getDoc31,
|
|
17117
17118
|
getDocs as getDocs25,
|
|
17118
17119
|
setDoc as setDoc20,
|
|
17119
|
-
updateDoc as
|
|
17120
|
+
updateDoc as updateDoc26,
|
|
17120
17121
|
deleteDoc as deleteDoc13,
|
|
17121
17122
|
query as query25,
|
|
17122
17123
|
where as where25,
|
|
@@ -17244,7 +17245,7 @@ import {
|
|
|
17244
17245
|
getDoc as getDoc32,
|
|
17245
17246
|
getDocs as getDocs26,
|
|
17246
17247
|
setDoc as setDoc21,
|
|
17247
|
-
updateDoc as
|
|
17248
|
+
updateDoc as updateDoc27,
|
|
17248
17249
|
deleteDoc as deleteDoc14,
|
|
17249
17250
|
query as query26,
|
|
17250
17251
|
orderBy as orderBy12,
|
|
@@ -17368,7 +17369,7 @@ async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendar
|
|
|
17368
17369
|
...updateData,
|
|
17369
17370
|
updatedAt: serverTimestamp25()
|
|
17370
17371
|
};
|
|
17371
|
-
await
|
|
17372
|
+
await updateDoc27(calendarRef, updates);
|
|
17372
17373
|
const updatedDoc = await getDoc32(calendarRef);
|
|
17373
17374
|
if (!updatedDoc.exists()) {
|
|
17374
17375
|
throw new Error("Synced calendar not found after update");
|
|
@@ -17381,7 +17382,7 @@ async function updatePatientSyncedCalendarUtil(db, patientId, calendarId, update
|
|
|
17381
17382
|
...updateData,
|
|
17382
17383
|
updatedAt: serverTimestamp25()
|
|
17383
17384
|
};
|
|
17384
|
-
await
|
|
17385
|
+
await updateDoc27(calendarRef, updates);
|
|
17385
17386
|
const updatedDoc = await getDoc32(calendarRef);
|
|
17386
17387
|
if (!updatedDoc.exists()) {
|
|
17387
17388
|
throw new Error("Synced calendar not found after update");
|
|
@@ -17394,7 +17395,7 @@ async function updateClinicSyncedCalendarUtil(db, clinicId, calendarId, updateDa
|
|
|
17394
17395
|
...updateData,
|
|
17395
17396
|
updatedAt: serverTimestamp25()
|
|
17396
17397
|
};
|
|
17397
|
-
await
|
|
17398
|
+
await updateDoc27(calendarRef, updates);
|
|
17398
17399
|
const updatedDoc = await getDoc32(calendarRef);
|
|
17399
17400
|
if (!updatedDoc.exists()) {
|
|
17400
17401
|
throw new Error("Synced calendar not found after update");
|
|
@@ -18824,7 +18825,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18824
18825
|
CALENDAR_COLLECTION,
|
|
18825
18826
|
eventId
|
|
18826
18827
|
);
|
|
18827
|
-
await
|
|
18828
|
+
await updateDoc28(eventRef, {
|
|
18828
18829
|
eventName: externalEvent.summary || "External Event",
|
|
18829
18830
|
eventTime: {
|
|
18830
18831
|
start: Timestamp30.fromDate(startTime),
|
|
@@ -18856,7 +18857,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18856
18857
|
CALENDAR_COLLECTION,
|
|
18857
18858
|
eventId
|
|
18858
18859
|
);
|
|
18859
|
-
await
|
|
18860
|
+
await updateDoc28(eventRef, {
|
|
18860
18861
|
status,
|
|
18861
18862
|
updatedAt: serverTimestamp26()
|
|
18862
18863
|
});
|
|
@@ -19257,7 +19258,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
19257
19258
|
} else {
|
|
19258
19259
|
syncIds.push(syncEvent);
|
|
19259
19260
|
}
|
|
19260
|
-
await
|
|
19261
|
+
await updateDoc28(eventRef, {
|
|
19261
19262
|
syncedCalendarEventId: syncIds,
|
|
19262
19263
|
updatedAt: serverTimestamp26()
|
|
19263
19264
|
});
|
|
@@ -19483,7 +19484,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
19483
19484
|
|
|
19484
19485
|
// src/services/calendar/calendar.v3.service.ts
|
|
19485
19486
|
import { Timestamp as Timestamp31, serverTimestamp as serverTimestamp27 } from "firebase/firestore";
|
|
19486
|
-
import { doc as doc33, getDoc as getDoc34, setDoc as setDoc23, updateDoc as
|
|
19487
|
+
import { doc as doc33, getDoc as getDoc34, setDoc as setDoc23, updateDoc as updateDoc29, deleteDoc as deleteDoc15 } from "firebase/firestore";
|
|
19487
19488
|
var CalendarServiceV3 = class extends BaseService {
|
|
19488
19489
|
/**
|
|
19489
19490
|
* Creates a new CalendarServiceV3 instance
|
|
@@ -19562,7 +19563,7 @@ var CalendarServiceV3 = class extends BaseService {
|
|
|
19562
19563
|
if (params.status !== void 0) {
|
|
19563
19564
|
updateData.status = params.status;
|
|
19564
19565
|
}
|
|
19565
|
-
await
|
|
19566
|
+
await updateDoc29(eventRef, updateData);
|
|
19566
19567
|
const updatedEventDoc = await getDoc34(eventRef);
|
|
19567
19568
|
return updatedEventDoc.data();
|
|
19568
19569
|
}
|
|
@@ -19791,7 +19792,7 @@ import {
|
|
|
19791
19792
|
getDocs as getDocs28,
|
|
19792
19793
|
query as query28,
|
|
19793
19794
|
where as where28,
|
|
19794
|
-
updateDoc as
|
|
19795
|
+
updateDoc as updateDoc30,
|
|
19795
19796
|
setDoc as setDoc24,
|
|
19796
19797
|
deleteDoc as deleteDoc16,
|
|
19797
19798
|
Timestamp as Timestamp32,
|
|
@@ -19960,7 +19961,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
19960
19961
|
updatedAt: serverTimestamp28()
|
|
19961
19962
|
};
|
|
19962
19963
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
19963
|
-
await
|
|
19964
|
+
await updateDoc30(docRef, updateData);
|
|
19964
19965
|
return await this.getInviteById(inviteId);
|
|
19965
19966
|
} catch (error) {
|
|
19966
19967
|
console.error(
|
|
@@ -19992,7 +19993,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
19992
19993
|
updatedAt: serverTimestamp28()
|
|
19993
19994
|
};
|
|
19994
19995
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
19995
|
-
await
|
|
19996
|
+
await updateDoc30(docRef, updateData);
|
|
19996
19997
|
return await this.getInviteById(inviteId);
|
|
19997
19998
|
} catch (error) {
|
|
19998
19999
|
console.error(
|
|
@@ -20024,7 +20025,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
20024
20025
|
updatedAt: serverTimestamp28()
|
|
20025
20026
|
};
|
|
20026
20027
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
20027
|
-
await
|
|
20028
|
+
await updateDoc30(docRef, updateData);
|
|
20028
20029
|
return await this.getInviteById(inviteId);
|
|
20029
20030
|
} catch (error) {
|
|
20030
20031
|
console.error(
|
|
@@ -20195,7 +20196,7 @@ import {
|
|
|
20195
20196
|
getDoc as getDoc36,
|
|
20196
20197
|
getDocs as getDocs29,
|
|
20197
20198
|
setDoc as setDoc25,
|
|
20198
|
-
updateDoc as
|
|
20199
|
+
updateDoc as updateDoc31,
|
|
20199
20200
|
deleteDoc as deleteDoc17,
|
|
20200
20201
|
query as query29,
|
|
20201
20202
|
where as where29,
|
|
@@ -20325,7 +20326,7 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
20325
20326
|
updatePayload.sortingOrder = (_c = validatedData.sortingOrder) != null ? _c : 0;
|
|
20326
20327
|
const docRef = doc35(this.collectionRef, templateId);
|
|
20327
20328
|
console.log("Update payload", updatePayload);
|
|
20328
|
-
await
|
|
20329
|
+
await updateDoc31(docRef, updatePayload);
|
|
20329
20330
|
return { ...template, ...updatePayload };
|
|
20330
20331
|
}
|
|
20331
20332
|
/**
|
|
@@ -20573,7 +20574,7 @@ import {
|
|
|
20573
20574
|
getDoc as getDoc37,
|
|
20574
20575
|
getDocs as getDocs30,
|
|
20575
20576
|
setDoc as setDoc26,
|
|
20576
|
-
updateDoc as
|
|
20577
|
+
updateDoc as updateDoc32,
|
|
20577
20578
|
query as query30,
|
|
20578
20579
|
orderBy as orderBy15,
|
|
20579
20580
|
limit as limit14,
|
|
@@ -20665,7 +20666,11 @@ var FilledDocumentService = class extends BaseService {
|
|
|
20665
20666
|
if (!docSnap.exists()) {
|
|
20666
20667
|
return null;
|
|
20667
20668
|
}
|
|
20668
|
-
|
|
20669
|
+
const data = docSnap.data();
|
|
20670
|
+
if (!data.id) {
|
|
20671
|
+
data.id = docSnap.id;
|
|
20672
|
+
}
|
|
20673
|
+
return data;
|
|
20669
20674
|
}
|
|
20670
20675
|
/**
|
|
20671
20676
|
* Update values or status in a filled document within an appointment's subcollection.
|
|
@@ -20710,7 +20715,7 @@ var FilledDocumentService = class extends BaseService {
|
|
|
20710
20715
|
}
|
|
20711
20716
|
if (Object.keys(updatePayload).length === 1 && "updatedAt" in updatePayload) {
|
|
20712
20717
|
}
|
|
20713
|
-
await
|
|
20718
|
+
await updateDoc32(docRef, updatePayload);
|
|
20714
20719
|
return { ...existingDoc, ...updatePayload };
|
|
20715
20720
|
}
|
|
20716
20721
|
/**
|
|
@@ -20766,9 +20771,13 @@ var FilledDocumentService = class extends BaseService {
|
|
|
20766
20771
|
const querySnapshot = await getDocs30(q);
|
|
20767
20772
|
const documents = [];
|
|
20768
20773
|
let lastVisible = null;
|
|
20769
|
-
querySnapshot.forEach((
|
|
20770
|
-
|
|
20771
|
-
|
|
20774
|
+
querySnapshot.forEach((docSnapshot) => {
|
|
20775
|
+
const data = docSnapshot.data();
|
|
20776
|
+
if (!data.id) {
|
|
20777
|
+
data.id = docSnapshot.id;
|
|
20778
|
+
}
|
|
20779
|
+
documents.push(data);
|
|
20780
|
+
lastVisible = docSnapshot;
|
|
20772
20781
|
});
|
|
20773
20782
|
return {
|
|
20774
20783
|
documents,
|
|
@@ -20934,7 +20943,7 @@ import {
|
|
|
20934
20943
|
getDocs as getDocs31,
|
|
20935
20944
|
query as query31,
|
|
20936
20945
|
where as where31,
|
|
20937
|
-
updateDoc as
|
|
20946
|
+
updateDoc as updateDoc33,
|
|
20938
20947
|
deleteDoc as deleteDoc18,
|
|
20939
20948
|
orderBy as orderBy16,
|
|
20940
20949
|
Timestamp as Timestamp34,
|
|
@@ -21020,7 +21029,7 @@ var NotificationService = class extends BaseService {
|
|
|
21020
21029
|
NOTIFICATIONS_COLLECTION,
|
|
21021
21030
|
notificationId
|
|
21022
21031
|
);
|
|
21023
|
-
await
|
|
21032
|
+
await updateDoc33(notificationRef, {
|
|
21024
21033
|
isRead: true,
|
|
21025
21034
|
updatedAt: Timestamp34.now()
|
|
21026
21035
|
});
|
|
@@ -21053,7 +21062,7 @@ var NotificationService = class extends BaseService {
|
|
|
21053
21062
|
NOTIFICATIONS_COLLECTION,
|
|
21054
21063
|
notificationId
|
|
21055
21064
|
);
|
|
21056
|
-
await
|
|
21065
|
+
await updateDoc33(notificationRef, {
|
|
21057
21066
|
status,
|
|
21058
21067
|
updatedAt: Timestamp34.now()
|
|
21059
21068
|
});
|
|
@@ -21109,7 +21118,7 @@ import {
|
|
|
21109
21118
|
query as query32,
|
|
21110
21119
|
where as where32,
|
|
21111
21120
|
doc as doc38,
|
|
21112
|
-
updateDoc as
|
|
21121
|
+
updateDoc as updateDoc34,
|
|
21113
21122
|
Timestamp as Timestamp35,
|
|
21114
21123
|
orderBy as orderBy17,
|
|
21115
21124
|
limit as limit15,
|
|
@@ -21272,7 +21281,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
21272
21281
|
if (newOverallStatus !== instance.overallStatus) {
|
|
21273
21282
|
updatePayload.overallStatus = newOverallStatus;
|
|
21274
21283
|
}
|
|
21275
|
-
await
|
|
21284
|
+
await updateDoc34(instanceRef, updatePayload);
|
|
21276
21285
|
return {
|
|
21277
21286
|
...instance,
|
|
21278
21287
|
instructions: updatedInstructions,
|
|
@@ -21292,7 +21301,7 @@ import {
|
|
|
21292
21301
|
getDocs as getDocs33,
|
|
21293
21302
|
query as query33,
|
|
21294
21303
|
where as where33,
|
|
21295
|
-
updateDoc as
|
|
21304
|
+
updateDoc as updateDoc35,
|
|
21296
21305
|
setDoc as setDoc27,
|
|
21297
21306
|
deleteDoc as deleteDoc19,
|
|
21298
21307
|
serverTimestamp as serverTimestamp31,
|
|
@@ -22449,7 +22458,7 @@ var ProcedureService = class extends BaseService {
|
|
|
22449
22458
|
} else if (validatedData.productId) {
|
|
22450
22459
|
console.warn("Attempted to update product without a valid technologyId");
|
|
22451
22460
|
}
|
|
22452
|
-
await
|
|
22461
|
+
await updateDoc35(procedureRef, {
|
|
22453
22462
|
...updatedProcedureData,
|
|
22454
22463
|
updatedAt: serverTimestamp31()
|
|
22455
22464
|
});
|
|
@@ -22467,7 +22476,7 @@ var ProcedureService = class extends BaseService {
|
|
|
22467
22476
|
console.warn(`Procedure ${id} not found for deactivation.`);
|
|
22468
22477
|
return;
|
|
22469
22478
|
}
|
|
22470
|
-
await
|
|
22479
|
+
await updateDoc35(procedureRef, {
|
|
22471
22480
|
isActive: false,
|
|
22472
22481
|
updatedAt: serverTimestamp31()
|
|
22473
22482
|
});
|
|
@@ -23855,7 +23864,7 @@ import {
|
|
|
23855
23864
|
getDoc as getDoc42,
|
|
23856
23865
|
getDocs as getDocs35,
|
|
23857
23866
|
query as query35,
|
|
23858
|
-
updateDoc as
|
|
23867
|
+
updateDoc as updateDoc36,
|
|
23859
23868
|
where as where35,
|
|
23860
23869
|
limit as limit17,
|
|
23861
23870
|
orderBy as orderBy19,
|
|
@@ -23968,7 +23977,7 @@ var BrandService = class extends BaseService {
|
|
|
23968
23977
|
updateData.name_lowercase = brand.name.toLowerCase();
|
|
23969
23978
|
}
|
|
23970
23979
|
const docRef = doc41(this.getBrandsRef(), brandId);
|
|
23971
|
-
await
|
|
23980
|
+
await updateDoc36(docRef, updateData);
|
|
23972
23981
|
return this.getById(brandId);
|
|
23973
23982
|
}
|
|
23974
23983
|
/**
|
|
@@ -24071,7 +24080,7 @@ import {
|
|
|
24071
24080
|
orderBy as orderBy20,
|
|
24072
24081
|
query as query36,
|
|
24073
24082
|
startAfter as startAfter16,
|
|
24074
|
-
updateDoc as
|
|
24083
|
+
updateDoc as updateDoc37,
|
|
24075
24084
|
where as where36
|
|
24076
24085
|
} from "firebase/firestore";
|
|
24077
24086
|
|
|
@@ -24231,7 +24240,7 @@ var CategoryService = class extends BaseService {
|
|
|
24231
24240
|
updatedAt: /* @__PURE__ */ new Date()
|
|
24232
24241
|
};
|
|
24233
24242
|
const docRef = doc42(this.categoriesRef, id);
|
|
24234
|
-
await
|
|
24243
|
+
await updateDoc37(docRef, updateData);
|
|
24235
24244
|
return this.getById(id);
|
|
24236
24245
|
}
|
|
24237
24246
|
/**
|
|
@@ -24383,7 +24392,7 @@ import {
|
|
|
24383
24392
|
query as query37,
|
|
24384
24393
|
setDoc as setDoc29,
|
|
24385
24394
|
startAfter as startAfter17,
|
|
24386
|
-
updateDoc as
|
|
24395
|
+
updateDoc as updateDoc38,
|
|
24387
24396
|
where as where37
|
|
24388
24397
|
} from "firebase/firestore";
|
|
24389
24398
|
|
|
@@ -24588,7 +24597,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
24588
24597
|
updatedAt: /* @__PURE__ */ new Date()
|
|
24589
24598
|
};
|
|
24590
24599
|
const docRef = doc43(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
24591
|
-
await
|
|
24600
|
+
await updateDoc38(docRef, updateData);
|
|
24592
24601
|
return this.getById(categoryId, subcategoryId);
|
|
24593
24602
|
}
|
|
24594
24603
|
}
|
|
@@ -24744,7 +24753,7 @@ import {
|
|
|
24744
24753
|
orderBy as orderBy22,
|
|
24745
24754
|
query as query38,
|
|
24746
24755
|
startAfter as startAfter18,
|
|
24747
|
-
updateDoc as
|
|
24756
|
+
updateDoc as updateDoc39,
|
|
24748
24757
|
where as where38,
|
|
24749
24758
|
arrayUnion as arrayUnion9,
|
|
24750
24759
|
arrayRemove as arrayRemove8,
|
|
@@ -24941,7 +24950,7 @@ var TechnologyService = class extends BaseService {
|
|
|
24941
24950
|
updateData.updatedAt = /* @__PURE__ */ new Date();
|
|
24942
24951
|
const docRef = doc44(this.technologiesRef, id);
|
|
24943
24952
|
const beforeTech = await this.getById(id);
|
|
24944
|
-
await
|
|
24953
|
+
await updateDoc39(docRef, updateData);
|
|
24945
24954
|
const categoryChanged = beforeTech && updateData.categoryId && beforeTech.categoryId !== updateData.categoryId;
|
|
24946
24955
|
const subcategoryChanged = beforeTech && updateData.subcategoryId && beforeTech.subcategoryId !== updateData.subcategoryId;
|
|
24947
24956
|
const nameChanged = beforeTech && updateData.name && beforeTech.name !== updateData.name;
|
|
@@ -25028,7 +25037,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25028
25037
|
async addRequirement(technologyId, requirement) {
|
|
25029
25038
|
const docRef = doc44(this.technologiesRef, technologyId);
|
|
25030
25039
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
25031
|
-
await
|
|
25040
|
+
await updateDoc39(docRef, {
|
|
25032
25041
|
[requirementType]: arrayUnion9(requirement),
|
|
25033
25042
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25034
25043
|
});
|
|
@@ -25043,7 +25052,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25043
25052
|
async removeRequirement(technologyId, requirement) {
|
|
25044
25053
|
const docRef = doc44(this.technologiesRef, technologyId);
|
|
25045
25054
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
25046
|
-
await
|
|
25055
|
+
await updateDoc39(docRef, {
|
|
25047
25056
|
[requirementType]: arrayRemove8(requirement),
|
|
25048
25057
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25049
25058
|
});
|
|
@@ -25082,7 +25091,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25082
25091
|
*/
|
|
25083
25092
|
async addBlockingCondition(technologyId, condition) {
|
|
25084
25093
|
const docRef = doc44(this.technologiesRef, technologyId);
|
|
25085
|
-
await
|
|
25094
|
+
await updateDoc39(docRef, {
|
|
25086
25095
|
blockingConditions: arrayUnion9(condition),
|
|
25087
25096
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25088
25097
|
});
|
|
@@ -25096,7 +25105,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25096
25105
|
*/
|
|
25097
25106
|
async removeBlockingCondition(technologyId, condition) {
|
|
25098
25107
|
const docRef = doc44(this.technologiesRef, technologyId);
|
|
25099
|
-
await
|
|
25108
|
+
await updateDoc39(docRef, {
|
|
25100
25109
|
blockingConditions: arrayRemove8(condition),
|
|
25101
25110
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25102
25111
|
});
|
|
@@ -25118,7 +25127,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25118
25127
|
if (existingContraindications.some((c) => c.id === contraindication.id)) {
|
|
25119
25128
|
return technology;
|
|
25120
25129
|
}
|
|
25121
|
-
await
|
|
25130
|
+
await updateDoc39(docRef, {
|
|
25122
25131
|
contraindications: [...existingContraindications, contraindication],
|
|
25123
25132
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25124
25133
|
});
|
|
@@ -25139,7 +25148,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25139
25148
|
const updatedContraindications = (technology.contraindications || []).filter(
|
|
25140
25149
|
(c) => c.id !== contraindication.id
|
|
25141
25150
|
);
|
|
25142
|
-
await
|
|
25151
|
+
await updateDoc39(docRef, {
|
|
25143
25152
|
contraindications: updatedContraindications,
|
|
25144
25153
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25145
25154
|
});
|
|
@@ -25168,7 +25177,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25168
25177
|
}
|
|
25169
25178
|
const updatedContraindications = [...contraindications];
|
|
25170
25179
|
updatedContraindications[index] = contraindication;
|
|
25171
|
-
await
|
|
25180
|
+
await updateDoc39(docRef, {
|
|
25172
25181
|
contraindications: updatedContraindications,
|
|
25173
25182
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25174
25183
|
});
|
|
@@ -25190,7 +25199,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25190
25199
|
if (existingBenefits.some((b) => b.id === benefit.id)) {
|
|
25191
25200
|
return technology;
|
|
25192
25201
|
}
|
|
25193
|
-
await
|
|
25202
|
+
await updateDoc39(docRef, {
|
|
25194
25203
|
benefits: [...existingBenefits, benefit],
|
|
25195
25204
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25196
25205
|
});
|
|
@@ -25209,7 +25218,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25209
25218
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
25210
25219
|
}
|
|
25211
25220
|
const updatedBenefits = (technology.benefits || []).filter((b) => b.id !== benefit.id);
|
|
25212
|
-
await
|
|
25221
|
+
await updateDoc39(docRef, {
|
|
25213
25222
|
benefits: updatedBenefits,
|
|
25214
25223
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25215
25224
|
});
|
|
@@ -25238,7 +25247,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25238
25247
|
}
|
|
25239
25248
|
const updatedBenefits = [...benefits];
|
|
25240
25249
|
updatedBenefits[index] = benefit;
|
|
25241
|
-
await
|
|
25250
|
+
await updateDoc39(docRef, {
|
|
25242
25251
|
benefits: updatedBenefits,
|
|
25243
25252
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25244
25253
|
});
|
|
@@ -25279,7 +25288,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25279
25288
|
*/
|
|
25280
25289
|
async updateCertificationRequirement(technologyId, certificationRequirement) {
|
|
25281
25290
|
const docRef = doc44(this.technologiesRef, technologyId);
|
|
25282
|
-
await
|
|
25291
|
+
await updateDoc39(docRef, {
|
|
25283
25292
|
certificationRequirement,
|
|
25284
25293
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25285
25294
|
});
|
|
@@ -25659,7 +25668,7 @@ import {
|
|
|
25659
25668
|
getDoc as getDoc46,
|
|
25660
25669
|
getDocs as getDocs39,
|
|
25661
25670
|
query as query39,
|
|
25662
|
-
updateDoc as
|
|
25671
|
+
updateDoc as updateDoc40,
|
|
25663
25672
|
where as where39,
|
|
25664
25673
|
limit as limit21,
|
|
25665
25674
|
orderBy as orderBy23,
|
|
@@ -25828,7 +25837,7 @@ var ProductService = class extends BaseService {
|
|
|
25828
25837
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25829
25838
|
};
|
|
25830
25839
|
const docRef = doc45(this.getProductsRef(technologyId), productId);
|
|
25831
|
-
await
|
|
25840
|
+
await updateDoc40(docRef, updateData);
|
|
25832
25841
|
return this.getById(technologyId, productId);
|
|
25833
25842
|
}
|
|
25834
25843
|
/**
|
|
@@ -25925,7 +25934,7 @@ var ProductService = class extends BaseService {
|
|
|
25925
25934
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25926
25935
|
};
|
|
25927
25936
|
const docRef = doc45(this.getTopLevelProductsRef(), productId);
|
|
25928
|
-
await
|
|
25937
|
+
await updateDoc40(docRef, updateData);
|
|
25929
25938
|
return this.getByIdTopLevel(productId);
|
|
25930
25939
|
}
|
|
25931
25940
|
/**
|
|
@@ -25941,7 +25950,7 @@ var ProductService = class extends BaseService {
|
|
|
25941
25950
|
*/
|
|
25942
25951
|
async assignToTechnology(productId, technologyId) {
|
|
25943
25952
|
const docRef = doc45(this.getTopLevelProductsRef(), productId);
|
|
25944
|
-
await
|
|
25953
|
+
await updateDoc40(docRef, {
|
|
25945
25954
|
assignedTechnologyIds: arrayUnion10(technologyId),
|
|
25946
25955
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25947
25956
|
});
|
|
@@ -25951,7 +25960,7 @@ var ProductService = class extends BaseService {
|
|
|
25951
25960
|
*/
|
|
25952
25961
|
async unassignFromTechnology(productId, technologyId) {
|
|
25953
25962
|
const docRef = doc45(this.getTopLevelProductsRef(), productId);
|
|
25954
|
-
await
|
|
25963
|
+
await updateDoc40(docRef, {
|
|
25955
25964
|
assignedTechnologyIds: arrayRemove9(technologyId),
|
|
25956
25965
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25957
25966
|
});
|
|
@@ -26097,7 +26106,7 @@ import {
|
|
|
26097
26106
|
doc as doc46,
|
|
26098
26107
|
getDoc as getDoc47,
|
|
26099
26108
|
setDoc as setDoc30,
|
|
26100
|
-
updateDoc as
|
|
26109
|
+
updateDoc as updateDoc41
|
|
26101
26110
|
} from "firebase/firestore";
|
|
26102
26111
|
var ADMIN_CONSTANTS_COLLECTION = "admin-constants";
|
|
26103
26112
|
var TREATMENT_BENEFITS_DOC = "treatment-benefits";
|
|
@@ -26160,7 +26169,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26160
26169
|
if (!docSnap.exists()) {
|
|
26161
26170
|
await setDoc30(this.treatmentBenefitsDocRef, { benefits: [newBenefit] });
|
|
26162
26171
|
} else {
|
|
26163
|
-
await
|
|
26172
|
+
await updateDoc41(this.treatmentBenefitsDocRef, {
|
|
26164
26173
|
benefits: arrayUnion11(newBenefit)
|
|
26165
26174
|
});
|
|
26166
26175
|
}
|
|
@@ -26200,7 +26209,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26200
26209
|
throw new Error("Treatment benefit not found.");
|
|
26201
26210
|
}
|
|
26202
26211
|
benefits[benefitIndex] = benefit;
|
|
26203
|
-
await
|
|
26212
|
+
await updateDoc41(this.treatmentBenefitsDocRef, { benefits });
|
|
26204
26213
|
return benefit;
|
|
26205
26214
|
}
|
|
26206
26215
|
/**
|
|
@@ -26214,7 +26223,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26214
26223
|
if (!benefitToRemove) {
|
|
26215
26224
|
return;
|
|
26216
26225
|
}
|
|
26217
|
-
await
|
|
26226
|
+
await updateDoc41(this.treatmentBenefitsDocRef, {
|
|
26218
26227
|
benefits: arrayRemove10(benefitToRemove)
|
|
26219
26228
|
});
|
|
26220
26229
|
}
|
|
@@ -26267,7 +26276,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26267
26276
|
contraindications: [newContraindication]
|
|
26268
26277
|
});
|
|
26269
26278
|
} else {
|
|
26270
|
-
await
|
|
26279
|
+
await updateDoc41(this.contraindicationsDocRef, {
|
|
26271
26280
|
contraindications: arrayUnion11(newContraindication)
|
|
26272
26281
|
});
|
|
26273
26282
|
}
|
|
@@ -26309,7 +26318,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26309
26318
|
throw new Error("Contraindication not found.");
|
|
26310
26319
|
}
|
|
26311
26320
|
contraindications[index] = contraindication;
|
|
26312
|
-
await
|
|
26321
|
+
await updateDoc41(this.contraindicationsDocRef, { contraindications });
|
|
26313
26322
|
return contraindication;
|
|
26314
26323
|
}
|
|
26315
26324
|
/**
|
|
@@ -26323,7 +26332,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26323
26332
|
if (!toRemove) {
|
|
26324
26333
|
return;
|
|
26325
26334
|
}
|
|
26326
|
-
await
|
|
26335
|
+
await updateDoc41(this.contraindicationsDocRef, {
|
|
26327
26336
|
contraindications: arrayRemove10(toRemove)
|
|
26328
26337
|
});
|
|
26329
26338
|
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Firestore, collection, doc, addDoc, deleteDoc, getDocs, query, where, serverTimestamp, getDoc } from 'firebase/firestore';
|
|
1
|
+
import { Firestore, collection, doc, addDoc, deleteDoc, getDocs, query, where, serverTimestamp, getDoc, updateDoc } from 'firebase/firestore';
|
|
2
2
|
import {
|
|
3
3
|
DocumentTemplate,
|
|
4
4
|
FilledDocumentStatus,
|
|
@@ -118,6 +118,9 @@ export async function initializeFormsForExtendedProcedure(
|
|
|
118
118
|
const docRef = await addDoc(formsCollectionRef, filledDocumentData);
|
|
119
119
|
const filledDocumentId = docRef.id;
|
|
120
120
|
|
|
121
|
+
// Update the document to include the id field in the data (for consistency)
|
|
122
|
+
await updateDoc(docRef, { id: filledDocumentId });
|
|
123
|
+
|
|
121
124
|
// Add to pendingUserFormsIds if it's a required user form
|
|
122
125
|
if (isUserForm && isRequired) {
|
|
123
126
|
pendingUserFormsIds.push(filledDocumentId);
|
|
@@ -144,7 +144,12 @@ export class FilledDocumentService extends BaseService {
|
|
|
144
144
|
if (!docSnap.exists()) {
|
|
145
145
|
return null;
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
const data = docSnap.data() as FilledDocument;
|
|
148
|
+
// Ensure id is populated from Firestore document ID if not in data
|
|
149
|
+
if (!data.id) {
|
|
150
|
+
data.id = docSnap.id;
|
|
151
|
+
}
|
|
152
|
+
return data;
|
|
148
153
|
}
|
|
149
154
|
|
|
150
155
|
/**
|
|
@@ -287,9 +292,14 @@ export class FilledDocumentService extends BaseService {
|
|
|
287
292
|
const documents: FilledDocument[] = [];
|
|
288
293
|
let lastVisible: QueryDocumentSnapshot<FilledDocument> | null = null;
|
|
289
294
|
|
|
290
|
-
querySnapshot.forEach((
|
|
291
|
-
|
|
292
|
-
|
|
295
|
+
querySnapshot.forEach((docSnapshot) => {
|
|
296
|
+
const data = docSnapshot.data() as FilledDocument;
|
|
297
|
+
// Ensure id is populated from Firestore document ID if not in data
|
|
298
|
+
if (!data.id) {
|
|
299
|
+
data.id = docSnapshot.id;
|
|
300
|
+
}
|
|
301
|
+
documents.push(data);
|
|
302
|
+
lastVisible = docSnapshot as QueryDocumentSnapshot<FilledDocument>;
|
|
293
303
|
});
|
|
294
304
|
|
|
295
305
|
return {
|