@blackcode_sa/metaestetics-api 1.6.2 → 1.6.3
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.d.mts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +64 -0
- package/dist/index.mjs +64 -0
- package/package.json +1 -1
- package/src/services/patient/patient.service.ts +31 -1
- package/src/services/patient/utils/practitioner.utils.ts +79 -1
- package/src/types/patient/index.ts +6 -0
package/dist/index.d.mts
CHANGED
|
@@ -1907,6 +1907,10 @@ interface PatientProfileComplete {
|
|
|
1907
1907
|
patientMedicalInfo?: PatientMedicalInfo;
|
|
1908
1908
|
patientLocationInfo?: PatientLocationInfo;
|
|
1909
1909
|
}
|
|
1910
|
+
interface PatientProfileForDoctor {
|
|
1911
|
+
patientProfile?: PatientProfile;
|
|
1912
|
+
patientSensitiveInfo?: PatientSensitiveInfo;
|
|
1913
|
+
}
|
|
1910
1914
|
|
|
1911
1915
|
/**
|
|
1912
1916
|
* Interface for clinic profile information
|
|
@@ -4783,6 +4787,19 @@ declare class PatientService extends BaseService {
|
|
|
4783
4787
|
limit?: number;
|
|
4784
4788
|
startAfter?: string;
|
|
4785
4789
|
}): Promise<PatientProfile[]>;
|
|
4790
|
+
/**
|
|
4791
|
+
* Gets all patients associated with a specific practitioner with their sensitive information.
|
|
4792
|
+
*
|
|
4793
|
+
* @param {string} practitionerId - ID of the practitioner whose patients to retrieve
|
|
4794
|
+
* @param {Object} options - Optional parameters for pagination
|
|
4795
|
+
* @param {number} options.limit - Maximum number of profiles to return
|
|
4796
|
+
* @param {string} options.startAfter - The ID of the document to start after (for pagination)
|
|
4797
|
+
* @returns {Promise<PatientProfileForDoctor[]>} A promise resolving to an array of patient profiles with sensitive info
|
|
4798
|
+
*/
|
|
4799
|
+
getPatientsByPractitionerWithDetails(practitionerId: string, options?: {
|
|
4800
|
+
limit?: number;
|
|
4801
|
+
startAfter?: string;
|
|
4802
|
+
}): Promise<PatientProfileForDoctor[]>;
|
|
4786
4803
|
/**
|
|
4787
4804
|
* Gets all patients associated with a specific clinic.
|
|
4788
4805
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1907,6 +1907,10 @@ interface PatientProfileComplete {
|
|
|
1907
1907
|
patientMedicalInfo?: PatientMedicalInfo;
|
|
1908
1908
|
patientLocationInfo?: PatientLocationInfo;
|
|
1909
1909
|
}
|
|
1910
|
+
interface PatientProfileForDoctor {
|
|
1911
|
+
patientProfile?: PatientProfile;
|
|
1912
|
+
patientSensitiveInfo?: PatientSensitiveInfo;
|
|
1913
|
+
}
|
|
1910
1914
|
|
|
1911
1915
|
/**
|
|
1912
1916
|
* Interface for clinic profile information
|
|
@@ -4783,6 +4787,19 @@ declare class PatientService extends BaseService {
|
|
|
4783
4787
|
limit?: number;
|
|
4784
4788
|
startAfter?: string;
|
|
4785
4789
|
}): Promise<PatientProfile[]>;
|
|
4790
|
+
/**
|
|
4791
|
+
* Gets all patients associated with a specific practitioner with their sensitive information.
|
|
4792
|
+
*
|
|
4793
|
+
* @param {string} practitionerId - ID of the practitioner whose patients to retrieve
|
|
4794
|
+
* @param {Object} options - Optional parameters for pagination
|
|
4795
|
+
* @param {number} options.limit - Maximum number of profiles to return
|
|
4796
|
+
* @param {string} options.startAfter - The ID of the document to start after (for pagination)
|
|
4797
|
+
* @returns {Promise<PatientProfileForDoctor[]>} A promise resolving to an array of patient profiles with sensitive info
|
|
4798
|
+
*/
|
|
4799
|
+
getPatientsByPractitionerWithDetails(practitionerId: string, options?: {
|
|
4800
|
+
limit?: number;
|
|
4801
|
+
startAfter?: string;
|
|
4802
|
+
}): Promise<PatientProfileForDoctor[]>;
|
|
4786
4803
|
/**
|
|
4787
4804
|
* Gets all patients associated with a specific clinic.
|
|
4788
4805
|
*
|
package/dist/index.js
CHANGED
|
@@ -2294,6 +2294,51 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
|
|
|
2294
2294
|
);
|
|
2295
2295
|
}
|
|
2296
2296
|
};
|
|
2297
|
+
var getPatientsByPractitionerWithDetailsUtil = async (db, practitionerId, options) => {
|
|
2298
|
+
try {
|
|
2299
|
+
console.log(
|
|
2300
|
+
`[getPatientsByPractitionerWithDetailsUtil] Fetching detailed patient profiles for practitioner ID: ${practitionerId} with options:`,
|
|
2301
|
+
options
|
|
2302
|
+
);
|
|
2303
|
+
const patientProfiles = await getPatientsByPractitionerUtil(
|
|
2304
|
+
db,
|
|
2305
|
+
practitionerId,
|
|
2306
|
+
options
|
|
2307
|
+
);
|
|
2308
|
+
const patientProfilesWithDetails = await Promise.all(
|
|
2309
|
+
patientProfiles.map(async (profile) => {
|
|
2310
|
+
try {
|
|
2311
|
+
const sensitiveInfoDoc = await (0, import_firestore9.getDoc)(
|
|
2312
|
+
getSensitiveInfoDocRef(db, profile.id)
|
|
2313
|
+
);
|
|
2314
|
+
const sensitiveInfo = sensitiveInfoDoc.exists() ? sensitiveInfoDoc.data() : void 0;
|
|
2315
|
+
return {
|
|
2316
|
+
patientProfile: profile,
|
|
2317
|
+
patientSensitiveInfo: sensitiveInfo
|
|
2318
|
+
};
|
|
2319
|
+
} catch (error) {
|
|
2320
|
+
console.error(
|
|
2321
|
+
`[getPatientsByPractitionerWithDetailsUtil] Error fetching sensitive info for patient ${profile.id}:`,
|
|
2322
|
+
error
|
|
2323
|
+
);
|
|
2324
|
+
return { patientProfile: profile };
|
|
2325
|
+
}
|
|
2326
|
+
})
|
|
2327
|
+
);
|
|
2328
|
+
console.log(
|
|
2329
|
+
`[getPatientsByPractitionerWithDetailsUtil] Found ${patientProfilesWithDetails.length} detailed patient profiles for practitioner ID: ${practitionerId}`
|
|
2330
|
+
);
|
|
2331
|
+
return patientProfilesWithDetails;
|
|
2332
|
+
} catch (error) {
|
|
2333
|
+
console.error(
|
|
2334
|
+
`[getPatientsByPractitionerWithDetailsUtil] Error fetching detailed patient profiles:`,
|
|
2335
|
+
error
|
|
2336
|
+
);
|
|
2337
|
+
throw new Error(
|
|
2338
|
+
`Failed to retrieve detailed patient profiles: ${error instanceof Error ? error.message : String(error)}`
|
|
2339
|
+
);
|
|
2340
|
+
}
|
|
2341
|
+
};
|
|
2297
2342
|
|
|
2298
2343
|
// src/services/patient/utils/clinic.utils.ts
|
|
2299
2344
|
var import_firestore10 = require("firebase/firestore");
|
|
@@ -2622,6 +2667,25 @@ var PatientService = class extends BaseService {
|
|
|
2622
2667
|
);
|
|
2623
2668
|
return getPatientsByPractitionerUtil(this.db, practitionerId, options);
|
|
2624
2669
|
}
|
|
2670
|
+
/**
|
|
2671
|
+
* Gets all patients associated with a specific practitioner with their sensitive information.
|
|
2672
|
+
*
|
|
2673
|
+
* @param {string} practitionerId - ID of the practitioner whose patients to retrieve
|
|
2674
|
+
* @param {Object} options - Optional parameters for pagination
|
|
2675
|
+
* @param {number} options.limit - Maximum number of profiles to return
|
|
2676
|
+
* @param {string} options.startAfter - The ID of the document to start after (for pagination)
|
|
2677
|
+
* @returns {Promise<PatientProfileForDoctor[]>} A promise resolving to an array of patient profiles with sensitive info
|
|
2678
|
+
*/
|
|
2679
|
+
async getPatientsByPractitionerWithDetails(practitionerId, options) {
|
|
2680
|
+
console.log(
|
|
2681
|
+
`[PatientService.getPatientsByPractitionerWithDetails] Fetching detailed patient profiles for practitioner: ${practitionerId}`
|
|
2682
|
+
);
|
|
2683
|
+
return getPatientsByPractitionerWithDetailsUtil(
|
|
2684
|
+
this.db,
|
|
2685
|
+
practitionerId,
|
|
2686
|
+
options
|
|
2687
|
+
);
|
|
2688
|
+
}
|
|
2625
2689
|
/**
|
|
2626
2690
|
* Gets all patients associated with a specific clinic.
|
|
2627
2691
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -2160,6 +2160,51 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
|
|
|
2160
2160
|
);
|
|
2161
2161
|
}
|
|
2162
2162
|
};
|
|
2163
|
+
var getPatientsByPractitionerWithDetailsUtil = async (db, practitionerId, options) => {
|
|
2164
|
+
try {
|
|
2165
|
+
console.log(
|
|
2166
|
+
`[getPatientsByPractitionerWithDetailsUtil] Fetching detailed patient profiles for practitioner ID: ${practitionerId} with options:`,
|
|
2167
|
+
options
|
|
2168
|
+
);
|
|
2169
|
+
const patientProfiles = await getPatientsByPractitionerUtil(
|
|
2170
|
+
db,
|
|
2171
|
+
practitionerId,
|
|
2172
|
+
options
|
|
2173
|
+
);
|
|
2174
|
+
const patientProfilesWithDetails = await Promise.all(
|
|
2175
|
+
patientProfiles.map(async (profile) => {
|
|
2176
|
+
try {
|
|
2177
|
+
const sensitiveInfoDoc = await getDoc7(
|
|
2178
|
+
getSensitiveInfoDocRef(db, profile.id)
|
|
2179
|
+
);
|
|
2180
|
+
const sensitiveInfo = sensitiveInfoDoc.exists() ? sensitiveInfoDoc.data() : void 0;
|
|
2181
|
+
return {
|
|
2182
|
+
patientProfile: profile,
|
|
2183
|
+
patientSensitiveInfo: sensitiveInfo
|
|
2184
|
+
};
|
|
2185
|
+
} catch (error) {
|
|
2186
|
+
console.error(
|
|
2187
|
+
`[getPatientsByPractitionerWithDetailsUtil] Error fetching sensitive info for patient ${profile.id}:`,
|
|
2188
|
+
error
|
|
2189
|
+
);
|
|
2190
|
+
return { patientProfile: profile };
|
|
2191
|
+
}
|
|
2192
|
+
})
|
|
2193
|
+
);
|
|
2194
|
+
console.log(
|
|
2195
|
+
`[getPatientsByPractitionerWithDetailsUtil] Found ${patientProfilesWithDetails.length} detailed patient profiles for practitioner ID: ${practitionerId}`
|
|
2196
|
+
);
|
|
2197
|
+
return patientProfilesWithDetails;
|
|
2198
|
+
} catch (error) {
|
|
2199
|
+
console.error(
|
|
2200
|
+
`[getPatientsByPractitionerWithDetailsUtil] Error fetching detailed patient profiles:`,
|
|
2201
|
+
error
|
|
2202
|
+
);
|
|
2203
|
+
throw new Error(
|
|
2204
|
+
`Failed to retrieve detailed patient profiles: ${error instanceof Error ? error.message : String(error)}`
|
|
2205
|
+
);
|
|
2206
|
+
}
|
|
2207
|
+
};
|
|
2163
2208
|
|
|
2164
2209
|
// src/services/patient/utils/clinic.utils.ts
|
|
2165
2210
|
import {
|
|
@@ -2497,6 +2542,25 @@ var PatientService = class extends BaseService {
|
|
|
2497
2542
|
);
|
|
2498
2543
|
return getPatientsByPractitionerUtil(this.db, practitionerId, options);
|
|
2499
2544
|
}
|
|
2545
|
+
/**
|
|
2546
|
+
* Gets all patients associated with a specific practitioner with their sensitive information.
|
|
2547
|
+
*
|
|
2548
|
+
* @param {string} practitionerId - ID of the practitioner whose patients to retrieve
|
|
2549
|
+
* @param {Object} options - Optional parameters for pagination
|
|
2550
|
+
* @param {number} options.limit - Maximum number of profiles to return
|
|
2551
|
+
* @param {string} options.startAfter - The ID of the document to start after (for pagination)
|
|
2552
|
+
* @returns {Promise<PatientProfileForDoctor[]>} A promise resolving to an array of patient profiles with sensitive info
|
|
2553
|
+
*/
|
|
2554
|
+
async getPatientsByPractitionerWithDetails(practitionerId, options) {
|
|
2555
|
+
console.log(
|
|
2556
|
+
`[PatientService.getPatientsByPractitionerWithDetails] Fetching detailed patient profiles for practitioner: ${practitionerId}`
|
|
2557
|
+
);
|
|
2558
|
+
return getPatientsByPractitionerWithDetailsUtil(
|
|
2559
|
+
this.db,
|
|
2560
|
+
practitionerId,
|
|
2561
|
+
options
|
|
2562
|
+
);
|
|
2563
|
+
}
|
|
2500
2564
|
/**
|
|
2501
2565
|
* Gets all patients associated with a specific clinic.
|
|
2502
2566
|
*
|
package/package.json
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
PatientClinic,
|
|
32
32
|
SearchPatientsParams,
|
|
33
33
|
RequesterInfo,
|
|
34
|
+
PatientProfileForDoctor,
|
|
34
35
|
} from "../../types/patient";
|
|
35
36
|
import { Auth } from "firebase/auth";
|
|
36
37
|
import { Firestore } from "firebase/firestore";
|
|
@@ -99,7 +100,10 @@ import {
|
|
|
99
100
|
removeClinicUtil,
|
|
100
101
|
} from "./utils/medical-stuff.utils";
|
|
101
102
|
|
|
102
|
-
import {
|
|
103
|
+
import {
|
|
104
|
+
getPatientsByPractitionerUtil,
|
|
105
|
+
getPatientsByPractitionerWithDetailsUtil,
|
|
106
|
+
} from "./utils/practitioner.utils";
|
|
103
107
|
import { getPatientsByClinicUtil } from "./utils/clinic.utils";
|
|
104
108
|
|
|
105
109
|
export class PatientService extends BaseService {
|
|
@@ -543,6 +547,32 @@ export class PatientService extends BaseService {
|
|
|
543
547
|
return getPatientsByPractitionerUtil(this.db, practitionerId, options);
|
|
544
548
|
}
|
|
545
549
|
|
|
550
|
+
/**
|
|
551
|
+
* Gets all patients associated with a specific practitioner with their sensitive information.
|
|
552
|
+
*
|
|
553
|
+
* @param {string} practitionerId - ID of the practitioner whose patients to retrieve
|
|
554
|
+
* @param {Object} options - Optional parameters for pagination
|
|
555
|
+
* @param {number} options.limit - Maximum number of profiles to return
|
|
556
|
+
* @param {string} options.startAfter - The ID of the document to start after (for pagination)
|
|
557
|
+
* @returns {Promise<PatientProfileForDoctor[]>} A promise resolving to an array of patient profiles with sensitive info
|
|
558
|
+
*/
|
|
559
|
+
async getPatientsByPractitionerWithDetails(
|
|
560
|
+
practitionerId: string,
|
|
561
|
+
options?: {
|
|
562
|
+
limit?: number;
|
|
563
|
+
startAfter?: string;
|
|
564
|
+
}
|
|
565
|
+
): Promise<PatientProfileForDoctor[]> {
|
|
566
|
+
console.log(
|
|
567
|
+
`[PatientService.getPatientsByPractitionerWithDetails] Fetching detailed patient profiles for practitioner: ${practitionerId}`
|
|
568
|
+
);
|
|
569
|
+
return getPatientsByPractitionerWithDetailsUtil(
|
|
570
|
+
this.db,
|
|
571
|
+
practitionerId,
|
|
572
|
+
options
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
|
|
546
576
|
/**
|
|
547
577
|
* Gets all patients associated with a specific clinic.
|
|
548
578
|
*
|
|
@@ -10,7 +10,13 @@ import {
|
|
|
10
10
|
getDoc,
|
|
11
11
|
QueryConstraint,
|
|
12
12
|
} from "firebase/firestore";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
PatientProfile,
|
|
15
|
+
PatientSensitiveInfo,
|
|
16
|
+
PatientProfileForDoctor,
|
|
17
|
+
PATIENTS_COLLECTION,
|
|
18
|
+
} from "../../../types/patient";
|
|
19
|
+
import { getSensitiveInfoDocRef } from "./docs.utils";
|
|
14
20
|
|
|
15
21
|
/**
|
|
16
22
|
* Retrieves all patients associated with a specific practitioner with pagination support.
|
|
@@ -78,3 +84,75 @@ export const getPatientsByPractitionerUtil = async (
|
|
|
78
84
|
);
|
|
79
85
|
}
|
|
80
86
|
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Retrieves all patients associated with a specific practitioner with their sensitive information.
|
|
90
|
+
*
|
|
91
|
+
* @param {Firestore} db - Firestore instance
|
|
92
|
+
* @param {string} practitionerId - ID of the practitioner whose patients to retrieve
|
|
93
|
+
* @param {Object} options - Optional parameters for pagination
|
|
94
|
+
* @param {number} options.limit - Maximum number of profiles to return
|
|
95
|
+
* @param {string} options.startAfter - The ID of the document to start after (for pagination)
|
|
96
|
+
* @returns {Promise<PatientProfileForDoctor[]>} A promise resolving to an array of patient profiles with sensitive info
|
|
97
|
+
*/
|
|
98
|
+
export const getPatientsByPractitionerWithDetailsUtil = async (
|
|
99
|
+
db: Firestore,
|
|
100
|
+
practitionerId: string,
|
|
101
|
+
options?: { limit?: number; startAfter?: string }
|
|
102
|
+
): Promise<PatientProfileForDoctor[]> => {
|
|
103
|
+
try {
|
|
104
|
+
console.log(
|
|
105
|
+
`[getPatientsByPractitionerWithDetailsUtil] Fetching detailed patient profiles for practitioner ID: ${practitionerId} with options:`,
|
|
106
|
+
options
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// First, get all patient profiles for this practitioner
|
|
110
|
+
const patientProfiles = await getPatientsByPractitionerUtil(
|
|
111
|
+
db,
|
|
112
|
+
practitionerId,
|
|
113
|
+
options
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// Then, fetch sensitive info for each patient
|
|
117
|
+
const patientProfilesWithDetails: PatientProfileForDoctor[] =
|
|
118
|
+
await Promise.all(
|
|
119
|
+
patientProfiles.map(async (profile) => {
|
|
120
|
+
try {
|
|
121
|
+
const sensitiveInfoDoc = await getDoc(
|
|
122
|
+
getSensitiveInfoDocRef(db, profile.id)
|
|
123
|
+
);
|
|
124
|
+
const sensitiveInfo = sensitiveInfoDoc.exists()
|
|
125
|
+
? (sensitiveInfoDoc.data() as PatientSensitiveInfo)
|
|
126
|
+
: undefined;
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
patientProfile: profile,
|
|
130
|
+
patientSensitiveInfo: sensitiveInfo,
|
|
131
|
+
};
|
|
132
|
+
} catch (error) {
|
|
133
|
+
console.error(
|
|
134
|
+
`[getPatientsByPractitionerWithDetailsUtil] Error fetching sensitive info for patient ${profile.id}:`,
|
|
135
|
+
error
|
|
136
|
+
);
|
|
137
|
+
// Return profile without sensitive info in case of error
|
|
138
|
+
return { patientProfile: profile };
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
console.log(
|
|
144
|
+
`[getPatientsByPractitionerWithDetailsUtil] Found ${patientProfilesWithDetails.length} detailed patient profiles for practitioner ID: ${practitionerId}`
|
|
145
|
+
);
|
|
146
|
+
return patientProfilesWithDetails;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.error(
|
|
149
|
+
`[getPatientsByPractitionerWithDetailsUtil] Error fetching detailed patient profiles:`,
|
|
150
|
+
error
|
|
151
|
+
);
|
|
152
|
+
throw new Error(
|
|
153
|
+
`Failed to retrieve detailed patient profiles: ${
|
|
154
|
+
error instanceof Error ? error.message : String(error)
|
|
155
|
+
}`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
@@ -237,3 +237,9 @@ export interface PatientProfileComplete {
|
|
|
237
237
|
patientMedicalInfo?: PatientMedicalInfo;
|
|
238
238
|
patientLocationInfo?: PatientLocationInfo;
|
|
239
239
|
}
|
|
240
|
+
|
|
241
|
+
// Create a type that combines patientProfile and patientSensitiveInfo, this will be used in the doctor's app only
|
|
242
|
+
export interface PatientProfileForDoctor {
|
|
243
|
+
patientProfile?: PatientProfile;
|
|
244
|
+
patientSensitiveInfo?: PatientSensitiveInfo;
|
|
245
|
+
}
|