@blackcode_sa/metaestetics-api 1.14.49 → 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.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 = [];
|
|
@@ -4882,21 +4882,15 @@ async function initializeFormsForExtendedProcedure(db, appointmentId, procedureI
|
|
|
4882
4882
|
);
|
|
4883
4883
|
continue;
|
|
4884
4884
|
}
|
|
4885
|
-
if (templateRef.isUserForm) {
|
|
4886
|
-
console.log(
|
|
4887
|
-
`[FormInit] Skipping user form ${templateRef.templateId} for extended procedure ${procedureId}.`
|
|
4888
|
-
);
|
|
4889
|
-
continue;
|
|
4890
|
-
}
|
|
4891
4885
|
const isRequired = templateRef.isRequired;
|
|
4892
|
-
const
|
|
4886
|
+
const isUserForm = templateRef.isUserForm || false;
|
|
4887
|
+
const formSubcollectionPath = isUserForm ? USER_FORMS_SUBCOLLECTION : DOCTOR_FORMS_SUBCOLLECTION;
|
|
4893
4888
|
const appointmentRef = doc6(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
4894
4889
|
const formsCollectionRef = collection5(appointmentRef, formSubcollectionPath);
|
|
4895
4890
|
const filledDocumentData = {
|
|
4896
4891
|
templateId: templateRef.templateId,
|
|
4897
4892
|
templateVersion: template.version,
|
|
4898
|
-
isUserForm
|
|
4899
|
-
// Always false for extended procedures
|
|
4893
|
+
isUserForm,
|
|
4900
4894
|
isRequired,
|
|
4901
4895
|
appointmentId,
|
|
4902
4896
|
procedureId,
|
|
@@ -4911,14 +4905,17 @@ async function initializeFormsForExtendedProcedure(db, appointmentId, procedureI
|
|
|
4911
4905
|
try {
|
|
4912
4906
|
const docRef = await addDoc(formsCollectionRef, filledDocumentData);
|
|
4913
4907
|
const filledDocumentId = docRef.id;
|
|
4908
|
+
await updateDoc4(docRef, { id: filledDocumentId });
|
|
4909
|
+
if (isUserForm && isRequired) {
|
|
4910
|
+
pendingUserFormsIds.push(filledDocumentId);
|
|
4911
|
+
}
|
|
4914
4912
|
allLinkedFormIds.push(filledDocumentId);
|
|
4915
4913
|
const linkedForm = {
|
|
4916
4914
|
formId: filledDocumentId,
|
|
4917
4915
|
templateId: template.id,
|
|
4918
4916
|
templateVersion: template.version,
|
|
4919
4917
|
title: template.title,
|
|
4920
|
-
isUserForm
|
|
4921
|
-
// Always false for extended procedures
|
|
4918
|
+
isUserForm,
|
|
4922
4919
|
isRequired,
|
|
4923
4920
|
sortingOrder: templateRef.sortingOrder,
|
|
4924
4921
|
status: "pending" /* PENDING */,
|
|
@@ -4926,7 +4923,7 @@ async function initializeFormsForExtendedProcedure(db, appointmentId, procedureI
|
|
|
4926
4923
|
};
|
|
4927
4924
|
initializedFormsInfo.push(linkedForm);
|
|
4928
4925
|
console.log(
|
|
4929
|
-
`[FormInit] Created FilledDocument ${filledDocumentId} (template: ${template.id}) for extended procedure ${procedureId} in appointment ${appointmentId}.`
|
|
4926
|
+
`[FormInit] Created FilledDocument ${filledDocumentId} (template: ${template.id}, isUserForm: ${isUserForm}) for extended procedure ${procedureId} in appointment ${appointmentId}.`
|
|
4930
4927
|
);
|
|
4931
4928
|
} catch (error) {
|
|
4932
4929
|
console.error(
|
|
@@ -4960,6 +4957,26 @@ async function removeFormsForExtendedProcedure(db, appointmentId, procedureId) {
|
|
|
4960
4957
|
);
|
|
4961
4958
|
}
|
|
4962
4959
|
}
|
|
4960
|
+
const userFormsRef = collection5(appointmentRef, USER_FORMS_SUBCOLLECTION);
|
|
4961
|
+
const userFormsQuery = query5(
|
|
4962
|
+
userFormsRef,
|
|
4963
|
+
where5("procedureId", "==", procedureId)
|
|
4964
|
+
);
|
|
4965
|
+
const userFormsSnap = await getDocs5(userFormsQuery);
|
|
4966
|
+
for (const formDoc of userFormsSnap.docs) {
|
|
4967
|
+
try {
|
|
4968
|
+
await deleteDoc2(formDoc.ref);
|
|
4969
|
+
removedFormIds.push(formDoc.id);
|
|
4970
|
+
console.log(
|
|
4971
|
+
`[FormInit] Removed user form ${formDoc.id} for extended procedure ${procedureId} from appointment ${appointmentId}.`
|
|
4972
|
+
);
|
|
4973
|
+
} catch (error) {
|
|
4974
|
+
console.error(
|
|
4975
|
+
`[FormInit] Error removing user form ${formDoc.id}:`,
|
|
4976
|
+
error
|
|
4977
|
+
);
|
|
4978
|
+
}
|
|
4979
|
+
}
|
|
4963
4980
|
return removedFormIds;
|
|
4964
4981
|
}
|
|
4965
4982
|
|
|
@@ -5079,7 +5096,7 @@ async function addExtendedProcedureUtil(db, appointmentId, procedureId) {
|
|
|
5079
5096
|
}
|
|
5080
5097
|
const extendedProcedures = [...metadata.extendedProcedures || [], extendedProcedureInfo];
|
|
5081
5098
|
const appointmentRef = doc7(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5082
|
-
await
|
|
5099
|
+
await updateDoc5(appointmentRef, {
|
|
5083
5100
|
"metadata.extendedProcedures": extendedProcedures,
|
|
5084
5101
|
"metadata.appointmentProducts": updatedProducts,
|
|
5085
5102
|
linkedFormIds: updatedLinkedFormIds,
|
|
@@ -5128,7 +5145,7 @@ async function removeExtendedProcedureUtil(db, appointmentId, procedureId) {
|
|
|
5128
5145
|
(formId) => !removedFormIds.includes(formId)
|
|
5129
5146
|
);
|
|
5130
5147
|
const appointmentRef = doc7(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5131
|
-
await
|
|
5148
|
+
await updateDoc5(appointmentRef, {
|
|
5132
5149
|
"metadata.extendedProcedures": metadata.extendedProcedures,
|
|
5133
5150
|
"metadata.appointmentProducts": updatedProducts,
|
|
5134
5151
|
"metadata.zonesData": updatedZonesData,
|
|
@@ -5151,7 +5168,7 @@ async function getAppointmentProductsUtil(db, appointmentId) {
|
|
|
5151
5168
|
}
|
|
5152
5169
|
|
|
5153
5170
|
// src/services/appointment/utils/recommended-procedure.utils.ts
|
|
5154
|
-
import { updateDoc as
|
|
5171
|
+
import { updateDoc as updateDoc6, serverTimestamp as serverTimestamp5, doc as doc8 } from "firebase/firestore";
|
|
5155
5172
|
import { getDoc as getDoc8 } from "firebase/firestore";
|
|
5156
5173
|
async function createExtendedProcedureInfoForRecommended(db, procedureId) {
|
|
5157
5174
|
const procedureRef = doc8(db, PROCEDURES_COLLECTION, procedureId);
|
|
@@ -5189,7 +5206,7 @@ async function addRecommendedProcedureUtil(db, appointmentId, procedureId, note,
|
|
|
5189
5206
|
};
|
|
5190
5207
|
const recommendedProcedures = [...metadata.recommendedProcedures || [], recommendedProcedure];
|
|
5191
5208
|
const appointmentRef = doc8(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5192
|
-
await
|
|
5209
|
+
await updateDoc6(appointmentRef, {
|
|
5193
5210
|
"metadata.recommendedProcedures": recommendedProcedures,
|
|
5194
5211
|
updatedAt: serverTimestamp5()
|
|
5195
5212
|
});
|
|
@@ -5207,7 +5224,7 @@ async function removeRecommendedProcedureUtil(db, appointmentId, recommendationI
|
|
|
5207
5224
|
const updatedRecommendedProcedures = [...metadata.recommendedProcedures];
|
|
5208
5225
|
updatedRecommendedProcedures.splice(recommendationIndex, 1);
|
|
5209
5226
|
const appointmentRef = doc8(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5210
|
-
await
|
|
5227
|
+
await updateDoc6(appointmentRef, {
|
|
5211
5228
|
"metadata.recommendedProcedures": updatedRecommendedProcedures,
|
|
5212
5229
|
updatedAt: serverTimestamp5()
|
|
5213
5230
|
});
|
|
@@ -5230,7 +5247,7 @@ async function updateRecommendedProcedureUtil(db, appointmentId, recommendationI
|
|
|
5230
5247
|
...updates.timeframe !== void 0 && { timeframe: updates.timeframe }
|
|
5231
5248
|
};
|
|
5232
5249
|
const appointmentRef = doc8(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5233
|
-
await
|
|
5250
|
+
await updateDoc6(appointmentRef, {
|
|
5234
5251
|
"metadata.recommendedProcedures": updatedRecommendedProcedures,
|
|
5235
5252
|
updatedAt: serverTimestamp5()
|
|
5236
5253
|
});
|
|
@@ -5243,7 +5260,7 @@ async function getRecommendedProceduresUtil(db, appointmentId) {
|
|
|
5243
5260
|
}
|
|
5244
5261
|
|
|
5245
5262
|
// src/services/appointment/utils/zone-photo.utils.ts
|
|
5246
|
-
import { updateDoc as
|
|
5263
|
+
import { updateDoc as updateDoc7, serverTimestamp as serverTimestamp6, doc as doc9, Timestamp as Timestamp6 } from "firebase/firestore";
|
|
5247
5264
|
function addVisibilityAudit(updates, doctorId) {
|
|
5248
5265
|
if (updates.showToPatient !== void 0 || updates.beforeNoteVisibleToPatient !== void 0 || updates.afterNoteVisibleToPatient !== void 0) {
|
|
5249
5266
|
return {
|
|
@@ -5274,7 +5291,7 @@ async function updateZonePhotoEntryUtil(db, appointmentId, zoneId, photoIndex, u
|
|
|
5274
5291
|
...updatesWithAudit
|
|
5275
5292
|
};
|
|
5276
5293
|
const appointmentRef = doc9(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
5277
|
-
await
|
|
5294
|
+
await updateDoc7(appointmentRef, {
|
|
5278
5295
|
"metadata.zonePhotos": updatedZonePhotos,
|
|
5279
5296
|
updatedAt: serverTimestamp6()
|
|
5280
5297
|
});
|
|
@@ -7742,7 +7759,7 @@ import {
|
|
|
7742
7759
|
getDocs as getDocs14,
|
|
7743
7760
|
query as query14,
|
|
7744
7761
|
where as where14,
|
|
7745
|
-
updateDoc as
|
|
7762
|
+
updateDoc as updateDoc18,
|
|
7746
7763
|
deleteDoc as deleteDoc5,
|
|
7747
7764
|
Timestamp as Timestamp19,
|
|
7748
7765
|
setDoc as setDoc12,
|
|
@@ -7849,7 +7866,7 @@ import {
|
|
|
7849
7866
|
doc as doc19,
|
|
7850
7867
|
getDoc as getDoc21,
|
|
7851
7868
|
writeBatch,
|
|
7852
|
-
updateDoc as
|
|
7869
|
+
updateDoc as updateDoc16,
|
|
7853
7870
|
serverTimestamp as serverTimestamp16
|
|
7854
7871
|
} from "firebase/firestore";
|
|
7855
7872
|
import { Timestamp as Timestamp16 } from "firebase/firestore";
|
|
@@ -7877,7 +7894,7 @@ import {
|
|
|
7877
7894
|
} from "firebase/firestore";
|
|
7878
7895
|
|
|
7879
7896
|
// src/services/patient/utils/sensitive.utils.ts
|
|
7880
|
-
import { getDoc as getDoc12, updateDoc as
|
|
7897
|
+
import { getDoc as getDoc12, updateDoc as updateDoc9, setDoc as setDoc4, serverTimestamp as serverTimestamp9 } from "firebase/firestore";
|
|
7881
7898
|
|
|
7882
7899
|
// src/validations/patient.schema.ts
|
|
7883
7900
|
import { z as z7 } from "zod";
|
|
@@ -8347,7 +8364,7 @@ import {
|
|
|
8347
8364
|
getDocs as getDocs8,
|
|
8348
8365
|
query as query8,
|
|
8349
8366
|
where as where8,
|
|
8350
|
-
updateDoc as
|
|
8367
|
+
updateDoc as updateDoc8,
|
|
8351
8368
|
setDoc as setDoc3,
|
|
8352
8369
|
deleteDoc as deleteDoc3,
|
|
8353
8370
|
Timestamp as Timestamp11,
|
|
@@ -9082,7 +9099,7 @@ async function updateClinicAdmin(db, adminId, data) {
|
|
|
9082
9099
|
...data,
|
|
9083
9100
|
updatedAt: serverTimestamp8()
|
|
9084
9101
|
};
|
|
9085
|
-
await
|
|
9102
|
+
await updateDoc8(doc12(db, CLINIC_ADMINS_COLLECTION, adminId), updatedData);
|
|
9086
9103
|
const updatedAdmin = await getClinicAdmin(db, adminId);
|
|
9087
9104
|
if (!updatedAdmin) {
|
|
9088
9105
|
throw new Error("Failed to retrieve updated admin");
|
|
@@ -9324,7 +9341,7 @@ var updateSensitiveInfoUtil = async (db, patientId, data, requesterId, requester
|
|
|
9324
9341
|
photoUrl: processedPhotoUrl,
|
|
9325
9342
|
updatedAt: serverTimestamp9()
|
|
9326
9343
|
};
|
|
9327
|
-
await
|
|
9344
|
+
await updateDoc9(getSensitiveInfoDocRef(db, patientId), updateData);
|
|
9328
9345
|
const updatedDoc = await getDoc12(getSensitiveInfoDocRef(db, patientId));
|
|
9329
9346
|
if (!updatedDoc.exists()) {
|
|
9330
9347
|
throw new Error("Failed to retrieve updated sensitive information");
|
|
@@ -9351,7 +9368,7 @@ var claimPatientSensitiveInfoUtil = async (db, patientId, userId) => {
|
|
|
9351
9368
|
if (sensitiveData.userRef) {
|
|
9352
9369
|
throw new Error("Patient sensitive information has already been claimed");
|
|
9353
9370
|
}
|
|
9354
|
-
await
|
|
9371
|
+
await updateDoc9(getSensitiveInfoDocRef(db, patientId), {
|
|
9355
9372
|
userRef: userId,
|
|
9356
9373
|
updatedAt: serverTimestamp9()
|
|
9357
9374
|
});
|
|
@@ -9549,7 +9566,7 @@ var getPatientsByClinicWithDetailsUtil = async (db, clinicId, options) => {
|
|
|
9549
9566
|
// src/services/patient/utils/location.utils.ts
|
|
9550
9567
|
import {
|
|
9551
9568
|
getDoc as getDoc15,
|
|
9552
|
-
updateDoc as
|
|
9569
|
+
updateDoc as updateDoc10,
|
|
9553
9570
|
setDoc as setDoc6,
|
|
9554
9571
|
serverTimestamp as serverTimestamp11
|
|
9555
9572
|
} from "firebase/firestore";
|
|
@@ -9565,7 +9582,7 @@ var updatePatientLocationUtil = async (db, patientId, latitude, longitude) => {
|
|
|
9565
9582
|
locationData,
|
|
9566
9583
|
updatedAt: serverTimestamp11()
|
|
9567
9584
|
};
|
|
9568
|
-
await
|
|
9585
|
+
await updateDoc10(getLocationInfoDocRef(db, patientId), updateData);
|
|
9569
9586
|
};
|
|
9570
9587
|
var createLocationInfoUtil = async (db, data, requesterId) => {
|
|
9571
9588
|
try {
|
|
@@ -9620,7 +9637,7 @@ var updateLocationInfoUtil = async (db, patientId, data, requesterId) => {
|
|
|
9620
9637
|
};
|
|
9621
9638
|
}
|
|
9622
9639
|
updateData.updatedAt = serverTimestamp11();
|
|
9623
|
-
await
|
|
9640
|
+
await updateDoc10(getLocationInfoDocRef(db, patientId), updateData);
|
|
9624
9641
|
const updatedInfo = await getLocationInfoUtil(db, patientId, requesterId);
|
|
9625
9642
|
if (!updatedInfo) {
|
|
9626
9643
|
throw new Error("Failed to retrieve updated location information");
|
|
@@ -9631,7 +9648,7 @@ var updateLocationInfoUtil = async (db, patientId, data, requesterId) => {
|
|
|
9631
9648
|
// src/services/patient/utils/medical-stuff.utils.ts
|
|
9632
9649
|
import {
|
|
9633
9650
|
getDoc as getDoc16,
|
|
9634
|
-
updateDoc as
|
|
9651
|
+
updateDoc as updateDoc11,
|
|
9635
9652
|
arrayUnion as arrayUnion2,
|
|
9636
9653
|
arrayRemove as arrayRemove2,
|
|
9637
9654
|
serverTimestamp as serverTimestamp12,
|
|
@@ -9667,7 +9684,7 @@ var addDoctorUtil = async (db, patientId, doctorRef, assignedBy) => {
|
|
|
9667
9684
|
} else {
|
|
9668
9685
|
updates.doctors = arrayUnion2(newDoctor);
|
|
9669
9686
|
}
|
|
9670
|
-
await
|
|
9687
|
+
await updateDoc11(getPatientDocRef(db, patientId), updates);
|
|
9671
9688
|
};
|
|
9672
9689
|
var removeDoctorUtil = async (db, patientId, doctorRef) => {
|
|
9673
9690
|
var _a;
|
|
@@ -9676,7 +9693,7 @@ var removeDoctorUtil = async (db, patientId, doctorRef) => {
|
|
|
9676
9693
|
if (!patientDoc.exists()) throw new Error("Patient profile not found");
|
|
9677
9694
|
const patientData = patientDoc.data();
|
|
9678
9695
|
const updatedDoctors = ((_a = patientData.doctors) == null ? void 0 : _a.filter((doctor) => doctor.userRef !== doctorRef)) || [];
|
|
9679
|
-
await
|
|
9696
|
+
await updateDoc11(patientDocRef, {
|
|
9680
9697
|
doctors: updatedDoctors,
|
|
9681
9698
|
// Set the filtered array
|
|
9682
9699
|
doctorIds: arrayRemove2(doctorRef),
|
|
@@ -9714,7 +9731,7 @@ var addClinicUtil = async (db, patientId, clinicId, assignedBy) => {
|
|
|
9714
9731
|
} else {
|
|
9715
9732
|
updates.clinics = arrayUnion2(newClinic);
|
|
9716
9733
|
}
|
|
9717
|
-
await
|
|
9734
|
+
await updateDoc11(getPatientDocRef(db, patientId), updates);
|
|
9718
9735
|
};
|
|
9719
9736
|
var removeClinicUtil = async (db, patientId, clinicId) => {
|
|
9720
9737
|
var _a;
|
|
@@ -9723,7 +9740,7 @@ var removeClinicUtil = async (db, patientId, clinicId) => {
|
|
|
9723
9740
|
if (!patientDoc.exists()) throw new Error("Patient profile not found");
|
|
9724
9741
|
const patientData = patientDoc.data();
|
|
9725
9742
|
const updatedClinics = ((_a = patientData.clinics) == null ? void 0 : _a.filter((clinic) => clinic.clinicId !== clinicId)) || [];
|
|
9726
|
-
await
|
|
9743
|
+
await updateDoc11(patientDocRef, {
|
|
9727
9744
|
clinics: updatedClinics,
|
|
9728
9745
|
// Set the filtered array
|
|
9729
9746
|
clinicIds: arrayRemove2(clinicId),
|
|
@@ -9735,7 +9752,7 @@ var removeClinicUtil = async (db, patientId, clinicId) => {
|
|
|
9735
9752
|
// src/services/patient/utils/medical.utils.ts
|
|
9736
9753
|
import {
|
|
9737
9754
|
getDoc as getDoc17,
|
|
9738
|
-
updateDoc as
|
|
9755
|
+
updateDoc as updateDoc12,
|
|
9739
9756
|
setDoc as setDoc7,
|
|
9740
9757
|
serverTimestamp as serverTimestamp13,
|
|
9741
9758
|
arrayUnion as arrayUnion3
|
|
@@ -9818,7 +9835,7 @@ var updateVitalStatsUtil = async (db, patientId, data, requesterId, requesterRol
|
|
|
9818
9835
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
9819
9836
|
await ensureMedicalInfoExists(db, patientId, requesterId);
|
|
9820
9837
|
const validatedData = updateVitalStatsSchema.parse(data);
|
|
9821
|
-
await
|
|
9838
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9822
9839
|
vitalStats: validatedData,
|
|
9823
9840
|
lastUpdated: serverTimestamp13(),
|
|
9824
9841
|
updatedBy: requesterId
|
|
@@ -9828,7 +9845,7 @@ var addAllergyUtil = async (db, patientId, data, requesterId, requesterRoles) =>
|
|
|
9828
9845
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
9829
9846
|
await ensureMedicalInfoExists(db, patientId, requesterId);
|
|
9830
9847
|
const validatedData = addAllergySchema.parse(data);
|
|
9831
|
-
await
|
|
9848
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9832
9849
|
allergies: arrayUnion3(validatedData),
|
|
9833
9850
|
lastUpdated: serverTimestamp13(),
|
|
9834
9851
|
updatedBy: requesterId
|
|
@@ -9849,7 +9866,7 @@ var updateAllergyUtil = async (db, patientId, data, requesterId, requesterRoles)
|
|
|
9849
9866
|
...updatedAllergies[allergyIndex],
|
|
9850
9867
|
...updateData
|
|
9851
9868
|
};
|
|
9852
|
-
await
|
|
9869
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9853
9870
|
allergies: updatedAllergies,
|
|
9854
9871
|
lastUpdated: serverTimestamp13(),
|
|
9855
9872
|
updatedBy: requesterId
|
|
@@ -9866,7 +9883,7 @@ var removeAllergyUtil = async (db, patientId, allergyIndex, requesterId, request
|
|
|
9866
9883
|
const updatedAllergies = medicalInfo.allergies.filter(
|
|
9867
9884
|
(_, index) => index !== allergyIndex
|
|
9868
9885
|
);
|
|
9869
|
-
await
|
|
9886
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9870
9887
|
allergies: updatedAllergies,
|
|
9871
9888
|
lastUpdated: serverTimestamp13(),
|
|
9872
9889
|
updatedBy: requesterId
|
|
@@ -9876,7 +9893,7 @@ var addBlockingConditionUtil = async (db, patientId, data, requesterId, requeste
|
|
|
9876
9893
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
9877
9894
|
await ensureMedicalInfoExists(db, patientId, requesterId);
|
|
9878
9895
|
const validatedData = addBlockingConditionSchema.parse(data);
|
|
9879
|
-
await
|
|
9896
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9880
9897
|
blockingConditions: arrayUnion3(validatedData),
|
|
9881
9898
|
lastUpdated: serverTimestamp13(),
|
|
9882
9899
|
updatedBy: requesterId
|
|
@@ -9897,7 +9914,7 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
|
|
|
9897
9914
|
...updatedConditions[conditionIndex],
|
|
9898
9915
|
...updateData
|
|
9899
9916
|
};
|
|
9900
|
-
await
|
|
9917
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9901
9918
|
blockingConditions: updatedConditions,
|
|
9902
9919
|
lastUpdated: serverTimestamp13(),
|
|
9903
9920
|
updatedBy: requesterId
|
|
@@ -9914,7 +9931,7 @@ var removeBlockingConditionUtil = async (db, patientId, conditionIndex, requeste
|
|
|
9914
9931
|
const updatedConditions = medicalInfo.blockingConditions.filter(
|
|
9915
9932
|
(_, index) => index !== conditionIndex
|
|
9916
9933
|
);
|
|
9917
|
-
await
|
|
9934
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9918
9935
|
blockingConditions: updatedConditions,
|
|
9919
9936
|
lastUpdated: serverTimestamp13(),
|
|
9920
9937
|
updatedBy: requesterId
|
|
@@ -9924,7 +9941,7 @@ var addContraindicationUtil = async (db, patientId, data, requesterId, requester
|
|
|
9924
9941
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
9925
9942
|
await ensureMedicalInfoExists(db, patientId, requesterId);
|
|
9926
9943
|
const validatedData = addContraindicationSchema.parse(data);
|
|
9927
|
-
await
|
|
9944
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9928
9945
|
contraindications: arrayUnion3(validatedData),
|
|
9929
9946
|
lastUpdated: serverTimestamp13(),
|
|
9930
9947
|
updatedBy: requesterId
|
|
@@ -9945,7 +9962,7 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
|
|
|
9945
9962
|
...updatedContraindications[contraindicationIndex],
|
|
9946
9963
|
...updateData
|
|
9947
9964
|
};
|
|
9948
|
-
await
|
|
9965
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9949
9966
|
contraindications: updatedContraindications,
|
|
9950
9967
|
lastUpdated: serverTimestamp13(),
|
|
9951
9968
|
updatedBy: requesterId
|
|
@@ -9962,7 +9979,7 @@ var removeContraindicationUtil = async (db, patientId, contraindicationIndex, re
|
|
|
9962
9979
|
const updatedContraindications = medicalInfo.contraindications.filter(
|
|
9963
9980
|
(_, index) => index !== contraindicationIndex
|
|
9964
9981
|
);
|
|
9965
|
-
await
|
|
9982
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9966
9983
|
contraindications: updatedContraindications,
|
|
9967
9984
|
lastUpdated: serverTimestamp13(),
|
|
9968
9985
|
updatedBy: requesterId
|
|
@@ -9972,7 +9989,7 @@ var addMedicationUtil = async (db, patientId, data, requesterId, requesterRoles)
|
|
|
9972
9989
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
9973
9990
|
await ensureMedicalInfoExists(db, patientId, requesterId);
|
|
9974
9991
|
const validatedData = addMedicationSchema.parse(data);
|
|
9975
|
-
await
|
|
9992
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9976
9993
|
currentMedications: arrayUnion3(validatedData),
|
|
9977
9994
|
lastUpdated: serverTimestamp13(),
|
|
9978
9995
|
updatedBy: requesterId
|
|
@@ -9993,7 +10010,7 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
|
|
|
9993
10010
|
...updatedMedications[medicationIndex],
|
|
9994
10011
|
...updateData
|
|
9995
10012
|
};
|
|
9996
|
-
await
|
|
10013
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
9997
10014
|
currentMedications: updatedMedications,
|
|
9998
10015
|
lastUpdated: serverTimestamp13(),
|
|
9999
10016
|
updatedBy: requesterId
|
|
@@ -10010,7 +10027,7 @@ var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, r
|
|
|
10010
10027
|
const updatedMedications = medicalInfo.currentMedications.filter(
|
|
10011
10028
|
(_, index) => index !== medicationIndex
|
|
10012
10029
|
);
|
|
10013
|
-
await
|
|
10030
|
+
await updateDoc12(getMedicalInfoDocRef(db, patientId), {
|
|
10014
10031
|
currentMedications: updatedMedications,
|
|
10015
10032
|
lastUpdated: serverTimestamp13(),
|
|
10016
10033
|
updatedBy: requesterId
|
|
@@ -10021,7 +10038,7 @@ var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, r
|
|
|
10021
10038
|
import {
|
|
10022
10039
|
getDoc as getDoc18,
|
|
10023
10040
|
setDoc as setDoc8,
|
|
10024
|
-
updateDoc as
|
|
10041
|
+
updateDoc as updateDoc13,
|
|
10025
10042
|
arrayUnion as arrayUnion4,
|
|
10026
10043
|
arrayRemove as arrayRemove4,
|
|
10027
10044
|
serverTimestamp as serverTimestamp14,
|
|
@@ -10158,19 +10175,19 @@ var getPatientProfileByUserRefUtil = async (db, userRef) => {
|
|
|
10158
10175
|
}
|
|
10159
10176
|
};
|
|
10160
10177
|
var addExpoTokenUtil = async (db, patientId, token) => {
|
|
10161
|
-
await
|
|
10178
|
+
await updateDoc13(getPatientDocRef(db, patientId), {
|
|
10162
10179
|
expoTokens: arrayUnion4(token),
|
|
10163
10180
|
updatedAt: serverTimestamp14()
|
|
10164
10181
|
});
|
|
10165
10182
|
};
|
|
10166
10183
|
var removeExpoTokenUtil = async (db, patientId, token) => {
|
|
10167
|
-
await
|
|
10184
|
+
await updateDoc13(getPatientDocRef(db, patientId), {
|
|
10168
10185
|
expoTokens: arrayRemove4(token),
|
|
10169
10186
|
updatedAt: serverTimestamp14()
|
|
10170
10187
|
});
|
|
10171
10188
|
};
|
|
10172
10189
|
var addPointsUtil = async (db, patientId, points) => {
|
|
10173
|
-
await
|
|
10190
|
+
await updateDoc13(getPatientDocRef(db, patientId), {
|
|
10174
10191
|
"gamification.points": increment(points),
|
|
10175
10192
|
updatedAt: serverTimestamp14()
|
|
10176
10193
|
});
|
|
@@ -10181,7 +10198,7 @@ var updatePatientProfileUtil = async (db, patientId, data) => {
|
|
|
10181
10198
|
...data,
|
|
10182
10199
|
updatedAt: serverTimestamp14()
|
|
10183
10200
|
};
|
|
10184
|
-
await
|
|
10201
|
+
await updateDoc13(getPatientDocRef(db, patientId), updateData);
|
|
10185
10202
|
const updatedDoc = await getDoc18(getPatientDocRef(db, patientId));
|
|
10186
10203
|
if (!updatedDoc.exists()) {
|
|
10187
10204
|
throw new Error("Patient profile not found after update");
|
|
@@ -10360,7 +10377,7 @@ import {
|
|
|
10360
10377
|
query as query12,
|
|
10361
10378
|
where as where12,
|
|
10362
10379
|
setDoc as setDoc9,
|
|
10363
|
-
updateDoc as
|
|
10380
|
+
updateDoc as updateDoc14,
|
|
10364
10381
|
Timestamp as Timestamp15,
|
|
10365
10382
|
collectionGroup
|
|
10366
10383
|
} from "firebase/firestore";
|
|
@@ -10455,7 +10472,7 @@ var markPatientTokenAsUsedUtil = async (db, tokenId, patientId, userId) => {
|
|
|
10455
10472
|
INVITE_TOKENS_COLLECTION,
|
|
10456
10473
|
tokenId
|
|
10457
10474
|
);
|
|
10458
|
-
await
|
|
10475
|
+
await updateDoc14(tokenRef, {
|
|
10459
10476
|
status: "used" /* USED */,
|
|
10460
10477
|
usedBy: userId,
|
|
10461
10478
|
usedAt: Timestamp15.now()
|
|
@@ -10494,7 +10511,7 @@ var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
|
|
|
10494
10511
|
};
|
|
10495
10512
|
|
|
10496
10513
|
// src/services/patient/utils/aesthetic-analysis.utils.ts
|
|
10497
|
-
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";
|
|
10498
10515
|
|
|
10499
10516
|
// src/validations/patient/aesthetic-analysis.schema.ts
|
|
10500
10517
|
import { z as z15 } from "zod";
|
|
@@ -10649,7 +10666,7 @@ var createOrUpdateAestheticAnalysisUtil = async (db, patientId, data, requesterI
|
|
|
10649
10666
|
updatedAt: serverTimestamp15()
|
|
10650
10667
|
});
|
|
10651
10668
|
} else {
|
|
10652
|
-
await
|
|
10669
|
+
await updateDoc15(docRef, {
|
|
10653
10670
|
...validatedData,
|
|
10654
10671
|
completionPercentage,
|
|
10655
10672
|
status,
|
|
@@ -10995,7 +11012,7 @@ var PatientService = class extends BaseService {
|
|
|
10995
11012
|
"patient_profile_photos",
|
|
10996
11013
|
file instanceof File ? file.name : `profile_photo_${patientId}`
|
|
10997
11014
|
);
|
|
10998
|
-
await
|
|
11015
|
+
await updateDoc16(getSensitiveInfoDocRef(this.db, patientId), {
|
|
10999
11016
|
photoUrl: mediaMetadata.url,
|
|
11000
11017
|
updatedAt: serverTimestamp16()
|
|
11001
11018
|
});
|
|
@@ -11050,7 +11067,7 @@ var PatientService = class extends BaseService {
|
|
|
11050
11067
|
error
|
|
11051
11068
|
);
|
|
11052
11069
|
}
|
|
11053
|
-
await
|
|
11070
|
+
await updateDoc16(getSensitiveInfoDocRef(this.db, patientId), {
|
|
11054
11071
|
photoUrl: null,
|
|
11055
11072
|
updatedAt: serverTimestamp16()
|
|
11056
11073
|
});
|
|
@@ -11377,7 +11394,7 @@ import {
|
|
|
11377
11394
|
getDocs as getDocs13,
|
|
11378
11395
|
query as query13,
|
|
11379
11396
|
where as where13,
|
|
11380
|
-
updateDoc as
|
|
11397
|
+
updateDoc as updateDoc17,
|
|
11381
11398
|
setDoc as setDoc11,
|
|
11382
11399
|
deleteDoc as deleteDoc4,
|
|
11383
11400
|
Timestamp as Timestamp18,
|
|
@@ -11969,7 +11986,7 @@ var PractitionerService = class extends BaseService {
|
|
|
11969
11986
|
this.db,
|
|
11970
11987
|
`${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${tokenId}`
|
|
11971
11988
|
);
|
|
11972
|
-
await
|
|
11989
|
+
await updateDoc17(tokenRef, {
|
|
11973
11990
|
status: "used" /* USED */,
|
|
11974
11991
|
usedBy: userId,
|
|
11975
11992
|
usedAt: Timestamp18.now()
|
|
@@ -11998,7 +12015,7 @@ var PractitionerService = class extends BaseService {
|
|
|
11998
12015
|
if (tokenData.status !== "active" /* ACTIVE */) {
|
|
11999
12016
|
throw new Error("Token is not active and cannot be revoked");
|
|
12000
12017
|
}
|
|
12001
|
-
await
|
|
12018
|
+
await updateDoc17(tokenRef, {
|
|
12002
12019
|
status: "revoked" /* REVOKED */,
|
|
12003
12020
|
updatedAt: serverTimestamp17()
|
|
12004
12021
|
});
|
|
@@ -12396,7 +12413,7 @@ var PractitionerService = class extends BaseService {
|
|
|
12396
12413
|
...processedData,
|
|
12397
12414
|
updatedAt: serverTimestamp17()
|
|
12398
12415
|
};
|
|
12399
|
-
await
|
|
12416
|
+
await updateDoc17(practitionerRef, updateData);
|
|
12400
12417
|
const updatedPractitioner = await this.getPractitioner(practitionerId);
|
|
12401
12418
|
if (!updatedPractitioner) {
|
|
12402
12419
|
throw new Error(
|
|
@@ -12434,7 +12451,7 @@ var PractitionerService = class extends BaseService {
|
|
|
12434
12451
|
);
|
|
12435
12452
|
return;
|
|
12436
12453
|
}
|
|
12437
|
-
await
|
|
12454
|
+
await updateDoc17(practitionerRef, {
|
|
12438
12455
|
clinics: arrayUnion6(clinicId),
|
|
12439
12456
|
updatedAt: serverTimestamp17()
|
|
12440
12457
|
});
|
|
@@ -12460,7 +12477,7 @@ var PractitionerService = class extends BaseService {
|
|
|
12460
12477
|
if (!practitionerDoc.exists()) {
|
|
12461
12478
|
throw new Error(`Practitioner ${practitionerId} not found`);
|
|
12462
12479
|
}
|
|
12463
|
-
await
|
|
12480
|
+
await updateDoc17(practitionerRef, {
|
|
12464
12481
|
clinics: arrayRemove5(clinicId),
|
|
12465
12482
|
updatedAt: serverTimestamp17()
|
|
12466
12483
|
});
|
|
@@ -13277,7 +13294,7 @@ var UserService = class extends BaseService {
|
|
|
13277
13294
|
return this.getUserById(userData.uid);
|
|
13278
13295
|
}
|
|
13279
13296
|
const profiles = await this.createProfilesForRoles(userData.uid, roles, options);
|
|
13280
|
-
await
|
|
13297
|
+
await updateDoc18(doc21(this.db, USERS_COLLECTION, userData.uid), profiles);
|
|
13281
13298
|
return this.getUserById(userData.uid);
|
|
13282
13299
|
}
|
|
13283
13300
|
/**
|
|
@@ -13444,7 +13461,7 @@ var UserService = class extends BaseService {
|
|
|
13444
13461
|
if (!userDoc.exists()) {
|
|
13445
13462
|
throw AUTH_ERRORS.USER_NOT_FOUND;
|
|
13446
13463
|
}
|
|
13447
|
-
await
|
|
13464
|
+
await updateDoc18(userRef, {
|
|
13448
13465
|
lastLoginAt: serverTimestamp18(),
|
|
13449
13466
|
updatedAt: serverTimestamp18()
|
|
13450
13467
|
});
|
|
@@ -13456,7 +13473,7 @@ var UserService = class extends BaseService {
|
|
|
13456
13473
|
if (!userDoc.exists()) {
|
|
13457
13474
|
throw USER_ERRORS.NOT_FOUND;
|
|
13458
13475
|
}
|
|
13459
|
-
await
|
|
13476
|
+
await updateDoc18(userRef, {
|
|
13460
13477
|
email,
|
|
13461
13478
|
isAnonymous: false,
|
|
13462
13479
|
updatedAt: serverTimestamp18()
|
|
@@ -13477,7 +13494,7 @@ var UserService = class extends BaseService {
|
|
|
13477
13494
|
updatedAt: serverTimestamp18()
|
|
13478
13495
|
};
|
|
13479
13496
|
userSchema.parse(updatedUser);
|
|
13480
|
-
await
|
|
13497
|
+
await updateDoc18(userRef, {
|
|
13481
13498
|
...updates,
|
|
13482
13499
|
updatedAt: serverTimestamp18()
|
|
13483
13500
|
});
|
|
@@ -13496,7 +13513,7 @@ var UserService = class extends BaseService {
|
|
|
13496
13513
|
const user = await this.getUserById(uid);
|
|
13497
13514
|
if (user.roles.includes(role)) return;
|
|
13498
13515
|
const profiles = await this.createProfilesForRoles(uid, [role], options);
|
|
13499
|
-
await
|
|
13516
|
+
await updateDoc18(doc21(this.db, USERS_COLLECTION, uid), {
|
|
13500
13517
|
roles: [...user.roles, role],
|
|
13501
13518
|
...profiles,
|
|
13502
13519
|
updatedAt: serverTimestamp18()
|
|
@@ -13525,7 +13542,7 @@ var UserService = class extends BaseService {
|
|
|
13525
13542
|
}
|
|
13526
13543
|
break;
|
|
13527
13544
|
}
|
|
13528
|
-
await
|
|
13545
|
+
await updateDoc18(doc21(this.db, USERS_COLLECTION, uid), {
|
|
13529
13546
|
roles: user.roles.filter((r) => r !== role),
|
|
13530
13547
|
updatedAt: serverTimestamp18()
|
|
13531
13548
|
});
|
|
@@ -13551,7 +13568,7 @@ var UserService = class extends BaseService {
|
|
|
13551
13568
|
} else {
|
|
13552
13569
|
updateData.acquisitionSourceOther = null;
|
|
13553
13570
|
}
|
|
13554
|
-
await
|
|
13571
|
+
await updateDoc18(userRef, updateData);
|
|
13555
13572
|
}
|
|
13556
13573
|
// Delete operations
|
|
13557
13574
|
async deleteUser(uid) {
|
|
@@ -13729,7 +13746,7 @@ import {
|
|
|
13729
13746
|
getDocs as getDocs16,
|
|
13730
13747
|
query as query16,
|
|
13731
13748
|
where as where16,
|
|
13732
|
-
updateDoc as
|
|
13749
|
+
updateDoc as updateDoc19,
|
|
13733
13750
|
setDoc as setDoc13,
|
|
13734
13751
|
Timestamp as Timestamp20
|
|
13735
13752
|
} from "firebase/firestore";
|
|
@@ -13997,7 +14014,7 @@ async function updateClinicGroup(db, groupId, data, app) {
|
|
|
13997
14014
|
updatedAt: Timestamp20.now()
|
|
13998
14015
|
};
|
|
13999
14016
|
console.log("[CLINIC_GROUP] Updating clinic group in Firestore");
|
|
14000
|
-
await
|
|
14017
|
+
await updateDoc19(doc22(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
|
|
14001
14018
|
console.log("[CLINIC_GROUP] Clinic group updated successfully");
|
|
14002
14019
|
const updatedGroup = await getClinicGroup(db, groupId);
|
|
14003
14020
|
if (!updatedGroup) {
|
|
@@ -14382,7 +14399,7 @@ import {
|
|
|
14382
14399
|
doc as doc24,
|
|
14383
14400
|
getDoc as getDoc26,
|
|
14384
14401
|
getDocs as getDocs20,
|
|
14385
|
-
updateDoc as
|
|
14402
|
+
updateDoc as updateDoc21,
|
|
14386
14403
|
serverTimestamp as serverTimestamp20,
|
|
14387
14404
|
writeBatch as writeBatch4,
|
|
14388
14405
|
arrayUnion as arrayUnion7
|
|
@@ -14402,7 +14419,7 @@ import {
|
|
|
14402
14419
|
getDocs as getDocs17,
|
|
14403
14420
|
query as query17,
|
|
14404
14421
|
where as where17,
|
|
14405
|
-
updateDoc as
|
|
14422
|
+
updateDoc as updateDoc20,
|
|
14406
14423
|
setDoc as setDoc14,
|
|
14407
14424
|
Timestamp as Timestamp21,
|
|
14408
14425
|
limit as limit9,
|
|
@@ -14619,7 +14636,7 @@ async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app
|
|
|
14619
14636
|
};
|
|
14620
14637
|
console.log("[CLINIC] Updating clinic in Firestore");
|
|
14621
14638
|
try {
|
|
14622
|
-
await
|
|
14639
|
+
await updateDoc20(doc23(db, CLINICS_COLLECTION, clinicId), updatedData);
|
|
14623
14640
|
console.log("[CLINIC] Clinic updated successfully");
|
|
14624
14641
|
} catch (updateError) {
|
|
14625
14642
|
console.error("[CLINIC] Error updating clinic in Firestore:", updateError);
|
|
@@ -15474,7 +15491,7 @@ var ClinicService = class extends BaseService {
|
|
|
15474
15491
|
};
|
|
15475
15492
|
}
|
|
15476
15493
|
updatePayload.updatedAt = serverTimestamp20();
|
|
15477
|
-
await
|
|
15494
|
+
await updateDoc21(clinicRef, updatePayload);
|
|
15478
15495
|
console.log(`[ClinicService] Clinic ${clinicId} updated successfully`);
|
|
15479
15496
|
const updatedClinic = await this.getClinic(clinicId);
|
|
15480
15497
|
if (!updatedClinic) throw new Error("Failed to retrieve updated clinic");
|
|
@@ -15492,7 +15509,7 @@ var ClinicService = class extends BaseService {
|
|
|
15492
15509
|
*/
|
|
15493
15510
|
async deactivateClinic(clinicId, adminId) {
|
|
15494
15511
|
const clinicRef = doc24(this.db, CLINICS_COLLECTION, clinicId);
|
|
15495
|
-
await
|
|
15512
|
+
await updateDoc21(clinicRef, {
|
|
15496
15513
|
isActive: false,
|
|
15497
15514
|
updatedAt: serverTimestamp20()
|
|
15498
15515
|
});
|
|
@@ -15502,7 +15519,7 @@ var ClinicService = class extends BaseService {
|
|
|
15502
15519
|
*/
|
|
15503
15520
|
async activateClinic(clinicId, adminId) {
|
|
15504
15521
|
const clinicRef = doc24(this.db, CLINICS_COLLECTION, clinicId);
|
|
15505
|
-
await
|
|
15522
|
+
await updateDoc21(clinicRef, {
|
|
15506
15523
|
isActive: true,
|
|
15507
15524
|
updatedAt: serverTimestamp20()
|
|
15508
15525
|
});
|
|
@@ -16839,7 +16856,7 @@ import {
|
|
|
16839
16856
|
where as where27,
|
|
16840
16857
|
getDocs as getDocs27,
|
|
16841
16858
|
setDoc as setDoc22,
|
|
16842
|
-
updateDoc as
|
|
16859
|
+
updateDoc as updateDoc28
|
|
16843
16860
|
} from "firebase/firestore";
|
|
16844
16861
|
|
|
16845
16862
|
// src/services/calendar/utils/clinic.utils.ts
|
|
@@ -16849,7 +16866,7 @@ import {
|
|
|
16849
16866
|
getDoc as getDoc28,
|
|
16850
16867
|
getDocs as getDocs22,
|
|
16851
16868
|
setDoc as setDoc17,
|
|
16852
|
-
updateDoc as
|
|
16869
|
+
updateDoc as updateDoc23,
|
|
16853
16870
|
deleteDoc as deleteDoc10,
|
|
16854
16871
|
query as query22,
|
|
16855
16872
|
where as where22,
|
|
@@ -16920,7 +16937,7 @@ async function updateClinicCalendarEventUtil(db, clinicId, eventId, updateData)
|
|
|
16920
16937
|
...updateData,
|
|
16921
16938
|
updatedAt: serverTimestamp21()
|
|
16922
16939
|
};
|
|
16923
|
-
await
|
|
16940
|
+
await updateDoc23(eventRef, updates);
|
|
16924
16941
|
const updatedDoc = await getDoc28(eventRef);
|
|
16925
16942
|
if (!updatedDoc.exists()) {
|
|
16926
16943
|
throw new Error("Event not found after update");
|
|
@@ -16953,7 +16970,7 @@ import {
|
|
|
16953
16970
|
getDoc as getDoc29,
|
|
16954
16971
|
getDocs as getDocs23,
|
|
16955
16972
|
setDoc as setDoc18,
|
|
16956
|
-
updateDoc as
|
|
16973
|
+
updateDoc as updateDoc24,
|
|
16957
16974
|
deleteDoc as deleteDoc11,
|
|
16958
16975
|
query as query23,
|
|
16959
16976
|
where as where23,
|
|
@@ -16983,7 +17000,7 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
|
|
|
16983
17000
|
...updateData,
|
|
16984
17001
|
updatedAt: serverTimestamp22()
|
|
16985
17002
|
};
|
|
16986
|
-
await
|
|
17003
|
+
await updateDoc24(eventRef, updates);
|
|
16987
17004
|
const updatedDoc = await getDoc29(eventRef);
|
|
16988
17005
|
if (!updatedDoc.exists()) {
|
|
16989
17006
|
throw new Error("Event not found after update");
|
|
@@ -16997,7 +17014,7 @@ import {
|
|
|
16997
17014
|
getDoc as getDoc30,
|
|
16998
17015
|
getDocs as getDocs24,
|
|
16999
17016
|
setDoc as setDoc19,
|
|
17000
|
-
updateDoc as
|
|
17017
|
+
updateDoc as updateDoc25,
|
|
17001
17018
|
deleteDoc as deleteDoc12,
|
|
17002
17019
|
query as query24,
|
|
17003
17020
|
where as where24,
|
|
@@ -17035,7 +17052,7 @@ async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId,
|
|
|
17035
17052
|
...updateData,
|
|
17036
17053
|
updatedAt: serverTimestamp23()
|
|
17037
17054
|
};
|
|
17038
|
-
await
|
|
17055
|
+
await updateDoc25(eventRef, updates);
|
|
17039
17056
|
const updatedDoc = await getDoc30(eventRef);
|
|
17040
17057
|
if (!updatedDoc.exists()) {
|
|
17041
17058
|
throw new Error("Event not found after update");
|
|
@@ -17100,7 +17117,7 @@ import {
|
|
|
17100
17117
|
getDoc as getDoc31,
|
|
17101
17118
|
getDocs as getDocs25,
|
|
17102
17119
|
setDoc as setDoc20,
|
|
17103
|
-
updateDoc as
|
|
17120
|
+
updateDoc as updateDoc26,
|
|
17104
17121
|
deleteDoc as deleteDoc13,
|
|
17105
17122
|
query as query25,
|
|
17106
17123
|
where as where25,
|
|
@@ -17228,7 +17245,7 @@ import {
|
|
|
17228
17245
|
getDoc as getDoc32,
|
|
17229
17246
|
getDocs as getDocs26,
|
|
17230
17247
|
setDoc as setDoc21,
|
|
17231
|
-
updateDoc as
|
|
17248
|
+
updateDoc as updateDoc27,
|
|
17232
17249
|
deleteDoc as deleteDoc14,
|
|
17233
17250
|
query as query26,
|
|
17234
17251
|
orderBy as orderBy12,
|
|
@@ -17352,7 +17369,7 @@ async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendar
|
|
|
17352
17369
|
...updateData,
|
|
17353
17370
|
updatedAt: serverTimestamp25()
|
|
17354
17371
|
};
|
|
17355
|
-
await
|
|
17372
|
+
await updateDoc27(calendarRef, updates);
|
|
17356
17373
|
const updatedDoc = await getDoc32(calendarRef);
|
|
17357
17374
|
if (!updatedDoc.exists()) {
|
|
17358
17375
|
throw new Error("Synced calendar not found after update");
|
|
@@ -17365,7 +17382,7 @@ async function updatePatientSyncedCalendarUtil(db, patientId, calendarId, update
|
|
|
17365
17382
|
...updateData,
|
|
17366
17383
|
updatedAt: serverTimestamp25()
|
|
17367
17384
|
};
|
|
17368
|
-
await
|
|
17385
|
+
await updateDoc27(calendarRef, updates);
|
|
17369
17386
|
const updatedDoc = await getDoc32(calendarRef);
|
|
17370
17387
|
if (!updatedDoc.exists()) {
|
|
17371
17388
|
throw new Error("Synced calendar not found after update");
|
|
@@ -17378,7 +17395,7 @@ async function updateClinicSyncedCalendarUtil(db, clinicId, calendarId, updateDa
|
|
|
17378
17395
|
...updateData,
|
|
17379
17396
|
updatedAt: serverTimestamp25()
|
|
17380
17397
|
};
|
|
17381
|
-
await
|
|
17398
|
+
await updateDoc27(calendarRef, updates);
|
|
17382
17399
|
const updatedDoc = await getDoc32(calendarRef);
|
|
17383
17400
|
if (!updatedDoc.exists()) {
|
|
17384
17401
|
throw new Error("Synced calendar not found after update");
|
|
@@ -18808,7 +18825,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18808
18825
|
CALENDAR_COLLECTION,
|
|
18809
18826
|
eventId
|
|
18810
18827
|
);
|
|
18811
|
-
await
|
|
18828
|
+
await updateDoc28(eventRef, {
|
|
18812
18829
|
eventName: externalEvent.summary || "External Event",
|
|
18813
18830
|
eventTime: {
|
|
18814
18831
|
start: Timestamp30.fromDate(startTime),
|
|
@@ -18840,7 +18857,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
18840
18857
|
CALENDAR_COLLECTION,
|
|
18841
18858
|
eventId
|
|
18842
18859
|
);
|
|
18843
|
-
await
|
|
18860
|
+
await updateDoc28(eventRef, {
|
|
18844
18861
|
status,
|
|
18845
18862
|
updatedAt: serverTimestamp26()
|
|
18846
18863
|
});
|
|
@@ -19241,7 +19258,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
19241
19258
|
} else {
|
|
19242
19259
|
syncIds.push(syncEvent);
|
|
19243
19260
|
}
|
|
19244
|
-
await
|
|
19261
|
+
await updateDoc28(eventRef, {
|
|
19245
19262
|
syncedCalendarEventId: syncIds,
|
|
19246
19263
|
updatedAt: serverTimestamp26()
|
|
19247
19264
|
});
|
|
@@ -19467,7 +19484,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
19467
19484
|
|
|
19468
19485
|
// src/services/calendar/calendar.v3.service.ts
|
|
19469
19486
|
import { Timestamp as Timestamp31, serverTimestamp as serverTimestamp27 } from "firebase/firestore";
|
|
19470
|
-
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";
|
|
19471
19488
|
var CalendarServiceV3 = class extends BaseService {
|
|
19472
19489
|
/**
|
|
19473
19490
|
* Creates a new CalendarServiceV3 instance
|
|
@@ -19546,7 +19563,7 @@ var CalendarServiceV3 = class extends BaseService {
|
|
|
19546
19563
|
if (params.status !== void 0) {
|
|
19547
19564
|
updateData.status = params.status;
|
|
19548
19565
|
}
|
|
19549
|
-
await
|
|
19566
|
+
await updateDoc29(eventRef, updateData);
|
|
19550
19567
|
const updatedEventDoc = await getDoc34(eventRef);
|
|
19551
19568
|
return updatedEventDoc.data();
|
|
19552
19569
|
}
|
|
@@ -19775,7 +19792,7 @@ import {
|
|
|
19775
19792
|
getDocs as getDocs28,
|
|
19776
19793
|
query as query28,
|
|
19777
19794
|
where as where28,
|
|
19778
|
-
updateDoc as
|
|
19795
|
+
updateDoc as updateDoc30,
|
|
19779
19796
|
setDoc as setDoc24,
|
|
19780
19797
|
deleteDoc as deleteDoc16,
|
|
19781
19798
|
Timestamp as Timestamp32,
|
|
@@ -19944,7 +19961,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
19944
19961
|
updatedAt: serverTimestamp28()
|
|
19945
19962
|
};
|
|
19946
19963
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
19947
|
-
await
|
|
19964
|
+
await updateDoc30(docRef, updateData);
|
|
19948
19965
|
return await this.getInviteById(inviteId);
|
|
19949
19966
|
} catch (error) {
|
|
19950
19967
|
console.error(
|
|
@@ -19976,7 +19993,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
19976
19993
|
updatedAt: serverTimestamp28()
|
|
19977
19994
|
};
|
|
19978
19995
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
19979
|
-
await
|
|
19996
|
+
await updateDoc30(docRef, updateData);
|
|
19980
19997
|
return await this.getInviteById(inviteId);
|
|
19981
19998
|
} catch (error) {
|
|
19982
19999
|
console.error(
|
|
@@ -20008,7 +20025,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
20008
20025
|
updatedAt: serverTimestamp28()
|
|
20009
20026
|
};
|
|
20010
20027
|
const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
20011
|
-
await
|
|
20028
|
+
await updateDoc30(docRef, updateData);
|
|
20012
20029
|
return await this.getInviteById(inviteId);
|
|
20013
20030
|
} catch (error) {
|
|
20014
20031
|
console.error(
|
|
@@ -20179,7 +20196,7 @@ import {
|
|
|
20179
20196
|
getDoc as getDoc36,
|
|
20180
20197
|
getDocs as getDocs29,
|
|
20181
20198
|
setDoc as setDoc25,
|
|
20182
|
-
updateDoc as
|
|
20199
|
+
updateDoc as updateDoc31,
|
|
20183
20200
|
deleteDoc as deleteDoc17,
|
|
20184
20201
|
query as query29,
|
|
20185
20202
|
where as where29,
|
|
@@ -20309,7 +20326,7 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
20309
20326
|
updatePayload.sortingOrder = (_c = validatedData.sortingOrder) != null ? _c : 0;
|
|
20310
20327
|
const docRef = doc35(this.collectionRef, templateId);
|
|
20311
20328
|
console.log("Update payload", updatePayload);
|
|
20312
|
-
await
|
|
20329
|
+
await updateDoc31(docRef, updatePayload);
|
|
20313
20330
|
return { ...template, ...updatePayload };
|
|
20314
20331
|
}
|
|
20315
20332
|
/**
|
|
@@ -20557,7 +20574,7 @@ import {
|
|
|
20557
20574
|
getDoc as getDoc37,
|
|
20558
20575
|
getDocs as getDocs30,
|
|
20559
20576
|
setDoc as setDoc26,
|
|
20560
|
-
updateDoc as
|
|
20577
|
+
updateDoc as updateDoc32,
|
|
20561
20578
|
query as query30,
|
|
20562
20579
|
orderBy as orderBy15,
|
|
20563
20580
|
limit as limit14,
|
|
@@ -20649,7 +20666,11 @@ var FilledDocumentService = class extends BaseService {
|
|
|
20649
20666
|
if (!docSnap.exists()) {
|
|
20650
20667
|
return null;
|
|
20651
20668
|
}
|
|
20652
|
-
|
|
20669
|
+
const data = docSnap.data();
|
|
20670
|
+
if (!data.id) {
|
|
20671
|
+
data.id = docSnap.id;
|
|
20672
|
+
}
|
|
20673
|
+
return data;
|
|
20653
20674
|
}
|
|
20654
20675
|
/**
|
|
20655
20676
|
* Update values or status in a filled document within an appointment's subcollection.
|
|
@@ -20694,7 +20715,7 @@ var FilledDocumentService = class extends BaseService {
|
|
|
20694
20715
|
}
|
|
20695
20716
|
if (Object.keys(updatePayload).length === 1 && "updatedAt" in updatePayload) {
|
|
20696
20717
|
}
|
|
20697
|
-
await
|
|
20718
|
+
await updateDoc32(docRef, updatePayload);
|
|
20698
20719
|
return { ...existingDoc, ...updatePayload };
|
|
20699
20720
|
}
|
|
20700
20721
|
/**
|
|
@@ -20750,9 +20771,13 @@ var FilledDocumentService = class extends BaseService {
|
|
|
20750
20771
|
const querySnapshot = await getDocs30(q);
|
|
20751
20772
|
const documents = [];
|
|
20752
20773
|
let lastVisible = null;
|
|
20753
|
-
querySnapshot.forEach((
|
|
20754
|
-
|
|
20755
|
-
|
|
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;
|
|
20756
20781
|
});
|
|
20757
20782
|
return {
|
|
20758
20783
|
documents,
|
|
@@ -20918,7 +20943,7 @@ import {
|
|
|
20918
20943
|
getDocs as getDocs31,
|
|
20919
20944
|
query as query31,
|
|
20920
20945
|
where as where31,
|
|
20921
|
-
updateDoc as
|
|
20946
|
+
updateDoc as updateDoc33,
|
|
20922
20947
|
deleteDoc as deleteDoc18,
|
|
20923
20948
|
orderBy as orderBy16,
|
|
20924
20949
|
Timestamp as Timestamp34,
|
|
@@ -21004,7 +21029,7 @@ var NotificationService = class extends BaseService {
|
|
|
21004
21029
|
NOTIFICATIONS_COLLECTION,
|
|
21005
21030
|
notificationId
|
|
21006
21031
|
);
|
|
21007
|
-
await
|
|
21032
|
+
await updateDoc33(notificationRef, {
|
|
21008
21033
|
isRead: true,
|
|
21009
21034
|
updatedAt: Timestamp34.now()
|
|
21010
21035
|
});
|
|
@@ -21037,7 +21062,7 @@ var NotificationService = class extends BaseService {
|
|
|
21037
21062
|
NOTIFICATIONS_COLLECTION,
|
|
21038
21063
|
notificationId
|
|
21039
21064
|
);
|
|
21040
|
-
await
|
|
21065
|
+
await updateDoc33(notificationRef, {
|
|
21041
21066
|
status,
|
|
21042
21067
|
updatedAt: Timestamp34.now()
|
|
21043
21068
|
});
|
|
@@ -21093,7 +21118,7 @@ import {
|
|
|
21093
21118
|
query as query32,
|
|
21094
21119
|
where as where32,
|
|
21095
21120
|
doc as doc38,
|
|
21096
|
-
updateDoc as
|
|
21121
|
+
updateDoc as updateDoc34,
|
|
21097
21122
|
Timestamp as Timestamp35,
|
|
21098
21123
|
orderBy as orderBy17,
|
|
21099
21124
|
limit as limit15,
|
|
@@ -21256,7 +21281,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
21256
21281
|
if (newOverallStatus !== instance.overallStatus) {
|
|
21257
21282
|
updatePayload.overallStatus = newOverallStatus;
|
|
21258
21283
|
}
|
|
21259
|
-
await
|
|
21284
|
+
await updateDoc34(instanceRef, updatePayload);
|
|
21260
21285
|
return {
|
|
21261
21286
|
...instance,
|
|
21262
21287
|
instructions: updatedInstructions,
|
|
@@ -21276,7 +21301,7 @@ import {
|
|
|
21276
21301
|
getDocs as getDocs33,
|
|
21277
21302
|
query as query33,
|
|
21278
21303
|
where as where33,
|
|
21279
|
-
updateDoc as
|
|
21304
|
+
updateDoc as updateDoc35,
|
|
21280
21305
|
setDoc as setDoc27,
|
|
21281
21306
|
deleteDoc as deleteDoc19,
|
|
21282
21307
|
serverTimestamp as serverTimestamp31,
|
|
@@ -22433,7 +22458,7 @@ var ProcedureService = class extends BaseService {
|
|
|
22433
22458
|
} else if (validatedData.productId) {
|
|
22434
22459
|
console.warn("Attempted to update product without a valid technologyId");
|
|
22435
22460
|
}
|
|
22436
|
-
await
|
|
22461
|
+
await updateDoc35(procedureRef, {
|
|
22437
22462
|
...updatedProcedureData,
|
|
22438
22463
|
updatedAt: serverTimestamp31()
|
|
22439
22464
|
});
|
|
@@ -22451,7 +22476,7 @@ var ProcedureService = class extends BaseService {
|
|
|
22451
22476
|
console.warn(`Procedure ${id} not found for deactivation.`);
|
|
22452
22477
|
return;
|
|
22453
22478
|
}
|
|
22454
|
-
await
|
|
22479
|
+
await updateDoc35(procedureRef, {
|
|
22455
22480
|
isActive: false,
|
|
22456
22481
|
updatedAt: serverTimestamp31()
|
|
22457
22482
|
});
|
|
@@ -23839,7 +23864,7 @@ import {
|
|
|
23839
23864
|
getDoc as getDoc42,
|
|
23840
23865
|
getDocs as getDocs35,
|
|
23841
23866
|
query as query35,
|
|
23842
|
-
updateDoc as
|
|
23867
|
+
updateDoc as updateDoc36,
|
|
23843
23868
|
where as where35,
|
|
23844
23869
|
limit as limit17,
|
|
23845
23870
|
orderBy as orderBy19,
|
|
@@ -23952,7 +23977,7 @@ var BrandService = class extends BaseService {
|
|
|
23952
23977
|
updateData.name_lowercase = brand.name.toLowerCase();
|
|
23953
23978
|
}
|
|
23954
23979
|
const docRef = doc41(this.getBrandsRef(), brandId);
|
|
23955
|
-
await
|
|
23980
|
+
await updateDoc36(docRef, updateData);
|
|
23956
23981
|
return this.getById(brandId);
|
|
23957
23982
|
}
|
|
23958
23983
|
/**
|
|
@@ -24055,7 +24080,7 @@ import {
|
|
|
24055
24080
|
orderBy as orderBy20,
|
|
24056
24081
|
query as query36,
|
|
24057
24082
|
startAfter as startAfter16,
|
|
24058
|
-
updateDoc as
|
|
24083
|
+
updateDoc as updateDoc37,
|
|
24059
24084
|
where as where36
|
|
24060
24085
|
} from "firebase/firestore";
|
|
24061
24086
|
|
|
@@ -24215,7 +24240,7 @@ var CategoryService = class extends BaseService {
|
|
|
24215
24240
|
updatedAt: /* @__PURE__ */ new Date()
|
|
24216
24241
|
};
|
|
24217
24242
|
const docRef = doc42(this.categoriesRef, id);
|
|
24218
|
-
await
|
|
24243
|
+
await updateDoc37(docRef, updateData);
|
|
24219
24244
|
return this.getById(id);
|
|
24220
24245
|
}
|
|
24221
24246
|
/**
|
|
@@ -24367,7 +24392,7 @@ import {
|
|
|
24367
24392
|
query as query37,
|
|
24368
24393
|
setDoc as setDoc29,
|
|
24369
24394
|
startAfter as startAfter17,
|
|
24370
|
-
updateDoc as
|
|
24395
|
+
updateDoc as updateDoc38,
|
|
24371
24396
|
where as where37
|
|
24372
24397
|
} from "firebase/firestore";
|
|
24373
24398
|
|
|
@@ -24572,7 +24597,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
24572
24597
|
updatedAt: /* @__PURE__ */ new Date()
|
|
24573
24598
|
};
|
|
24574
24599
|
const docRef = doc43(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
24575
|
-
await
|
|
24600
|
+
await updateDoc38(docRef, updateData);
|
|
24576
24601
|
return this.getById(categoryId, subcategoryId);
|
|
24577
24602
|
}
|
|
24578
24603
|
}
|
|
@@ -24728,7 +24753,7 @@ import {
|
|
|
24728
24753
|
orderBy as orderBy22,
|
|
24729
24754
|
query as query38,
|
|
24730
24755
|
startAfter as startAfter18,
|
|
24731
|
-
updateDoc as
|
|
24756
|
+
updateDoc as updateDoc39,
|
|
24732
24757
|
where as where38,
|
|
24733
24758
|
arrayUnion as arrayUnion9,
|
|
24734
24759
|
arrayRemove as arrayRemove8,
|
|
@@ -24925,7 +24950,7 @@ var TechnologyService = class extends BaseService {
|
|
|
24925
24950
|
updateData.updatedAt = /* @__PURE__ */ new Date();
|
|
24926
24951
|
const docRef = doc44(this.technologiesRef, id);
|
|
24927
24952
|
const beforeTech = await this.getById(id);
|
|
24928
|
-
await
|
|
24953
|
+
await updateDoc39(docRef, updateData);
|
|
24929
24954
|
const categoryChanged = beforeTech && updateData.categoryId && beforeTech.categoryId !== updateData.categoryId;
|
|
24930
24955
|
const subcategoryChanged = beforeTech && updateData.subcategoryId && beforeTech.subcategoryId !== updateData.subcategoryId;
|
|
24931
24956
|
const nameChanged = beforeTech && updateData.name && beforeTech.name !== updateData.name;
|
|
@@ -25012,7 +25037,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25012
25037
|
async addRequirement(technologyId, requirement) {
|
|
25013
25038
|
const docRef = doc44(this.technologiesRef, technologyId);
|
|
25014
25039
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
25015
|
-
await
|
|
25040
|
+
await updateDoc39(docRef, {
|
|
25016
25041
|
[requirementType]: arrayUnion9(requirement),
|
|
25017
25042
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25018
25043
|
});
|
|
@@ -25027,7 +25052,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25027
25052
|
async removeRequirement(technologyId, requirement) {
|
|
25028
25053
|
const docRef = doc44(this.technologiesRef, technologyId);
|
|
25029
25054
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
25030
|
-
await
|
|
25055
|
+
await updateDoc39(docRef, {
|
|
25031
25056
|
[requirementType]: arrayRemove8(requirement),
|
|
25032
25057
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25033
25058
|
});
|
|
@@ -25066,7 +25091,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25066
25091
|
*/
|
|
25067
25092
|
async addBlockingCondition(technologyId, condition) {
|
|
25068
25093
|
const docRef = doc44(this.technologiesRef, technologyId);
|
|
25069
|
-
await
|
|
25094
|
+
await updateDoc39(docRef, {
|
|
25070
25095
|
blockingConditions: arrayUnion9(condition),
|
|
25071
25096
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25072
25097
|
});
|
|
@@ -25080,7 +25105,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25080
25105
|
*/
|
|
25081
25106
|
async removeBlockingCondition(technologyId, condition) {
|
|
25082
25107
|
const docRef = doc44(this.technologiesRef, technologyId);
|
|
25083
|
-
await
|
|
25108
|
+
await updateDoc39(docRef, {
|
|
25084
25109
|
blockingConditions: arrayRemove8(condition),
|
|
25085
25110
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25086
25111
|
});
|
|
@@ -25102,7 +25127,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25102
25127
|
if (existingContraindications.some((c) => c.id === contraindication.id)) {
|
|
25103
25128
|
return technology;
|
|
25104
25129
|
}
|
|
25105
|
-
await
|
|
25130
|
+
await updateDoc39(docRef, {
|
|
25106
25131
|
contraindications: [...existingContraindications, contraindication],
|
|
25107
25132
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25108
25133
|
});
|
|
@@ -25123,7 +25148,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25123
25148
|
const updatedContraindications = (technology.contraindications || []).filter(
|
|
25124
25149
|
(c) => c.id !== contraindication.id
|
|
25125
25150
|
);
|
|
25126
|
-
await
|
|
25151
|
+
await updateDoc39(docRef, {
|
|
25127
25152
|
contraindications: updatedContraindications,
|
|
25128
25153
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25129
25154
|
});
|
|
@@ -25152,7 +25177,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25152
25177
|
}
|
|
25153
25178
|
const updatedContraindications = [...contraindications];
|
|
25154
25179
|
updatedContraindications[index] = contraindication;
|
|
25155
|
-
await
|
|
25180
|
+
await updateDoc39(docRef, {
|
|
25156
25181
|
contraindications: updatedContraindications,
|
|
25157
25182
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25158
25183
|
});
|
|
@@ -25174,7 +25199,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25174
25199
|
if (existingBenefits.some((b) => b.id === benefit.id)) {
|
|
25175
25200
|
return technology;
|
|
25176
25201
|
}
|
|
25177
|
-
await
|
|
25202
|
+
await updateDoc39(docRef, {
|
|
25178
25203
|
benefits: [...existingBenefits, benefit],
|
|
25179
25204
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25180
25205
|
});
|
|
@@ -25193,7 +25218,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25193
25218
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
25194
25219
|
}
|
|
25195
25220
|
const updatedBenefits = (technology.benefits || []).filter((b) => b.id !== benefit.id);
|
|
25196
|
-
await
|
|
25221
|
+
await updateDoc39(docRef, {
|
|
25197
25222
|
benefits: updatedBenefits,
|
|
25198
25223
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25199
25224
|
});
|
|
@@ -25222,7 +25247,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25222
25247
|
}
|
|
25223
25248
|
const updatedBenefits = [...benefits];
|
|
25224
25249
|
updatedBenefits[index] = benefit;
|
|
25225
|
-
await
|
|
25250
|
+
await updateDoc39(docRef, {
|
|
25226
25251
|
benefits: updatedBenefits,
|
|
25227
25252
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25228
25253
|
});
|
|
@@ -25263,7 +25288,7 @@ var TechnologyService = class extends BaseService {
|
|
|
25263
25288
|
*/
|
|
25264
25289
|
async updateCertificationRequirement(technologyId, certificationRequirement) {
|
|
25265
25290
|
const docRef = doc44(this.technologiesRef, technologyId);
|
|
25266
|
-
await
|
|
25291
|
+
await updateDoc39(docRef, {
|
|
25267
25292
|
certificationRequirement,
|
|
25268
25293
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25269
25294
|
});
|
|
@@ -25643,7 +25668,7 @@ import {
|
|
|
25643
25668
|
getDoc as getDoc46,
|
|
25644
25669
|
getDocs as getDocs39,
|
|
25645
25670
|
query as query39,
|
|
25646
|
-
updateDoc as
|
|
25671
|
+
updateDoc as updateDoc40,
|
|
25647
25672
|
where as where39,
|
|
25648
25673
|
limit as limit21,
|
|
25649
25674
|
orderBy as orderBy23,
|
|
@@ -25812,7 +25837,7 @@ var ProductService = class extends BaseService {
|
|
|
25812
25837
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25813
25838
|
};
|
|
25814
25839
|
const docRef = doc45(this.getProductsRef(technologyId), productId);
|
|
25815
|
-
await
|
|
25840
|
+
await updateDoc40(docRef, updateData);
|
|
25816
25841
|
return this.getById(technologyId, productId);
|
|
25817
25842
|
}
|
|
25818
25843
|
/**
|
|
@@ -25909,7 +25934,7 @@ var ProductService = class extends BaseService {
|
|
|
25909
25934
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25910
25935
|
};
|
|
25911
25936
|
const docRef = doc45(this.getTopLevelProductsRef(), productId);
|
|
25912
|
-
await
|
|
25937
|
+
await updateDoc40(docRef, updateData);
|
|
25913
25938
|
return this.getByIdTopLevel(productId);
|
|
25914
25939
|
}
|
|
25915
25940
|
/**
|
|
@@ -25925,7 +25950,7 @@ var ProductService = class extends BaseService {
|
|
|
25925
25950
|
*/
|
|
25926
25951
|
async assignToTechnology(productId, technologyId) {
|
|
25927
25952
|
const docRef = doc45(this.getTopLevelProductsRef(), productId);
|
|
25928
|
-
await
|
|
25953
|
+
await updateDoc40(docRef, {
|
|
25929
25954
|
assignedTechnologyIds: arrayUnion10(technologyId),
|
|
25930
25955
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25931
25956
|
});
|
|
@@ -25935,7 +25960,7 @@ var ProductService = class extends BaseService {
|
|
|
25935
25960
|
*/
|
|
25936
25961
|
async unassignFromTechnology(productId, technologyId) {
|
|
25937
25962
|
const docRef = doc45(this.getTopLevelProductsRef(), productId);
|
|
25938
|
-
await
|
|
25963
|
+
await updateDoc40(docRef, {
|
|
25939
25964
|
assignedTechnologyIds: arrayRemove9(technologyId),
|
|
25940
25965
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25941
25966
|
});
|
|
@@ -26081,7 +26106,7 @@ import {
|
|
|
26081
26106
|
doc as doc46,
|
|
26082
26107
|
getDoc as getDoc47,
|
|
26083
26108
|
setDoc as setDoc30,
|
|
26084
|
-
updateDoc as
|
|
26109
|
+
updateDoc as updateDoc41
|
|
26085
26110
|
} from "firebase/firestore";
|
|
26086
26111
|
var ADMIN_CONSTANTS_COLLECTION = "admin-constants";
|
|
26087
26112
|
var TREATMENT_BENEFITS_DOC = "treatment-benefits";
|
|
@@ -26144,7 +26169,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26144
26169
|
if (!docSnap.exists()) {
|
|
26145
26170
|
await setDoc30(this.treatmentBenefitsDocRef, { benefits: [newBenefit] });
|
|
26146
26171
|
} else {
|
|
26147
|
-
await
|
|
26172
|
+
await updateDoc41(this.treatmentBenefitsDocRef, {
|
|
26148
26173
|
benefits: arrayUnion11(newBenefit)
|
|
26149
26174
|
});
|
|
26150
26175
|
}
|
|
@@ -26184,7 +26209,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26184
26209
|
throw new Error("Treatment benefit not found.");
|
|
26185
26210
|
}
|
|
26186
26211
|
benefits[benefitIndex] = benefit;
|
|
26187
|
-
await
|
|
26212
|
+
await updateDoc41(this.treatmentBenefitsDocRef, { benefits });
|
|
26188
26213
|
return benefit;
|
|
26189
26214
|
}
|
|
26190
26215
|
/**
|
|
@@ -26198,7 +26223,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26198
26223
|
if (!benefitToRemove) {
|
|
26199
26224
|
return;
|
|
26200
26225
|
}
|
|
26201
|
-
await
|
|
26226
|
+
await updateDoc41(this.treatmentBenefitsDocRef, {
|
|
26202
26227
|
benefits: arrayRemove10(benefitToRemove)
|
|
26203
26228
|
});
|
|
26204
26229
|
}
|
|
@@ -26251,7 +26276,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26251
26276
|
contraindications: [newContraindication]
|
|
26252
26277
|
});
|
|
26253
26278
|
} else {
|
|
26254
|
-
await
|
|
26279
|
+
await updateDoc41(this.contraindicationsDocRef, {
|
|
26255
26280
|
contraindications: arrayUnion11(newContraindication)
|
|
26256
26281
|
});
|
|
26257
26282
|
}
|
|
@@ -26293,7 +26318,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26293
26318
|
throw new Error("Contraindication not found.");
|
|
26294
26319
|
}
|
|
26295
26320
|
contraindications[index] = contraindication;
|
|
26296
|
-
await
|
|
26321
|
+
await updateDoc41(this.contraindicationsDocRef, { contraindications });
|
|
26297
26322
|
return contraindication;
|
|
26298
26323
|
}
|
|
26299
26324
|
/**
|
|
@@ -26307,7 +26332,7 @@ var ConstantsService = class extends BaseService {
|
|
|
26307
26332
|
if (!toRemove) {
|
|
26308
26333
|
return;
|
|
26309
26334
|
}
|
|
26310
|
-
await
|
|
26335
|
+
await updateDoc41(this.contraindicationsDocRef, {
|
|
26311
26336
|
contraindications: arrayRemove10(toRemove)
|
|
26312
26337
|
});
|
|
26313
26338
|
}
|