@bizmap/sdk 0.0.94 → 0.0.96
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/main.d.ts +60 -54
- package/dist/main.js +25 -26
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -181,6 +181,7 @@ declare const CompanyDetails: z.ZodObject<{
|
|
|
181
181
|
RR: "RR";
|
|
182
182
|
LOR: "LOR";
|
|
183
183
|
}>>;
|
|
184
|
+
servicesDeployed: z.ZodBoolean;
|
|
184
185
|
}, z.core.$strip>;
|
|
185
186
|
billing: z.ZodObject<{
|
|
186
187
|
lastModified: z.ZodNullable<z.ZodInt>;
|
|
@@ -224,18 +225,15 @@ declare const CompanyDetails: z.ZodObject<{
|
|
|
224
225
|
percentage: z.ZodNumber;
|
|
225
226
|
isOptional: z.ZodBoolean;
|
|
226
227
|
}, z.core.$strip>>;
|
|
227
|
-
offeredServices: z.ZodObject<{
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
cost: z.ZodNumber;
|
|
237
|
-
}, z.core.$strip>>;
|
|
238
|
-
}, z.core.$strip>;
|
|
228
|
+
offeredServices: z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
229
|
+
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
230
|
+
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
231
|
+
currency: z.ZodEnum<{
|
|
232
|
+
JMD: "JMD";
|
|
233
|
+
}>;
|
|
234
|
+
item: z.ZodString;
|
|
235
|
+
cost: z.ZodNumber;
|
|
236
|
+
}, z.core.$strip>>;
|
|
239
237
|
}, z.core.$strip>;
|
|
240
238
|
staff: z.ZodObject<{
|
|
241
239
|
lastModified: z.ZodNullable<z.ZodInt>;
|
|
@@ -322,6 +320,7 @@ declare const MutableCompanyDetails: z.ZodObject<{
|
|
|
322
320
|
RR: "RR";
|
|
323
321
|
LOR: "LOR";
|
|
324
322
|
}>>>;
|
|
323
|
+
servicesDeployed: z.ZodOptional<z.ZodBoolean>;
|
|
325
324
|
}, z.core.$strip>>;
|
|
326
325
|
billing: z.ZodOptional<z.ZodObject<{
|
|
327
326
|
version: z.ZodOptional<z.ZodInt>;
|
|
@@ -365,18 +364,15 @@ declare const MutableCompanyDetails: z.ZodObject<{
|
|
|
365
364
|
percentage: z.ZodNumber;
|
|
366
365
|
isOptional: z.ZodBoolean;
|
|
367
366
|
}, z.core.$strip>>>;
|
|
368
|
-
offeredServices: z.ZodOptional<z.ZodObject<{
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
cost: z.ZodNumber;
|
|
378
|
-
}, z.core.$strip>>;
|
|
379
|
-
}, z.core.$strip>>;
|
|
367
|
+
offeredServices: z.ZodOptional<z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
368
|
+
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
369
|
+
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
370
|
+
currency: z.ZodEnum<{
|
|
371
|
+
JMD: "JMD";
|
|
372
|
+
}>;
|
|
373
|
+
item: z.ZodString;
|
|
374
|
+
cost: z.ZodNumber;
|
|
375
|
+
}, z.core.$strip>>>;
|
|
380
376
|
}, z.core.$strip>>;
|
|
381
377
|
staff: z.ZodOptional<z.ZodObject<{
|
|
382
378
|
partnerMap: z.ZodOptional<z.ZodRecord<z.ZodUUID, z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
@@ -443,18 +439,15 @@ declare const CompanyBilling: z.ZodObject<{
|
|
|
443
439
|
percentage: z.ZodNumber;
|
|
444
440
|
isOptional: z.ZodBoolean;
|
|
445
441
|
}, z.core.$strip>>;
|
|
446
|
-
offeredServices: z.ZodObject<{
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
cost: z.ZodNumber;
|
|
456
|
-
}, z.core.$strip>>;
|
|
457
|
-
}, z.core.$strip>;
|
|
442
|
+
offeredServices: z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
443
|
+
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
444
|
+
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
445
|
+
currency: z.ZodEnum<{
|
|
446
|
+
JMD: "JMD";
|
|
447
|
+
}>;
|
|
448
|
+
item: z.ZodString;
|
|
449
|
+
cost: z.ZodNumber;
|
|
450
|
+
}, z.core.$strip>>;
|
|
458
451
|
version: z.ZodInt;
|
|
459
452
|
lastModified: z.ZodNullable<z.ZodInt>;
|
|
460
453
|
}, z.core.$strip>;
|
|
@@ -501,18 +494,15 @@ declare const MutableCompanyBilling: z.ZodObject<{
|
|
|
501
494
|
percentage: z.ZodNumber;
|
|
502
495
|
isOptional: z.ZodBoolean;
|
|
503
496
|
}, z.core.$strip>>;
|
|
504
|
-
offeredServices: z.ZodObject<{
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
cost: z.ZodNumber;
|
|
514
|
-
}, z.core.$strip>>;
|
|
515
|
-
}, z.core.$strip>;
|
|
497
|
+
offeredServices: z.ZodRecord<z.ZodUUID, z.ZodObject<{
|
|
498
|
+
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
499
|
+
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
500
|
+
currency: z.ZodEnum<{
|
|
501
|
+
JMD: "JMD";
|
|
502
|
+
}>;
|
|
503
|
+
item: z.ZodString;
|
|
504
|
+
cost: z.ZodNumber;
|
|
505
|
+
}, z.core.$strip>>;
|
|
516
506
|
}, z.core.$strip>;
|
|
517
507
|
type MutableCompanyBilling = z.infer<typeof MutableCompanyBilling>;
|
|
518
508
|
|
|
@@ -601,6 +591,7 @@ declare const CompanyPreferences: z.ZodObject<{
|
|
|
601
591
|
RR: "RR";
|
|
602
592
|
LOR: "LOR";
|
|
603
593
|
}>>;
|
|
594
|
+
servicesDeployed: z.ZodBoolean;
|
|
604
595
|
version: z.ZodInt;
|
|
605
596
|
lastModified: z.ZodNullable<z.ZodInt>;
|
|
606
597
|
}, z.core.$strip>;
|
|
@@ -617,6 +608,7 @@ declare const MutableCompanyPreferences: z.ZodObject<{
|
|
|
617
608
|
RR: "RR";
|
|
618
609
|
LOR: "LOR";
|
|
619
610
|
}>>;
|
|
611
|
+
servicesDeployed: z.ZodBoolean;
|
|
620
612
|
}, z.core.$strip>;
|
|
621
613
|
type MutableCompanyPreferences = z.infer<typeof MutableCompanyPreferences>;
|
|
622
614
|
|
|
@@ -1031,7 +1023,6 @@ declare const ClientIdentity: z.ZodObject<{
|
|
|
1031
1023
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
1032
1024
|
version: z.ZodInt;
|
|
1033
1025
|
_id: z.ZodUUID;
|
|
1034
|
-
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
1035
1026
|
photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1036
1027
|
firstName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1037
1028
|
middleName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -1044,6 +1035,8 @@ declare const ClientIdentity: z.ZodObject<{
|
|
|
1044
1035
|
}>;
|
|
1045
1036
|
isGlobal: z.ZodBoolean;
|
|
1046
1037
|
origin: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1038
|
+
visits: z.ZodOptional<z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodArray<z.ZodInt>>>;
|
|
1039
|
+
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
1047
1040
|
nid: z.ZodOptional<z.ZodObject<{
|
|
1048
1041
|
trn: z.ZodOptional<z.ZodString>;
|
|
1049
1042
|
nin: z.ZodOptional<z.ZodString>;
|
|
@@ -1081,6 +1074,7 @@ declare const MiniAppointmentDetails: z.ZodObject<{
|
|
|
1081
1074
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
1082
1075
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
1083
1076
|
_id: z.ZodUUID;
|
|
1077
|
+
category: z.ZodInt;
|
|
1084
1078
|
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1085
1079
|
tkt: z.ZodReadonly<z.ZodInt>;
|
|
1086
1080
|
reason: z.ZodOptional<z.ZodObject<{
|
|
@@ -1295,6 +1289,7 @@ declare const AppointmentDetails: z.ZodObject<{
|
|
|
1295
1289
|
}, z.core.$strip>>>;
|
|
1296
1290
|
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1297
1291
|
tkt: z.ZodReadonly<z.ZodInt>;
|
|
1292
|
+
category: z.ZodInt;
|
|
1298
1293
|
reason: z.ZodOptional<z.ZodObject<{
|
|
1299
1294
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
1300
1295
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
@@ -1361,7 +1356,6 @@ declare const AppointmentDetails: z.ZodObject<{
|
|
|
1361
1356
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
1362
1357
|
version: z.ZodInt;
|
|
1363
1358
|
_id: z.ZodUUID;
|
|
1364
|
-
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
1365
1359
|
photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1366
1360
|
firstName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1367
1361
|
middleName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -1374,6 +1368,8 @@ declare const AppointmentDetails: z.ZodObject<{
|
|
|
1374
1368
|
}>;
|
|
1375
1369
|
isGlobal: z.ZodBoolean;
|
|
1376
1370
|
origin: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1371
|
+
visits: z.ZodOptional<z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodArray<z.ZodInt>>>;
|
|
1372
|
+
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
1377
1373
|
nid: z.ZodOptional<z.ZodObject<{
|
|
1378
1374
|
trn: z.ZodOptional<z.ZodString>;
|
|
1379
1375
|
nin: z.ZodOptional<z.ZodString>;
|
|
@@ -1473,6 +1469,7 @@ declare const MutableAppointmentDetails: z.ZodObject<{
|
|
|
1473
1469
|
}, z.core.$strip>>>;
|
|
1474
1470
|
src: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1475
1471
|
tkt: z.ZodReadonly<z.ZodInt>;
|
|
1472
|
+
category: z.ZodInt;
|
|
1476
1473
|
reason: z.ZodOptional<z.ZodObject<{
|
|
1477
1474
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
1478
1475
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
@@ -1539,7 +1536,6 @@ declare const MutableAppointmentDetails: z.ZodObject<{
|
|
|
1539
1536
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
1540
1537
|
version: z.ZodInt;
|
|
1541
1538
|
_id: z.ZodUUID;
|
|
1542
|
-
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
1543
1539
|
photoUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1544
1540
|
firstName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1545
1541
|
middleName: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -1552,6 +1548,8 @@ declare const MutableAppointmentDetails: z.ZodObject<{
|
|
|
1552
1548
|
}>;
|
|
1553
1549
|
isGlobal: z.ZodBoolean;
|
|
1554
1550
|
origin: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
1551
|
+
visits: z.ZodOptional<z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodArray<z.ZodInt>>>;
|
|
1552
|
+
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
1555
1553
|
nid: z.ZodOptional<z.ZodObject<{
|
|
1556
1554
|
trn: z.ZodOptional<z.ZodString>;
|
|
1557
1555
|
nin: z.ZodOptional<z.ZodString>;
|
|
@@ -1578,8 +1576,14 @@ type MutableAppointmentDetails = z.infer<typeof MutableAppointmentDetails>;
|
|
|
1578
1576
|
declare const ScheduleAppointmentForm: z.ZodObject<{
|
|
1579
1577
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
1580
1578
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
1581
|
-
|
|
1582
|
-
|
|
1579
|
+
clientId: z.ZodUUID;
|
|
1580
|
+
serviceProviderId: z.ZodUnion<[z.ZodUUID, z.ZodLiteral<"next">]>;
|
|
1581
|
+
category: z.ZodInt;
|
|
1582
|
+
appointmentReason: z.ZodOptional<z.ZodObject<{
|
|
1583
|
+
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
1584
|
+
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
1585
|
+
value: z.ZodString;
|
|
1586
|
+
}, z.core.$strip>>;
|
|
1583
1587
|
charges: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1584
1588
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
1585
1589
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
@@ -1733,6 +1737,7 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
|
|
|
1733
1737
|
}[] | null;
|
|
1734
1738
|
src: string;
|
|
1735
1739
|
tkt: number;
|
|
1740
|
+
category: number;
|
|
1736
1741
|
charges: {
|
|
1737
1742
|
createdAt: number;
|
|
1738
1743
|
uid: string;
|
|
@@ -1779,9 +1784,10 @@ declare function scheduleAppointment(request: RequestParameter): Promise<{
|
|
|
1779
1784
|
firstSchoolName?: string | undefined;
|
|
1780
1785
|
};
|
|
1781
1786
|
lastModified?: number | null | undefined;
|
|
1782
|
-
phoneNumber?: string | undefined;
|
|
1783
1787
|
photoUrl?: string | null | undefined;
|
|
1784
1788
|
email?: string | undefined;
|
|
1789
|
+
visits?: Record<string, number[]> | undefined;
|
|
1790
|
+
phoneNumber?: string | undefined;
|
|
1785
1791
|
nid?: {
|
|
1786
1792
|
trn?: string | undefined;
|
|
1787
1793
|
nin?: string | undefined;
|
package/dist/main.js
CHANGED
|
@@ -191,24 +191,13 @@ var CompanyBilling = z8.object({
|
|
|
191
191
|
discounts: createAdjustments("discount"),
|
|
192
192
|
/** Optionally deductable from bills */
|
|
193
193
|
prepayments: createAdjustments("pre-payment"),
|
|
194
|
-
offeredServices: z8.
|
|
195
|
-
|
|
196
|
-
deployed: z8.boolean(),
|
|
197
|
-
// An object is used instead of an array so that updates to a particular service is accurate
|
|
198
|
-
// and consistent.
|
|
199
|
-
value: z8.record(z8.uuidv4(), PriceTag.omit({ uid: true }))
|
|
200
|
-
}).superRefine((data, ctx) => {
|
|
201
|
-
const services = Object.entries(data.value);
|
|
194
|
+
offeredServices: z8.record(z8.uuidv4(), PriceTag.omit({ uid: true })).superRefine((data, ctx) => {
|
|
195
|
+
const services = Object.entries(data);
|
|
202
196
|
if (services.length > 150) {
|
|
203
197
|
ctx.addIssue(
|
|
204
198
|
"Creating more services than the max allowed services (150) is prohibited."
|
|
205
199
|
);
|
|
206
200
|
}
|
|
207
|
-
if (data.deployed && services.length < 1) {
|
|
208
|
-
ctx.addIssue(
|
|
209
|
-
"You must create at least (1) service in order to deploy your service list."
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
201
|
}),
|
|
213
202
|
version: Version,
|
|
214
203
|
lastModified: Timestamp.nullable()
|
|
@@ -407,6 +396,7 @@ var CompanyPreferences = z12.object({
|
|
|
407
396
|
* @property LOR (Least Outstanding Requests): Distribute based on availability.
|
|
408
397
|
*/
|
|
409
398
|
apptDistAlg: appointmentDistAlgs.default("RR"),
|
|
399
|
+
servicesDeployed: z12.boolean(),
|
|
410
400
|
version: Version,
|
|
411
401
|
lastModified: Timestamp.nullable()
|
|
412
402
|
}).refine(
|
|
@@ -460,7 +450,7 @@ var UserDetails = z13.object({
|
|
|
460
450
|
}).omit({ uid: true });
|
|
461
451
|
|
|
462
452
|
// src/schemas/profiles/Client.ts
|
|
463
|
-
import { Address as Address2 } from "@wavy/util";
|
|
453
|
+
import { Address as Address2, PhoneNumber as PhoneNumber2 } from "@wavy/util";
|
|
464
454
|
var Name = z14.string().trim().min(2).max(MAX_NAME_LENGTH).transform((d) => d.replace(/-+/g, "-").replace(/'+/g, "'")).superRefine((data, ctx) => {
|
|
465
455
|
const invalidCharIdx = data.search(/[^a-z'-]/i);
|
|
466
456
|
if (invalidCharIdx >= 0) {
|
|
@@ -485,6 +475,8 @@ var ClientIdentity = UserDetails.pick({
|
|
|
485
475
|
sex: genders,
|
|
486
476
|
isGlobal: z14.boolean(),
|
|
487
477
|
origin: CompanyIdentity.shape._id,
|
|
478
|
+
visits: z14.record(CompanyIdentity.shape._id, z14.array(Timestamp).min(1)).optional(),
|
|
479
|
+
phoneNumber: PhoneNumber2.optional(),
|
|
488
480
|
// aka. National id
|
|
489
481
|
nid: z14.object({
|
|
490
482
|
trn: Trn,
|
|
@@ -499,7 +491,6 @@ var ClientIdentity = UserDetails.pick({
|
|
|
499
491
|
motherMiddleName: Name,
|
|
500
492
|
oldestSiblingMiddleName: Name,
|
|
501
493
|
firstSchoolName: z14.string().trim().min(3).max(60)
|
|
502
|
-
// nickname: z.string().trim().min(1).max(40),
|
|
503
494
|
}).partial().refine(
|
|
504
495
|
(data) => Object.keys(data).length > 0,
|
|
505
496
|
"At least (1) attribute must be defined."
|
|
@@ -816,6 +807,9 @@ var TimelineActivity = z21.object({
|
|
|
816
807
|
var MiniAppointmentDetails = z21.object({
|
|
817
808
|
/** A random uid that identifies the document. */
|
|
818
809
|
_id: z21.uuidv4(),
|
|
810
|
+
// This helps to identify the urgency of the appointment
|
|
811
|
+
// 3
|
|
812
|
+
category: z21.int().min(1).max(3),
|
|
819
813
|
/** The company's uid */
|
|
820
814
|
src: CompanyState.shape._id,
|
|
821
815
|
/** The ticket number */
|
|
@@ -900,9 +894,10 @@ var MutableAppointmentDetails = AppointmentDetails.safeExtend(
|
|
|
900
894
|
}).shape
|
|
901
895
|
);
|
|
902
896
|
var ScheduleAppointmentForm = z21.object({
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
897
|
+
clientId: ClientIdentity.shape._id,
|
|
898
|
+
serviceProviderId: CompanyUser.shape._id.or(z21.literal("next")),
|
|
899
|
+
category: AppointmentDetails.shape.category,
|
|
900
|
+
appointmentReason: AppointmentDetails.shape.reason,
|
|
906
901
|
charges: AppointmentDetails.shape.charges.optional(),
|
|
907
902
|
prepayments: AppointmentDetails.shape.prepayments.optional(),
|
|
908
903
|
payments: AppointmentDetails.shape.payments.optional(),
|
|
@@ -910,7 +905,7 @@ var ScheduleAppointmentForm = z21.object({
|
|
|
910
905
|
});
|
|
911
906
|
|
|
912
907
|
// src/functions/scheduleAppointment.ts
|
|
913
|
-
import { findChanges, omit } from "@wavy/fn";
|
|
908
|
+
import { findChanges, omit, TODO } from "@wavy/fn";
|
|
914
909
|
import { v4 } from "uuid";
|
|
915
910
|
|
|
916
911
|
// src/functions/findAvailableStaff.ts
|
|
@@ -952,6 +947,7 @@ function findNextAvailableStaff(userUids, algorithm, staff) {
|
|
|
952
947
|
|
|
953
948
|
// src/functions/scheduleAppointment.ts
|
|
954
949
|
async function scheduleAppointment(request) {
|
|
950
|
+
TODO("Revise this fn (some things have changed in the form etc.)");
|
|
955
951
|
request.form = ScheduleAppointmentForm.parse(request.form);
|
|
956
952
|
request.sender = UserDetails.parse(request.sender);
|
|
957
953
|
request.preferences = CompanyPreferences.omit({
|
|
@@ -976,14 +972,16 @@ async function scheduleAppointment(request) {
|
|
|
976
972
|
if (availableDoctors.length < 1) {
|
|
977
973
|
throw new Error("Insufficient staff available.");
|
|
978
974
|
}
|
|
979
|
-
if (request.form.
|
|
980
|
-
selectedDoctor = request.form.
|
|
981
|
-
} else if (request.form.
|
|
975
|
+
if (request.form.serviceProviderId && availableDoctors.includes(request.form.serviceProviderId)) {
|
|
976
|
+
selectedDoctor = request.form.serviceProviderId;
|
|
977
|
+
} else if (request.form.serviceProviderId && staffDetailsCopy.members[request.form.serviceProviderId]?.roles?.includes?.(
|
|
978
|
+
"doc"
|
|
979
|
+
)) {
|
|
982
980
|
throw new Error("Unavailable doctor selected.");
|
|
983
|
-
} else if (request.form.
|
|
981
|
+
} else if (request.form.serviceProviderId) {
|
|
984
982
|
throw new Error("Invalid doctor selected.");
|
|
985
983
|
}
|
|
986
|
-
if (request.form.
|
|
984
|
+
if (request.form.serviceProviderId === null || request.form.serviceProviderId === void 0) {
|
|
987
985
|
selectedDoctor = findNextAvailableStaff(
|
|
988
986
|
availableDoctors,
|
|
989
987
|
request.preferences.apptDistAlg,
|
|
@@ -1004,7 +1002,7 @@ async function scheduleAppointment(request) {
|
|
|
1004
1002
|
if (request.preferences.serviceSelector === "scheduler" && (!request.form.charges || request.form.charges.length < 1)) {
|
|
1005
1003
|
throw new Error("Insufficient services selected.");
|
|
1006
1004
|
} else if (request.preferences.serviceSelector === "scheduler" && request.billing.offeredServices.deployed && request.form.charges.find(
|
|
1007
|
-
(charge) => !!Object.values(request.billing.offeredServices
|
|
1005
|
+
(charge) => !!Object.values(request.billing.offeredServices).find(
|
|
1008
1006
|
(createdCharge) => findChanges(charge, createdCharge).length > 0
|
|
1009
1007
|
)
|
|
1010
1008
|
)) {
|
|
@@ -1047,6 +1045,7 @@ async function scheduleAppointment(request) {
|
|
|
1047
1045
|
_id: v4(),
|
|
1048
1046
|
src: stateCopy._id,
|
|
1049
1047
|
tkt: request.state.tktNoCounter,
|
|
1048
|
+
category: request.form.category,
|
|
1050
1049
|
discounts: Object.values(request.billing.discounts || {}).filter(
|
|
1051
1050
|
(disc) => !disc.isOptional
|
|
1052
1051
|
),
|
|
@@ -1056,7 +1055,7 @@ async function scheduleAppointment(request) {
|
|
|
1056
1055
|
payments: request.preferences.enforcePaidAppointments ? request.form.payments : null,
|
|
1057
1056
|
prepayments: request.preferences.enforcePaidAppointments ? request.form.prepayments || [] : null,
|
|
1058
1057
|
charges: request.preferences.serviceSelector === "scheduler" ? request.form.charges : [],
|
|
1059
|
-
client: await request.findClient(request.form.
|
|
1058
|
+
client: await request.findClient(request.form.clientId),
|
|
1060
1059
|
_hash: "aa.aa.aa",
|
|
1061
1060
|
lastModified: null,
|
|
1062
1061
|
timeline: {
|