@primocaredentgroup/elettromedicali 0.1.0 → 0.1.1
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/client/index.d.ts +0 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -28
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +4 -4
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/component.d.ts +165 -218
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/contracts.d.ts +9 -9
- package/dist/component/contracts.d.ts.map +1 -1
- package/dist/component/contracts.js +7 -13
- package/dist/component/contracts.js.map +1 -1
- package/dist/component/crons.d.ts.map +1 -1
- package/dist/component/crons.js +1 -2
- package/dist/component/crons.js.map +1 -1
- package/dist/component/dashboardStats.d.ts +8 -3
- package/dist/component/dashboardStats.d.ts.map +1 -1
- package/dist/component/dashboardStats.js +24 -39
- package/dist/component/dashboardStats.js.map +1 -1
- package/dist/component/dashboardStatsCache.d.ts +5 -11
- package/dist/component/dashboardStatsCache.d.ts.map +1 -1
- package/dist/component/dashboardStatsCache.js +12 -53
- package/dist/component/dashboardStatsCache.js.map +1 -1
- package/dist/component/deviceCategories.d.ts +22 -15
- package/dist/component/deviceCategories.d.ts.map +1 -1
- package/dist/component/deviceCategories.js +10 -4
- package/dist/component/deviceCategories.js.map +1 -1
- package/dist/component/deviceQuestions.d.ts +36 -27
- package/dist/component/deviceQuestions.d.ts.map +1 -1
- package/dist/component/deviceQuestions.js +22 -5
- package/dist/component/deviceQuestions.js.map +1 -1
- package/dist/component/deviceRepairHistory.d.ts +3 -3
- package/dist/component/deviceRepairHistory.js +1 -1
- package/dist/component/deviceRepairHistory.js.map +1 -1
- package/dist/component/deviceStatus.d.ts +8 -57
- package/dist/component/deviceStatus.d.ts.map +1 -1
- package/dist/component/deviceStatus.js +32 -30
- package/dist/component/deviceStatus.js.map +1 -1
- package/dist/component/devices.d.ts +39 -22
- package/dist/component/devices.d.ts.map +1 -1
- package/dist/component/devices.js +85 -96
- package/dist/component/devices.js.map +1 -1
- package/dist/component/emailHelpers.d.ts +10 -3
- package/dist/component/emailHelpers.d.ts.map +1 -1
- package/dist/component/emailHelpers.js +9 -20
- package/dist/component/emailHelpers.js.map +1 -1
- package/dist/component/emails.d.ts +5 -5
- package/dist/component/emails.js +2 -2
- package/dist/component/emails.js.map +1 -1
- package/dist/component/http.d.ts.map +1 -1
- package/dist/component/http.js +3 -108
- package/dist/component/http.js.map +1 -1
- package/dist/component/migrationHelpers.d.ts +29 -0
- package/dist/component/migrationHelpers.d.ts.map +1 -0
- package/dist/component/migrationHelpers.js +84 -0
- package/dist/component/migrationHelpers.js.map +1 -0
- package/dist/component/roles.d.ts +1 -0
- package/dist/component/roles.d.ts.map +1 -1
- package/dist/component/roles.js +5 -6
- package/dist/component/roles.js.map +1 -1
- package/dist/component/schema.d.ts +69 -150
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +35 -88
- package/dist/component/schema.js.map +1 -1
- package/dist/component/slaMonitoring.d.ts +16 -30
- package/dist/component/slaMonitoring.d.ts.map +1 -1
- package/dist/component/slaMonitoring.js +48 -99
- package/dist/component/slaMonitoring.js.map +1 -1
- package/dist/component/spareParts.d.ts +11 -48
- package/dist/component/spareParts.d.ts.map +1 -1
- package/dist/component/spareParts.js +41 -11
- package/dist/component/spareParts.js.map +1 -1
- package/dist/component/suppliers.d.ts +38 -19
- package/dist/component/suppliers.d.ts.map +1 -1
- package/dist/component/suppliers.js +63 -44
- package/dist/component/suppliers.js.map +1 -1
- package/dist/component/ticketComments.d.ts +18 -12
- package/dist/component/ticketComments.d.ts.map +1 -1
- package/dist/component/ticketComments.js +28 -59
- package/dist/component/ticketComments.js.map +1 -1
- package/dist/component/ticketDeviceData.d.ts +63 -0
- package/dist/component/ticketDeviceData.d.ts.map +1 -0
- package/dist/component/ticketDeviceData.js +103 -0
- package/dist/component/ticketDeviceData.js.map +1 -0
- package/dist/component/ticketExport.d.ts +22 -40
- package/dist/component/ticketExport.d.ts.map +1 -1
- package/dist/component/ticketExport.js +43 -109
- package/dist/component/ticketExport.js.map +1 -1
- package/dist/component/ticketHistory.d.ts +4 -4
- package/dist/component/ticketHistory.d.ts.map +1 -1
- package/dist/component/ticketHistory.js +6 -9
- package/dist/component/ticketHistory.js.map +1 -1
- package/dist/component/ticketMacros.d.ts +19 -18
- package/dist/component/ticketMacros.d.ts.map +1 -1
- package/dist/component/ticketMacros.js +24 -30
- package/dist/component/ticketMacros.js.map +1 -1
- package/dist/component/ticketStatuses.d.ts +1 -0
- package/dist/component/ticketStatuses.d.ts.map +1 -1
- package/dist/component/ticketStatuses.js +5 -6
- package/dist/component/ticketStatuses.js.map +1 -1
- package/dist/component/ticketTriggers.d.ts +36 -16
- package/dist/component/ticketTriggers.d.ts.map +1 -1
- package/dist/component/ticketTriggers.js +115 -153
- package/dist/component/ticketTriggers.js.map +1 -1
- package/dist/component/userProfiles.d.ts +25 -120
- package/dist/component/userProfiles.d.ts.map +1 -1
- package/dist/component/userProfiles.js +73 -384
- package/dist/component/userProfiles.js.map +1 -1
- package/dist/test.d.ts +69 -150
- package/dist/test.d.ts.map +1 -1
- package/package.json +12 -3
- package/src/client/index.ts +2 -30
- package/src/component/_generated/api.ts +4 -4
- package/src/component/_generated/component.ts +228 -350
- package/src/component/contracts.ts +7 -14
- package/src/component/crons.ts +2 -7
- package/src/component/dashboardStats.ts +24 -41
- package/src/component/dashboardStatsCache.ts +12 -61
- package/src/component/deviceCategories.ts +12 -4
- package/src/component/deviceQuestions.ts +28 -5
- package/src/component/deviceRepairHistory.ts +1 -1
- package/src/component/deviceStatus.ts +43 -45
- package/src/component/devices.ts +87 -106
- package/src/component/emailHelpers.ts +9 -19
- package/src/component/emails.ts +2 -2
- package/src/component/http.ts +3 -108
- package/src/component/migrationHelpers.ts +96 -0
- package/src/component/roles.ts +5 -6
- package/src/component/schema.ts +35 -93
- package/src/component/slaMonitoring.ts +52 -107
- package/src/component/spareParts.ts +46 -12
- package/src/component/suppliers.ts +71 -48
- package/src/component/ticketComments.ts +28 -71
- package/src/component/ticketDeviceData.ts +113 -0
- package/src/component/ticketExport.ts +52 -137
- package/src/component/ticketHistory.ts +6 -9
- package/src/component/ticketMacros.ts +25 -37
- package/src/component/ticketStatuses.ts +5 -6
- package/src/component/ticketTriggers.ts +121 -217
- package/src/component/userProfiles.ts +67 -451
- package/dist/component/clinics.d.ts +0 -103
- package/dist/component/clinics.d.ts.map +0 -1
- package/dist/component/clinics.js +0 -126
- package/dist/component/clinics.js.map +0 -1
- package/dist/component/maintenanceTasks.d.ts +0 -733
- package/dist/component/maintenanceTasks.d.ts.map +0 -1
- package/dist/component/maintenanceTasks.js +0 -937
- package/dist/component/maintenanceTasks.js.map +0 -1
- package/src/component/clinics.ts +0 -136
- package/src/component/maintenanceTasks.ts +0 -1003
|
@@ -1,58 +1,60 @@
|
|
|
1
1
|
import { query } from './_generated/server';
|
|
2
2
|
import { v } from 'convex/values';
|
|
3
3
|
export const computeDeviceStatus = query({
|
|
4
|
-
args: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.
|
|
8
|
-
.
|
|
9
|
-
.
|
|
10
|
-
|
|
4
|
+
args: {
|
|
5
|
+
deviceId: v.id('devices'),
|
|
6
|
+
tickets: v.optional(v.array(v.object({
|
|
7
|
+
status: v.string(),
|
|
8
|
+
description: v.optional(v.string()),
|
|
9
|
+
created_at: v.optional(v.number()),
|
|
10
|
+
updated_at: v.optional(v.number()),
|
|
11
|
+
}))),
|
|
12
|
+
},
|
|
13
|
+
handler: async (ctx, args) => {
|
|
14
|
+
const tickets = args.tickets || [];
|
|
15
|
+
if (tickets.length === 0)
|
|
11
16
|
return 'in_uso';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
t.updated_at &&
|
|
15
|
-
t.created_at < t.updated_at);
|
|
16
|
-
if (smaltito) {
|
|
17
|
+
const smaltito = tickets.find((t) => t.status === 'smaltito' && t.updated_at && t.created_at && t.created_at < t.updated_at);
|
|
18
|
+
if (smaltito)
|
|
17
19
|
return 'smaltito';
|
|
18
|
-
}
|
|
19
20
|
const raee = tickets.find((t) => t.description?.toLowerCase().includes('raee') ||
|
|
20
21
|
t.description?.toLowerCase().includes('smaltimento'));
|
|
21
|
-
if (raee && raee.status !== 'closed' && raee.status !== 'completed')
|
|
22
|
+
if (raee && raee.status !== 'closed' && raee.status !== 'completed')
|
|
22
23
|
return 'da_smaltire';
|
|
23
|
-
}
|
|
24
24
|
const openTickets = tickets.filter((t) => t.status === 'open' ||
|
|
25
25
|
t.status === 'assigned_to_supplier' ||
|
|
26
26
|
t.status === 'in_progress' ||
|
|
27
27
|
t.status === 'pending');
|
|
28
|
-
if (openTickets.length > 0)
|
|
28
|
+
if (openTickets.length > 0)
|
|
29
29
|
return 'guasto';
|
|
30
|
-
}
|
|
31
30
|
return 'in_uso';
|
|
32
31
|
},
|
|
33
32
|
});
|
|
34
33
|
export const getDeviceTicketHistory = query({
|
|
35
|
-
args: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
args: {
|
|
35
|
+
deviceId: v.id('devices'),
|
|
36
|
+
tickets: v.optional(v.array(v.any())),
|
|
37
|
+
},
|
|
38
|
+
handler: async (ctx, args) => {
|
|
39
|
+
const tickets = args.tickets || [];
|
|
40
|
+
const deviceDataEntries = await ctx.db
|
|
41
|
+
.query('ticket_device_data')
|
|
42
|
+
.withIndex('by_deviceId', (q) => q.eq('deviceId', args.deviceId))
|
|
43
|
+
.collect();
|
|
44
|
+
const ticketIdSet = new Set(deviceDataEntries.map(d => d.ticketId));
|
|
45
|
+
const enriched = await Promise.all(tickets
|
|
46
|
+
.filter((t) => ticketIdSet.has(t._id?.toString() || t.ticketId))
|
|
47
|
+
.map(async (ticket) => {
|
|
46
48
|
const supplier = ticket.supplierId
|
|
47
49
|
? await ctx.db.get(ticket.supplierId)
|
|
48
50
|
: null;
|
|
49
51
|
return {
|
|
50
52
|
...ticket,
|
|
51
|
-
clinic,
|
|
53
|
+
clinic: null,
|
|
52
54
|
supplier,
|
|
53
55
|
};
|
|
54
56
|
}));
|
|
55
|
-
return
|
|
57
|
+
return enriched;
|
|
56
58
|
},
|
|
57
59
|
});
|
|
58
60
|
//# sourceMappingURL=deviceStatus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceStatus.js","sourceRoot":"","sources":["../../src/component/deviceStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;IACvC,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"deviceStatus.js","sourceRoot":"","sources":["../../src/component/deviceStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;IACvC,IAAI,EAAE;QACJ,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC;QACzB,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;YACnC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;YAClB,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YACnC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YAClC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACnC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CACF,CAAC,CAAC"}
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
export declare const listDevices: import("convex/server").RegisteredQuery<"public", {
|
|
2
|
-
clinicId?:
|
|
2
|
+
clinicId?: string | undefined;
|
|
3
|
+
category?: string | undefined;
|
|
4
|
+
status?: string | undefined;
|
|
5
|
+
page?: number | undefined;
|
|
6
|
+
pageSize?: number | undefined;
|
|
7
|
+
search?: string | undefined;
|
|
3
8
|
userSelectedClinicId?: number | undefined;
|
|
4
|
-
userClinicId?:
|
|
9
|
+
userClinicId?: string | undefined;
|
|
5
10
|
userRole?: string | undefined;
|
|
6
11
|
_triggerReload?: number | undefined;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
userSupplierId?: import("convex/values").GenericId<"suppliers"> | undefined;
|
|
13
|
+
}, Promise<{
|
|
14
|
+
page: any[];
|
|
15
|
+
totalCount: number;
|
|
16
|
+
totalPages: number;
|
|
17
|
+
currentPage: number;
|
|
18
|
+
}>>;
|
|
12
19
|
export declare const listDevicesPaginated: import("convex/server").RegisteredQuery<"public", {
|
|
13
|
-
clinicId?:
|
|
20
|
+
clinicId?: string | undefined;
|
|
14
21
|
category?: string | undefined;
|
|
15
22
|
brand?: string | undefined;
|
|
16
23
|
status?: string | undefined;
|
|
17
24
|
userSelectedClinicId?: number | undefined;
|
|
18
|
-
userClinicId?:
|
|
25
|
+
userClinicId?: string | undefined;
|
|
19
26
|
userRole?: string | undefined;
|
|
20
27
|
searchTerm?: string | undefined;
|
|
21
28
|
paginationOpts: {
|
|
@@ -33,19 +40,19 @@ export declare const listDevicesPaginated: import("convex/server").RegisteredQue
|
|
|
33
40
|
internalId: any;
|
|
34
41
|
status: any;
|
|
35
42
|
clinicId: any;
|
|
36
|
-
clinicName:
|
|
43
|
+
clinicName: string;
|
|
37
44
|
photoUrl: string | null;
|
|
38
45
|
}[];
|
|
39
46
|
isDone: boolean;
|
|
40
47
|
continueCursor: string;
|
|
41
48
|
}>>;
|
|
42
49
|
export declare const getDevicesCount: import("convex/server").RegisteredQuery<"public", {
|
|
43
|
-
clinicId?:
|
|
50
|
+
clinicId?: string | undefined;
|
|
44
51
|
category?: string | undefined;
|
|
45
52
|
brand?: string | undefined;
|
|
46
53
|
status?: string | undefined;
|
|
47
54
|
userSelectedClinicId?: number | undefined;
|
|
48
|
-
userClinicId?:
|
|
55
|
+
userClinicId?: string | undefined;
|
|
49
56
|
userRole?: string | undefined;
|
|
50
57
|
}, Promise<{
|
|
51
58
|
total: number;
|
|
@@ -83,7 +90,7 @@ export declare const getDevice: import("convex/server").RegisteredQuery<"public"
|
|
|
83
90
|
authorizationsStorageIds?: import("convex/values").GenericId<"_storage">[] | undefined;
|
|
84
91
|
otherAttachmentsStorageIds?: import("convex/values").GenericId<"_storage">[] | undefined;
|
|
85
92
|
name: string;
|
|
86
|
-
clinicId:
|
|
93
|
+
clinicId: string;
|
|
87
94
|
category: string;
|
|
88
95
|
brand: string;
|
|
89
96
|
model: string;
|
|
@@ -123,7 +130,7 @@ export declare const getById: import("convex/server").RegisteredQuery<"public",
|
|
|
123
130
|
authorizationsStorageIds?: import("convex/values").GenericId<"_storage">[] | undefined;
|
|
124
131
|
otherAttachmentsStorageIds?: import("convex/values").GenericId<"_storage">[] | undefined;
|
|
125
132
|
name: string;
|
|
126
|
-
clinicId:
|
|
133
|
+
clinicId: string;
|
|
127
134
|
category: string;
|
|
128
135
|
brand: string;
|
|
129
136
|
model: string;
|
|
@@ -163,7 +170,7 @@ export declare const listAllDevicesForMigration: import("convex/server").Registe
|
|
|
163
170
|
authorizationsStorageIds?: import("convex/values").GenericId<"_storage">[] | undefined;
|
|
164
171
|
otherAttachmentsStorageIds?: import("convex/values").GenericId<"_storage">[] | undefined;
|
|
165
172
|
name: string;
|
|
166
|
-
clinicId:
|
|
173
|
+
clinicId: string;
|
|
167
174
|
category: string;
|
|
168
175
|
brand: string;
|
|
169
176
|
model: string;
|
|
@@ -174,6 +181,7 @@ export declare const generateUploadUrl: import("convex/server").RegisteredMutati
|
|
|
174
181
|
export declare const createDevice: import("convex/server").RegisteredMutation<"public", {
|
|
175
182
|
supplierId?: import("convex/values").GenericId<"suppliers"> | undefined;
|
|
176
183
|
metadata?: any;
|
|
184
|
+
primoupClinicId?: number | undefined;
|
|
177
185
|
photoStorageId?: import("convex/values").GenericId<"_storage"> | undefined;
|
|
178
186
|
internalId?: string | undefined;
|
|
179
187
|
industry40Data?: string | undefined;
|
|
@@ -194,7 +202,7 @@ export declare const createDevice: import("convex/server").RegisteredMutation<"p
|
|
|
194
202
|
authorizationsStorageIds?: import("convex/values").GenericId<"_storage">[] | undefined;
|
|
195
203
|
otherAttachmentsStorageIds?: import("convex/values").GenericId<"_storage">[] | undefined;
|
|
196
204
|
name: string;
|
|
197
|
-
clinicId:
|
|
205
|
+
clinicId: string;
|
|
198
206
|
category: string;
|
|
199
207
|
brand: string;
|
|
200
208
|
model: string;
|
|
@@ -203,7 +211,7 @@ export declare const createDevice: import("convex/server").RegisteredMutation<"p
|
|
|
203
211
|
}, Promise<import("convex/values").GenericId<"devices">>>;
|
|
204
212
|
export declare const updateDevice: import("convex/server").RegisteredMutation<"public", {
|
|
205
213
|
name?: string | undefined;
|
|
206
|
-
clinicId?:
|
|
214
|
+
clinicId?: string | undefined;
|
|
207
215
|
supplierId?: import("convex/values").GenericId<"suppliers"> | undefined;
|
|
208
216
|
metadata?: any;
|
|
209
217
|
primoupClinicId?: number | undefined;
|
|
@@ -243,7 +251,7 @@ export declare const updateDeviceByUser: import("convex/server").RegisteredMutat
|
|
|
243
251
|
status?: "active" | "in_maintenance" | "out_of_service" | undefined;
|
|
244
252
|
industry40Data?: string | undefined;
|
|
245
253
|
userSelectedClinicId?: number | undefined;
|
|
246
|
-
userClinicId?:
|
|
254
|
+
userClinicId?: string | undefined;
|
|
247
255
|
deviceId: import("convex/values").GenericId<"devices">;
|
|
248
256
|
userRole: string;
|
|
249
257
|
}, Promise<import("convex/values").GenericId<"devices">>>;
|
|
@@ -253,7 +261,7 @@ export declare const deleteDevice: import("convex/server").RegisteredMutation<"p
|
|
|
253
261
|
success: boolean;
|
|
254
262
|
}>>;
|
|
255
263
|
export declare const getDeviceStats: import("convex/server").RegisteredQuery<"public", {
|
|
256
|
-
userClinicId?:
|
|
264
|
+
userClinicId?: string | undefined;
|
|
257
265
|
userRole?: string | undefined;
|
|
258
266
|
}, Promise<{
|
|
259
267
|
total: number;
|
|
@@ -264,7 +272,16 @@ export declare const getDeviceStats: import("convex/server").RegisteredQuery<"pu
|
|
|
264
272
|
export declare const getFileUrl: import("convex/server").RegisteredQuery<"public", {
|
|
265
273
|
storageId: import("convex/values").GenericId<"_storage">;
|
|
266
274
|
}, Promise<string | null>>;
|
|
267
|
-
export declare const listAllDevicesForExport: import("convex/server").RegisteredQuery<"public", {}, Promise<
|
|
275
|
+
export declare const listAllDevicesForExport: import("convex/server").RegisteredQuery<"public", {}, Promise<{
|
|
276
|
+
clinicId: string;
|
|
277
|
+
clinicName: string;
|
|
278
|
+
category: string;
|
|
279
|
+
brand: string;
|
|
280
|
+
model: string;
|
|
281
|
+
serial_number: string;
|
|
282
|
+
quantity: number;
|
|
283
|
+
status: "active" | "in_maintenance" | "out_of_service";
|
|
284
|
+
}[]>>;
|
|
268
285
|
export declare const getDeviceTemplates: import("convex/server").RegisteredQuery<"public", {
|
|
269
286
|
searchQuery?: string | undefined;
|
|
270
287
|
}, Promise<{
|
|
@@ -276,8 +293,8 @@ export declare const getDeviceTemplates: import("convex/server").RegisteredQuery
|
|
|
276
293
|
}[];
|
|
277
294
|
}[]>>;
|
|
278
295
|
export declare const createDeviceByUser: import("convex/server").RegisteredMutation<"public", {
|
|
279
|
-
userPrimoupClinics?: any[] | undefined;
|
|
280
296
|
name: string;
|
|
297
|
+
clinicId: string;
|
|
281
298
|
category: string;
|
|
282
299
|
brand: string;
|
|
283
300
|
model: string;
|
|
@@ -290,7 +307,7 @@ export declare const listAllDevicesForAdmin: import("convex/server").RegisteredQ
|
|
|
290
307
|
category: string;
|
|
291
308
|
brand: string;
|
|
292
309
|
model: string;
|
|
293
|
-
clinicId:
|
|
310
|
+
clinicId: string;
|
|
294
311
|
}[]>>;
|
|
295
312
|
export declare const getUniqueBrandsAndModels: import("convex/server").RegisteredQuery<"public", {}, Promise<{
|
|
296
313
|
brands: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devices.d.ts","sourceRoot":"","sources":["../../src/component/devices.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"devices.d.ts","sourceRoot":"","sources":["../../src/component/devices.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;GAgFtB,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwG/B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;GA2C1B,CAAC;AAEH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAWpB,CAAC;AAEH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAWlB,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiBrC,CAAC;AAEH,eAAO,MAAM,iBAAiB,2EAK5B,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDAsCvB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDAkDvB,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;yDAsC7B,CAAC;AAEH,eAAO,MAAM,YAAY;;;;GAWvB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;GAuCzB,CAAC;AAEH,eAAO,MAAM,UAAU;;0BAMrB,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;KAelC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;KAiD7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;yDAyB7B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;KAcjC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;GAsBnC,CAAC"}
|
|
@@ -11,59 +11,80 @@ async function getPhotoUrl(ctx, device) {
|
|
|
11
11
|
}
|
|
12
12
|
export const listDevices = query({
|
|
13
13
|
args: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
page: v.optional(v.number()),
|
|
15
|
+
pageSize: v.optional(v.number()),
|
|
16
|
+
clinicId: v.optional(v.string()),
|
|
17
|
+
search: v.optional(v.string()),
|
|
18
|
+
category: v.optional(v.string()),
|
|
19
|
+
status: v.optional(v.string()),
|
|
19
20
|
_triggerReload: v.optional(v.number()),
|
|
20
21
|
userRole: v.optional(v.string()),
|
|
21
|
-
userClinicId: v.optional(v.
|
|
22
|
+
userClinicId: v.optional(v.string()),
|
|
22
23
|
userSelectedClinicId: v.optional(v.number()),
|
|
24
|
+
userSupplierId: v.optional(v.id('suppliers')),
|
|
23
25
|
},
|
|
24
26
|
handler: async (ctx, args) => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
+
const page = args.page || 1;
|
|
28
|
+
const pageSize = args.pageSize || 40;
|
|
29
|
+
let baseQuery;
|
|
27
30
|
if (args.userRole === 'admin') {
|
|
28
31
|
if (args.clinicId) {
|
|
29
|
-
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
baseQuery = ctx.db.query('devices')
|
|
33
|
+
.withIndex('by_clinicId', (q) => q.eq('clinicId', args.clinicId));
|
|
34
|
+
}
|
|
35
|
+
else if (args.userSelectedClinicId) {
|
|
36
|
+
baseQuery = ctx.db.query('devices')
|
|
37
|
+
.withIndex('by_primoupClinicId', (q) => q.eq('primoupClinicId', args.userSelectedClinicId));
|
|
34
38
|
}
|
|
35
39
|
else {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
baseQuery = ctx.db.query('devices');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if (args.userRole === 'supplier') {
|
|
44
|
+
if (args.userSupplierId) {
|
|
45
|
+
baseQuery = ctx.db.query('devices')
|
|
46
|
+
.withIndex('by_supplierId', (q) => q.eq('supplierId', args.userSupplierId));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return { page: [], totalCount: 0, totalPages: 0, currentPage: page };
|
|
40
50
|
}
|
|
41
51
|
}
|
|
42
52
|
else if (args.userRole === 'user') {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
devices = await ctx.db
|
|
47
|
-
.query('devices')
|
|
48
|
-
.withIndex('by_primoupClinicId', (q) => q.eq('primoupClinicId', selectedClinicId))
|
|
49
|
-
.take(limit);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
devices = [];
|
|
53
|
-
}
|
|
53
|
+
if (args.userSelectedClinicId) {
|
|
54
|
+
baseQuery = ctx.db.query('devices')
|
|
55
|
+
.withIndex('by_primoupClinicId', (q) => q.eq('primoupClinicId', args.userSelectedClinicId));
|
|
54
56
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
else {
|
|
58
|
+
return { page: [], totalCount: 0, totalPages: 0, currentPage: page };
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
else {
|
|
60
|
-
|
|
62
|
+
return { page: [], totalCount: 0, totalPages: 0, currentPage: page };
|
|
63
|
+
}
|
|
64
|
+
let allDevices = await baseQuery.collect();
|
|
65
|
+
if (args.search) {
|
|
66
|
+
const s = args.search.toLowerCase();
|
|
67
|
+
allDevices = allDevices.filter((d) => d.name?.toLowerCase().includes(s) ||
|
|
68
|
+
d.brand?.toLowerCase().includes(s) ||
|
|
69
|
+
d.model?.toLowerCase().includes(s) ||
|
|
70
|
+
d.serialNumber?.toLowerCase().includes(s) ||
|
|
71
|
+
d.internalId?.toLowerCase().includes(s));
|
|
61
72
|
}
|
|
62
|
-
|
|
73
|
+
if (args.category) {
|
|
74
|
+
allDevices = allDevices.filter((d) => d.category === args.category);
|
|
75
|
+
}
|
|
76
|
+
if (args.status) {
|
|
77
|
+
allDevices = allDevices.filter((d) => d.status === args.status);
|
|
78
|
+
}
|
|
79
|
+
const totalCount = allDevices.length;
|
|
80
|
+
const totalPages = Math.ceil(totalCount / pageSize);
|
|
81
|
+
const startIndex = (page - 1) * pageSize;
|
|
82
|
+
const pageDevices = allDevices.slice(startIndex, startIndex + pageSize);
|
|
83
|
+
const devicesWithUrls = await Promise.all(pageDevices.map(async (device) => ({
|
|
63
84
|
...device,
|
|
64
85
|
photoUrl: await getPhotoUrl(ctx, device),
|
|
65
86
|
})));
|
|
66
|
-
return devicesWithUrls;
|
|
87
|
+
return { page: devicesWithUrls, totalCount, totalPages, currentPage: page };
|
|
67
88
|
},
|
|
68
89
|
});
|
|
69
90
|
export const listDevicesPaginated = query({
|
|
@@ -76,9 +97,9 @@ export const listDevicesPaginated = query({
|
|
|
76
97
|
brand: v.optional(v.string()),
|
|
77
98
|
status: v.optional(v.string()),
|
|
78
99
|
searchTerm: v.optional(v.string()),
|
|
79
|
-
clinicId: v.optional(v.
|
|
100
|
+
clinicId: v.optional(v.string()),
|
|
80
101
|
userRole: v.optional(v.string()),
|
|
81
|
-
userClinicId: v.optional(v.
|
|
102
|
+
userClinicId: v.optional(v.string()),
|
|
82
103
|
userSelectedClinicId: v.optional(v.number()),
|
|
83
104
|
},
|
|
84
105
|
handler: async (ctx, args) => {
|
|
@@ -125,8 +146,11 @@ export const listDevicesPaginated = query({
|
|
|
125
146
|
if (args.status && !(args.userRole === 'admin' && !args.clinicId && !args.category)) {
|
|
126
147
|
filteredQuery = filteredQuery.filter((q) => q.eq(q.field('status'), args.status));
|
|
127
148
|
}
|
|
128
|
-
const
|
|
129
|
-
|
|
149
|
+
const limit = args.paginationOpts.numItems + 1;
|
|
150
|
+
const allResults = await filteredQuery.take(limit);
|
|
151
|
+
const isDone = allResults.length < limit;
|
|
152
|
+
const page = isDone ? allResults : allResults.slice(0, -1);
|
|
153
|
+
let filteredPage = page;
|
|
130
154
|
if (args.searchTerm) {
|
|
131
155
|
const search = args.searchTerm.toLowerCase();
|
|
132
156
|
filteredPage = filteredPage.filter((device) => device.name?.toLowerCase().includes(search) ||
|
|
@@ -135,9 +159,6 @@ export const listDevicesPaginated = query({
|
|
|
135
159
|
device.serialNumber?.toLowerCase().includes(search) ||
|
|
136
160
|
device.internalId?.toLowerCase().includes(search));
|
|
137
161
|
}
|
|
138
|
-
const clinicIds = [...new Set(filteredPage.map((d) => d.clinicId).filter(Boolean))];
|
|
139
|
-
const clinics = await Promise.all(clinicIds.map(id => ctx.db.get(id)));
|
|
140
|
-
const clinicMap = new Map(clinics.filter(Boolean).map((c) => [c._id.toString(), c.name]));
|
|
141
162
|
const minimalPage = await Promise.all(filteredPage.map(async (device) => ({
|
|
142
163
|
_id: device._id,
|
|
143
164
|
name: device.name,
|
|
@@ -148,15 +169,15 @@ export const listDevicesPaginated = query({
|
|
|
148
169
|
internalId: device.internalId,
|
|
149
170
|
status: device.status,
|
|
150
171
|
clinicId: device.clinicId,
|
|
151
|
-
clinicName:
|
|
172
|
+
clinicName: '',
|
|
152
173
|
photoUrl: device.photoStorageId
|
|
153
174
|
? await ctx.storage.getUrl(device.photoStorageId)
|
|
154
175
|
: null,
|
|
155
176
|
})));
|
|
156
177
|
return {
|
|
157
178
|
page: minimalPage,
|
|
158
|
-
isDone
|
|
159
|
-
continueCursor:
|
|
179
|
+
isDone,
|
|
180
|
+
continueCursor: '',
|
|
160
181
|
};
|
|
161
182
|
},
|
|
162
183
|
});
|
|
@@ -165,9 +186,9 @@ export const getDevicesCount = query({
|
|
|
165
186
|
category: v.optional(v.string()),
|
|
166
187
|
brand: v.optional(v.string()),
|
|
167
188
|
status: v.optional(v.string()),
|
|
168
|
-
clinicId: v.optional(v.
|
|
189
|
+
clinicId: v.optional(v.string()),
|
|
169
190
|
userRole: v.optional(v.string()),
|
|
170
|
-
userClinicId: v.optional(v.
|
|
191
|
+
userClinicId: v.optional(v.string()),
|
|
171
192
|
userSelectedClinicId: v.optional(v.number()),
|
|
172
193
|
},
|
|
173
194
|
handler: async (ctx, args) => {
|
|
@@ -253,7 +274,8 @@ export const generateUploadUrl = mutation({
|
|
|
253
274
|
});
|
|
254
275
|
export const createDevice = mutation({
|
|
255
276
|
args: {
|
|
256
|
-
clinicId: v.
|
|
277
|
+
clinicId: v.string(),
|
|
278
|
+
primoupClinicId: v.optional(v.number()),
|
|
257
279
|
supplierId: v.optional(v.id('suppliers')),
|
|
258
280
|
name: v.string(),
|
|
259
281
|
category: v.string(),
|
|
@@ -284,13 +306,6 @@ export const createDevice = mutation({
|
|
|
284
306
|
},
|
|
285
307
|
handler: async (ctx, args) => {
|
|
286
308
|
const deviceData = { ...args };
|
|
287
|
-
const clinic = await ctx.db.get(args.clinicId);
|
|
288
|
-
if (clinic?.primoupId) {
|
|
289
|
-
const primoupIdNum = parseInt(clinic.primoupId, 10);
|
|
290
|
-
if (!isNaN(primoupIdNum)) {
|
|
291
|
-
deviceData.primoupClinicId = primoupIdNum;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
309
|
const deviceId = await ctx.db.insert('devices', deviceData);
|
|
295
310
|
return deviceId;
|
|
296
311
|
},
|
|
@@ -298,7 +313,7 @@ export const createDevice = mutation({
|
|
|
298
313
|
export const updateDevice = mutation({
|
|
299
314
|
args: {
|
|
300
315
|
deviceId: v.id('devices'),
|
|
301
|
-
clinicId: v.optional(v.
|
|
316
|
+
clinicId: v.optional(v.string()),
|
|
302
317
|
primoupClinicId: v.optional(v.number()),
|
|
303
318
|
supplierId: v.optional(v.id('suppliers')),
|
|
304
319
|
name: v.optional(v.string()),
|
|
@@ -356,7 +371,7 @@ export const updateDeviceByUser = mutation({
|
|
|
356
371
|
industry40Data: v.optional(v.string()),
|
|
357
372
|
userRole: v.string(),
|
|
358
373
|
userSelectedClinicId: v.optional(v.number()),
|
|
359
|
-
userClinicId: v.optional(v.
|
|
374
|
+
userClinicId: v.optional(v.string()),
|
|
360
375
|
},
|
|
361
376
|
handler: async (ctx, args) => {
|
|
362
377
|
const device = await ctx.db.get(args.deviceId);
|
|
@@ -396,7 +411,7 @@ export const deleteDevice = mutation({
|
|
|
396
411
|
export const getDeviceStats = query({
|
|
397
412
|
args: {
|
|
398
413
|
userRole: v.optional(v.string()),
|
|
399
|
-
userClinicId: v.optional(v.
|
|
414
|
+
userClinicId: v.optional(v.string()),
|
|
400
415
|
},
|
|
401
416
|
handler: async (ctx, args) => {
|
|
402
417
|
try {
|
|
@@ -444,26 +459,17 @@ export const getFileUrl = query({
|
|
|
444
459
|
export const listAllDevicesForExport = query({
|
|
445
460
|
args: {},
|
|
446
461
|
handler: async (ctx) => {
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
brand: device.brand || '',
|
|
459
|
-
model: device.model || '',
|
|
460
|
-
serial_number: device.serial_number || '',
|
|
461
|
-
quantity: device.quantity || 1,
|
|
462
|
-
status: device.status || 'active',
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
return results;
|
|
462
|
+
const devices = await ctx.db.query('devices').take(5000);
|
|
463
|
+
return devices.map(device => ({
|
|
464
|
+
clinicId: device.clinicId,
|
|
465
|
+
clinicName: '',
|
|
466
|
+
category: device.category || '',
|
|
467
|
+
brand: device.brand || '',
|
|
468
|
+
model: device.model || '',
|
|
469
|
+
serial_number: device.serial_number || '',
|
|
470
|
+
quantity: device.quantity || 1,
|
|
471
|
+
status: device.status || 'active',
|
|
472
|
+
}));
|
|
467
473
|
},
|
|
468
474
|
});
|
|
469
475
|
export const getDeviceTemplates = query({
|
|
@@ -510,35 +516,18 @@ export const getDeviceTemplates = query({
|
|
|
510
516
|
});
|
|
511
517
|
export const createDeviceByUser = mutation({
|
|
512
518
|
args: {
|
|
519
|
+
clinicId: v.string(),
|
|
513
520
|
name: v.string(),
|
|
514
521
|
category: v.string(),
|
|
515
522
|
brand: v.string(),
|
|
516
523
|
model: v.string(),
|
|
517
524
|
serial_number: v.string(),
|
|
518
525
|
userSelectedClinicId: v.number(),
|
|
519
|
-
userPrimoupClinics: v.optional(v.array(v.any())),
|
|
520
526
|
},
|
|
521
527
|
handler: async (ctx, args) => {
|
|
522
|
-
const selectedClinicId = args.userSelectedClinicId;
|
|
523
|
-
const primoupClinics = args.userPrimoupClinics || [];
|
|
524
|
-
const selectedPrimoupClinic = primoupClinics.find((c) => c.id === selectedClinicId);
|
|
525
|
-
if (!selectedPrimoupClinic) {
|
|
526
|
-
throw new Error('Selected clinic not found in user profile');
|
|
527
|
-
}
|
|
528
|
-
let clinic = await ctx.db
|
|
529
|
-
.query('clinics')
|
|
530
|
-
.withIndex('by_primoupId', (q) => q.eq('primoupId', String(selectedClinicId)))
|
|
531
|
-
.first();
|
|
532
|
-
if (!clinic) {
|
|
533
|
-
const clinics = await ctx.db.query('clinics').take(500);
|
|
534
|
-
clinic = clinics.find(c => c.name === selectedPrimoupClinic.name) || null;
|
|
535
|
-
}
|
|
536
|
-
if (!clinic) {
|
|
537
|
-
throw new Error('Clinic not found in database');
|
|
538
|
-
}
|
|
539
528
|
const deviceId = await ctx.db.insert('devices', {
|
|
540
|
-
clinicId:
|
|
541
|
-
primoupClinicId:
|
|
529
|
+
clinicId: args.clinicId,
|
|
530
|
+
primoupClinicId: args.userSelectedClinicId,
|
|
542
531
|
name: args.name,
|
|
543
532
|
category: args.category,
|
|
544
533
|
brand: args.brand,
|