@bizmap/sdk 0.0.59 → 0.0.60
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 +34 -34
- package/dist/main.js +44 -45
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -26,11 +26,11 @@ declare const healthcareProviderRoles: z.ZodEnum<{
|
|
|
26
26
|
physAsst: "physAsst";
|
|
27
27
|
}>;
|
|
28
28
|
type HealthcareProviderRole = z.infer<typeof healthcareProviderRoles>;
|
|
29
|
-
declare const
|
|
29
|
+
declare const appointmentDistAlgs: z.ZodEnum<{
|
|
30
30
|
RR: "RR";
|
|
31
31
|
LOR: "LOR";
|
|
32
32
|
}>;
|
|
33
|
-
type
|
|
33
|
+
type AppointmentDistAlg = z.infer<typeof appointmentDistAlgs>;
|
|
34
34
|
declare const companyServiceSelectors: z.ZodEnum<{
|
|
35
35
|
scheduler: "scheduler";
|
|
36
36
|
doctor: "doctor";
|
|
@@ -145,8 +145,8 @@ declare const CompanyDetails: z.ZodObject<{
|
|
|
145
145
|
scheduler: "scheduler";
|
|
146
146
|
doctor: "doctor";
|
|
147
147
|
}>;
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
enforcePaidAppointments: z.ZodBoolean;
|
|
149
|
+
apptDistAlg: z.ZodDefault<z.ZodEnum<{
|
|
150
150
|
RR: "RR";
|
|
151
151
|
LOR: "LOR";
|
|
152
152
|
}>>;
|
|
@@ -204,7 +204,7 @@ declare const CompanyDetails: z.ZodObject<{
|
|
|
204
204
|
percentage: z.ZodNumber;
|
|
205
205
|
isOptional: z.ZodBoolean;
|
|
206
206
|
}, z.core.$strip>>;
|
|
207
|
-
|
|
207
|
+
offeredServices: z.ZodObject<{
|
|
208
208
|
deployed: z.ZodBoolean;
|
|
209
209
|
value: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
210
210
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
@@ -239,7 +239,7 @@ declare const CompanyDetails: z.ZodObject<{
|
|
|
239
239
|
active: "active";
|
|
240
240
|
inactive: "inactive";
|
|
241
241
|
}>;
|
|
242
|
-
|
|
242
|
+
appointments: z.ZodRecord<z.ZodLiteral<"ongoing" | "completed">, z.ZodInt>;
|
|
243
243
|
lastActive: z.ZodNullable<z.ZodInt>;
|
|
244
244
|
isAvailableLastModified: z.ZodNullable<z.ZodInt>;
|
|
245
245
|
isBusyLastModified: z.ZodNullable<z.ZodInt>;
|
|
@@ -301,8 +301,8 @@ declare const MutableCompanyDetails: z.ZodObject<{
|
|
|
301
301
|
scheduler: "scheduler";
|
|
302
302
|
doctor: "doctor";
|
|
303
303
|
}>>;
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
enforcePaidAppointments: z.ZodOptional<z.ZodBoolean>;
|
|
305
|
+
apptDistAlg: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
306
306
|
RR: "RR";
|
|
307
307
|
LOR: "LOR";
|
|
308
308
|
}>>>;
|
|
@@ -359,7 +359,7 @@ declare const MutableCompanyDetails: z.ZodObject<{
|
|
|
359
359
|
percentage: z.ZodNumber;
|
|
360
360
|
isOptional: z.ZodBoolean;
|
|
361
361
|
}, z.core.$strip>>>;
|
|
362
|
-
|
|
362
|
+
offeredServices: z.ZodOptional<z.ZodObject<{
|
|
363
363
|
deployed: z.ZodBoolean;
|
|
364
364
|
value: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
365
365
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
@@ -452,7 +452,7 @@ declare const CompanyBilling: z.ZodObject<{
|
|
|
452
452
|
percentage: z.ZodNumber;
|
|
453
453
|
isOptional: z.ZodBoolean;
|
|
454
454
|
}, z.core.$strip>>;
|
|
455
|
-
|
|
455
|
+
offeredServices: z.ZodObject<{
|
|
456
456
|
deployed: z.ZodBoolean;
|
|
457
457
|
value: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
458
458
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
@@ -523,7 +523,7 @@ declare const MutableCompanyBilling: z.ZodObject<{
|
|
|
523
523
|
percentage: z.ZodNumber;
|
|
524
524
|
isOptional: z.ZodBoolean;
|
|
525
525
|
}, z.core.$strip>>;
|
|
526
|
-
|
|
526
|
+
offeredServices: z.ZodObject<{
|
|
527
527
|
deployed: z.ZodBoolean;
|
|
528
528
|
value: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
529
529
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
@@ -612,8 +612,8 @@ declare const CompanyPreferences: z.ZodObject<{
|
|
|
612
612
|
scheduler: "scheduler";
|
|
613
613
|
doctor: "doctor";
|
|
614
614
|
}>;
|
|
615
|
-
|
|
616
|
-
|
|
615
|
+
enforcePaidAppointments: z.ZodBoolean;
|
|
616
|
+
apptDistAlg: z.ZodDefault<z.ZodEnum<{
|
|
617
617
|
RR: "RR";
|
|
618
618
|
LOR: "LOR";
|
|
619
619
|
}>>;
|
|
@@ -625,8 +625,8 @@ declare const MutableCompanyPreferences: z.ZodObject<{
|
|
|
625
625
|
scheduler: "scheduler";
|
|
626
626
|
doctor: "doctor";
|
|
627
627
|
}>;
|
|
628
|
-
|
|
629
|
-
|
|
628
|
+
enforcePaidAppointments: z.ZodBoolean;
|
|
629
|
+
apptDistAlg: z.ZodDefault<z.ZodEnum<{
|
|
630
630
|
RR: "RR";
|
|
631
631
|
LOR: "LOR";
|
|
632
632
|
}>>;
|
|
@@ -651,7 +651,7 @@ declare const CompanyStaff: z.ZodPipe<z.ZodObject<{
|
|
|
651
651
|
active: "active";
|
|
652
652
|
inactive: "inactive";
|
|
653
653
|
}>;
|
|
654
|
-
|
|
654
|
+
appointments: z.ZodRecord<z.ZodLiteral<"ongoing" | "completed">, z.ZodInt>;
|
|
655
655
|
lastActive: z.ZodNullable<z.ZodInt>;
|
|
656
656
|
isAvailableLastModified: z.ZodNullable<z.ZodInt>;
|
|
657
657
|
isBusyLastModified: z.ZodNullable<z.ZodInt>;
|
|
@@ -694,7 +694,7 @@ declare const CompanyStaff: z.ZodPipe<z.ZodObject<{
|
|
|
694
694
|
isAvailable: boolean;
|
|
695
695
|
isBusy: boolean;
|
|
696
696
|
status: "inviteSent" | "active" | "inactive";
|
|
697
|
-
|
|
697
|
+
appointments: Record<"ongoing" | "completed", number>;
|
|
698
698
|
lastActive: number | null;
|
|
699
699
|
isAvailableLastModified: number | null;
|
|
700
700
|
isBusyLastModified: number | null;
|
|
@@ -728,7 +728,7 @@ declare const CompanyStaff: z.ZodPipe<z.ZodObject<{
|
|
|
728
728
|
isAvailable: boolean;
|
|
729
729
|
isBusy: boolean;
|
|
730
730
|
status: "inviteSent" | "active" | "inactive";
|
|
731
|
-
|
|
731
|
+
appointments: Record<"ongoing" | "completed", number>;
|
|
732
732
|
lastActive: number | null;
|
|
733
733
|
isAvailableLastModified: number | null;
|
|
734
734
|
isBusyLastModified: number | null;
|
|
@@ -796,7 +796,7 @@ declare const CompanyUser: z.ZodObject<{
|
|
|
796
796
|
active: "active";
|
|
797
797
|
inactive: "inactive";
|
|
798
798
|
}>;
|
|
799
|
-
|
|
799
|
+
appointments: z.ZodRecord<z.ZodLiteral<"ongoing" | "completed">, z.ZodInt>;
|
|
800
800
|
lastActive: z.ZodNullable<z.ZodInt>;
|
|
801
801
|
isAvailableLastModified: z.ZodNullable<z.ZodInt>;
|
|
802
802
|
isBusyLastModified: z.ZodNullable<z.ZodInt>;
|
|
@@ -1038,7 +1038,7 @@ declare const Reason: z.ZodObject<{
|
|
|
1038
1038
|
lastModified: z.ZodInt;
|
|
1039
1039
|
}, z.core.$strip>;
|
|
1040
1040
|
|
|
1041
|
-
declare const
|
|
1041
|
+
declare const MiniAppointmentDetails: z.ZodObject<{
|
|
1042
1042
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
1043
1043
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
1044
1044
|
_id: z.ZodUUID;
|
|
@@ -1187,8 +1187,8 @@ declare const MiniServiceDetails: z.ZodObject<{
|
|
|
1187
1187
|
}, z.core.$strip>>;
|
|
1188
1188
|
}, z.core.$strip>;
|
|
1189
1189
|
}, z.core.$strip>;
|
|
1190
|
-
type
|
|
1191
|
-
declare const
|
|
1190
|
+
type MiniAppointmentDetails = z.infer<typeof MiniAppointmentDetails>;
|
|
1191
|
+
declare const AppointmentDetails: z.ZodObject<{
|
|
1192
1192
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
1193
1193
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
1194
1194
|
additionalFees: z.ZodReadonly<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
@@ -1357,8 +1357,8 @@ declare const ServiceDetails: z.ZodObject<{
|
|
|
1357
1357
|
activated: z.ZodBoolean;
|
|
1358
1358
|
}, z.core.$strip>;
|
|
1359
1359
|
}, z.core.$strip>;
|
|
1360
|
-
type
|
|
1361
|
-
declare const
|
|
1360
|
+
type AppointmentDetails = z.infer<typeof AppointmentDetails>;
|
|
1361
|
+
declare const MutableAppointmentDetails: z.ZodObject<{
|
|
1362
1362
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
1363
1363
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
1364
1364
|
additionalFees: z.ZodReadonly<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
@@ -1528,8 +1528,8 @@ declare const MutableServiceDetails: z.ZodObject<{
|
|
|
1528
1528
|
}, z.core.$strip>;
|
|
1529
1529
|
_hash: z.ZodString;
|
|
1530
1530
|
}, z.core.$strip>;
|
|
1531
|
-
type
|
|
1532
|
-
declare const
|
|
1531
|
+
type MutableAppointmentDetails = z.infer<typeof MutableAppointmentDetails>;
|
|
1532
|
+
declare const ScheduleAppointmentForm: z.ZodObject<{
|
|
1533
1533
|
createdAt: z.ZodReadonly<z.ZodInt>;
|
|
1534
1534
|
lastModified: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
1535
1535
|
clientUid: z.ZodUUID;
|
|
@@ -1575,10 +1575,10 @@ declare const CreateServiceForm: z.ZodObject<{
|
|
|
1575
1575
|
amount: z.ZodNumber;
|
|
1576
1576
|
}, z.core.$strip>>>>>;
|
|
1577
1577
|
}, z.core.$strip>;
|
|
1578
|
-
type
|
|
1578
|
+
type ScheduleAppointmentForm = z.infer<typeof ScheduleAppointmentForm>;
|
|
1579
1579
|
|
|
1580
|
-
declare function
|
|
1581
|
-
form:
|
|
1580
|
+
declare function scheduleAppointment(request: {
|
|
1581
|
+
form: ScheduleAppointmentForm;
|
|
1582
1582
|
sender: UserDetails;
|
|
1583
1583
|
billing: SafeOmit<CompanyBilling, "uid" | "prepayments" | "lastModified">;
|
|
1584
1584
|
preferences: SafeOmit<CompanyPreferences, "uid" | "lastModified">;
|
|
@@ -1586,7 +1586,7 @@ declare function createCompanyService(request: {
|
|
|
1586
1586
|
staff: CompanyStaff;
|
|
1587
1587
|
cost: number;
|
|
1588
1588
|
findClient: (uid: string) => Promise<ClientIdentity>;
|
|
1589
|
-
|
|
1589
|
+
createHash: (appointment: SafeOmit<MutableAppointmentDetails, "_hash">) => string;
|
|
1590
1590
|
options?: Partial<{
|
|
1591
1591
|
ignoreBalanceCheck: boolean;
|
|
1592
1592
|
}>;
|
|
@@ -1620,7 +1620,7 @@ declare function createCompanyService(request: {
|
|
|
1620
1620
|
isAvailable: boolean;
|
|
1621
1621
|
isBusy: boolean;
|
|
1622
1622
|
status: "inviteSent" | "active" | "inactive";
|
|
1623
|
-
|
|
1623
|
+
appointments: Record<"ongoing" | "completed", number>;
|
|
1624
1624
|
lastActive: number | null;
|
|
1625
1625
|
isAvailableLastModified: number | null;
|
|
1626
1626
|
isBusyLastModified: number | null;
|
|
@@ -1782,7 +1782,7 @@ declare function createCompanyService(request: {
|
|
|
1782
1782
|
|
|
1783
1783
|
declare function findAvailableStaff(role: CompanyUserRole, staff: CompanyStaff): string[];
|
|
1784
1784
|
|
|
1785
|
-
declare function findNextAvailableStaff(userUids: string[], algorithm: CompanyPreferences["
|
|
1785
|
+
declare function findNextAvailableStaff(userUids: string[], algorithm: CompanyPreferences["apptDistAlg"], staff: CompanyStaff): string | null;
|
|
1786
1786
|
|
|
1787
1787
|
/**@returns an array of the users that have conflicting roles or are incompatible with the other partners, or null if none was found. */
|
|
1788
1788
|
declare const findConflictingPartners: (...partners: CompanyUser[]) => {
|
|
@@ -1791,7 +1791,7 @@ declare const findConflictingPartners: (...partners: CompanyUser[]) => {
|
|
|
1791
1791
|
isAvailable: boolean;
|
|
1792
1792
|
isBusy: boolean;
|
|
1793
1793
|
status: "inviteSent" | "active" | "inactive";
|
|
1794
|
-
|
|
1794
|
+
appointments: Record<"ongoing" | "completed", number>;
|
|
1795
1795
|
lastActive: number | null;
|
|
1796
1796
|
isAvailableLastModified: number | null;
|
|
1797
1797
|
isBusyLastModified: number | null;
|
|
@@ -1803,4 +1803,4 @@ declare const findConflictingPartners: (...partners: CompanyUser[]) => {
|
|
|
1803
1803
|
/**@returns the roles that are compatible with the selected role. */
|
|
1804
1804
|
declare const getCompatibleRoles: (role: CompanyUserRole) => CompanyUserRole[];
|
|
1805
1805
|
|
|
1806
|
-
export { ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole,
|
|
1806
|
+
export { AppointmentDetails, type AppointmentDistAlg, ClientIdentity, CompanyBilling, CompanyDetails, CompanyIdentity, CompanyInviteList, CompanyNotifications, type CompanyPartnerRole, CompanyPreferences, type CompanyServiceSelector, CompanyStaff, CompanyState, CompanyUser, type CompanyUserRole, CreditCurrency, type EmployeeRole, type HealthcareProviderRole, InviteResponse, InvoiceNo, MedicalDetails, Medicine, MiniAppointmentDetails, MutableAppointmentDetails, MutableCompanyBilling, MutableCompanyDetails, MutableCompanyIdentity, MutableCompanyPreferences, Notification, type PaymentMethod, PriceAdjustment, PriceTag, Reason, Receipts, ScheduleAppointmentForm, StandardTime, TicketNo, type Tier, TierList, TimeLog, Timestamp, UserDetails, Vitals, appointmentDistAlgs, companyPartnerRoles, companyServiceSelectors, companyUserRoles, employeeRoles, findAvailableStaff, findConflictingPartners, findNextAvailableStaff, getCompatibleRoles, healthcareProviderRoles, paymentMethods, scheduleAppointment, serviceProviders, tiers, vitalKeys };
|
package/dist/main.js
CHANGED
|
@@ -16,7 +16,7 @@ var healthcareProviderRoles = companyUserRoles.extract([
|
|
|
16
16
|
"physAsst",
|
|
17
17
|
"doc"
|
|
18
18
|
]);
|
|
19
|
-
var
|
|
19
|
+
var appointmentDistAlgs = z.enum(["RR", "LOR"]);
|
|
20
20
|
var companyServiceSelectors = z.enum(["scheduler", "doctor"]);
|
|
21
21
|
|
|
22
22
|
// src/enums/Global.ts
|
|
@@ -34,7 +34,7 @@ var vitalKeys = z3.enum([
|
|
|
34
34
|
"bodyTemp"
|
|
35
35
|
]);
|
|
36
36
|
|
|
37
|
-
// src/enums/
|
|
37
|
+
// src/enums/Appointments.ts
|
|
38
38
|
import * as z4 from "zod";
|
|
39
39
|
var serviceProviders = z4.enum([
|
|
40
40
|
"scheduler",
|
|
@@ -148,7 +148,7 @@ var CompanyBilling = z8.object({
|
|
|
148
148
|
discounts: createAdjustments("discount"),
|
|
149
149
|
/** Optionally deductable from bills */
|
|
150
150
|
prepayments: createAdjustments("pre-payment"),
|
|
151
|
-
|
|
151
|
+
offeredServices: z8.object({
|
|
152
152
|
/** Forces service selectors to use the list of service(s) that you've created. */
|
|
153
153
|
deployed: z8.boolean(),
|
|
154
154
|
value: z8.record(z8.string(), PriceTag.omit({ uid: true }))
|
|
@@ -298,15 +298,15 @@ var CompanyPreferences = z12.object({
|
|
|
298
298
|
* @note
|
|
299
299
|
* - only allowed when `serviceSelector === "scheduler"`
|
|
300
300
|
* */
|
|
301
|
-
|
|
301
|
+
enforcePaidAppointments: z12.boolean(),
|
|
302
302
|
/**
|
|
303
303
|
* @property RR (Round Robin): Even distribution.
|
|
304
304
|
* @property LOR (Least Outstanding Requests): Distribute based on availability.
|
|
305
305
|
*/
|
|
306
|
-
|
|
306
|
+
apptDistAlg: appointmentDistAlgs.default("RR"),
|
|
307
307
|
lastModified: Timestamp.nullable()
|
|
308
308
|
}).refine(
|
|
309
|
-
(data) => !data.
|
|
309
|
+
(data) => !data.enforcePaidAppointments || data.enforcePaidAppointments && data.serviceSelector === "scheduler",
|
|
310
310
|
'Enforcing paid appointments is only allowed when the service selector is the "scheduler".'
|
|
311
311
|
);
|
|
312
312
|
var MutableCompanyPreferences = CompanyPreferences.omit({
|
|
@@ -394,7 +394,7 @@ var CompanyUser = z14.object({
|
|
|
394
394
|
isAvailable: z14.boolean(),
|
|
395
395
|
isBusy: z14.boolean(),
|
|
396
396
|
status: z14.enum(["inviteSent", "active", "inactive"]),
|
|
397
|
-
|
|
397
|
+
appointments: z14.record(z14.literal(["ongoing", "completed"]), z14.int().min(0)),
|
|
398
398
|
lastActive: Timestamp.nullable(),
|
|
399
399
|
isAvailableLastModified: Timestamp.nullable(),
|
|
400
400
|
isBusyLastModified: Timestamp.nullable()
|
|
@@ -543,10 +543,10 @@ var CompanyInviteList = z17.record(
|
|
|
543
543
|
"Insufficient amount of members invited."
|
|
544
544
|
);
|
|
545
545
|
|
|
546
|
-
// src/schemas/Client.ts
|
|
546
|
+
// src/schemas/appointment/components/Client.ts
|
|
547
547
|
var ClientIdentity = UserDetails.omit({ notifications: true });
|
|
548
548
|
|
|
549
|
-
// src/schemas/Medical.ts
|
|
549
|
+
// src/schemas/appointment/components/payload/Medical.ts
|
|
550
550
|
import * as z18 from "zod";
|
|
551
551
|
var Vitals = z18.record(
|
|
552
552
|
vitalKeys,
|
|
@@ -581,13 +581,13 @@ var MedicalDetails = z18.object({
|
|
|
581
581
|
).optional()
|
|
582
582
|
});
|
|
583
583
|
|
|
584
|
-
// src/schemas/
|
|
584
|
+
// src/schemas/appointment/Appointment.ts
|
|
585
585
|
import * as z19 from "zod";
|
|
586
586
|
var TimelineActivity = z19.object({
|
|
587
587
|
postedAt: Timestamp.nullish(),
|
|
588
588
|
userUid: CompanyUser.shape.uid.nonoptional()
|
|
589
589
|
});
|
|
590
|
-
var
|
|
590
|
+
var MiniAppointmentDetails = z19.object({
|
|
591
591
|
/** A random uid that identifies the document. */
|
|
592
592
|
_id: z19.uuidv4(),
|
|
593
593
|
/** The company's uid */
|
|
@@ -647,10 +647,10 @@ var MiniServiceDetails = z19.object({
|
|
|
647
647
|
}),
|
|
648
648
|
...TimeLog.shape
|
|
649
649
|
});
|
|
650
|
-
var
|
|
650
|
+
var AppointmentDetails = MiniAppointmentDetails.omit({
|
|
651
651
|
clientUid: true
|
|
652
652
|
}).extend(z19.object({ client: ClientIdentity }).shape);
|
|
653
|
-
var
|
|
653
|
+
var MutableAppointmentDetails = AppointmentDetails.safeExtend(
|
|
654
654
|
z19.object({
|
|
655
655
|
/**
|
|
656
656
|
* @description An encrypted copy of the last state of the service.
|
|
@@ -659,18 +659,18 @@ var MutableServiceDetails = ServiceDetails.safeExtend(
|
|
|
659
659
|
_hash: z19.string()
|
|
660
660
|
}).shape
|
|
661
661
|
);
|
|
662
|
-
var
|
|
662
|
+
var ScheduleAppointmentForm = z19.object({
|
|
663
663
|
clientUid: ClientIdentity.shape.uid,
|
|
664
664
|
/** A nullish value === next_available */
|
|
665
665
|
serviceProviderUid: CompanyUser.shape.uid.nullish(),
|
|
666
|
-
charges:
|
|
667
|
-
prepayments:
|
|
668
|
-
payments:
|
|
666
|
+
charges: AppointmentDetails.shape.charges.optional(),
|
|
667
|
+
prepayments: AppointmentDetails.shape.prepayments.optional(),
|
|
668
|
+
payments: AppointmentDetails.shape.payments.optional(),
|
|
669
669
|
...TimeLog.shape
|
|
670
670
|
});
|
|
671
671
|
|
|
672
|
-
// src/functions/
|
|
673
|
-
import { findChanges, omit
|
|
672
|
+
// src/functions/scheduleAppointment.ts
|
|
673
|
+
import { findChanges, omit } from "@wavy/fn";
|
|
674
674
|
import { v4 } from "uuid";
|
|
675
675
|
|
|
676
676
|
// src/functions/findAvailableStaff.ts
|
|
@@ -690,14 +690,14 @@ function findNextAvailableStaff(userUids, algorithm, staff) {
|
|
|
690
690
|
switch (algorithm) {
|
|
691
691
|
case "RR": {
|
|
692
692
|
nextAvailable = userUids.find(
|
|
693
|
-
(uid) => staff.members[uid].
|
|
693
|
+
(uid) => staff.members[uid].appointments.ongoing < staff.members[userUids[0]].appointments.ongoing
|
|
694
694
|
) || userUids[0];
|
|
695
695
|
break;
|
|
696
696
|
}
|
|
697
697
|
case "LOR": {
|
|
698
698
|
for (const uid of userUids) {
|
|
699
699
|
const user = staff.members[uid];
|
|
700
|
-
if (!nextAvailable || user.
|
|
700
|
+
if (!nextAvailable || user.appointments.ongoing < staff.members[nextAvailable].appointments.ongoing) {
|
|
701
701
|
nextAvailable = uid;
|
|
702
702
|
}
|
|
703
703
|
}
|
|
@@ -709,9 +709,9 @@ function findNextAvailableStaff(userUids, algorithm, staff) {
|
|
|
709
709
|
return nextAvailable;
|
|
710
710
|
}
|
|
711
711
|
|
|
712
|
-
// src/functions/
|
|
713
|
-
async function
|
|
714
|
-
request.form =
|
|
712
|
+
// src/functions/scheduleAppointment.ts
|
|
713
|
+
async function scheduleAppointment(request) {
|
|
714
|
+
request.form = ScheduleAppointmentForm.parse(request.form);
|
|
715
715
|
request.sender = UserDetails.parse(request.sender);
|
|
716
716
|
request.preferences = CompanyPreferences.omit({
|
|
717
717
|
uid: true,
|
|
@@ -745,7 +745,7 @@ async function createCompanyService(request) {
|
|
|
745
745
|
if (request.form.serviceProviderUid === null || request.form.serviceProviderUid === void 0) {
|
|
746
746
|
selectedDoctor = findNextAvailableStaff(
|
|
747
747
|
availableDoctors,
|
|
748
|
-
request.preferences.
|
|
748
|
+
request.preferences.apptDistAlg,
|
|
749
749
|
staffDetailsCopy
|
|
750
750
|
);
|
|
751
751
|
}
|
|
@@ -762,16 +762,16 @@ async function createCompanyService(request) {
|
|
|
762
762
|
}
|
|
763
763
|
if (request.preferences.serviceSelector === "scheduler" && (!request.form.charges || request.form.charges.length < 1)) {
|
|
764
764
|
throw new Error("Insufficient services selected.");
|
|
765
|
-
} else if (request.preferences.serviceSelector === "scheduler" && request.billing.
|
|
766
|
-
(
|
|
767
|
-
(
|
|
765
|
+
} else if (request.preferences.serviceSelector === "scheduler" && request.billing.offeredServices.deployed && request.form.charges.find(
|
|
766
|
+
(charge) => !!Object.values(request.billing.offeredServices.value).find(
|
|
767
|
+
(createdCharge) => findChanges(charge, createdCharge).length > 0
|
|
768
768
|
)
|
|
769
769
|
)) {
|
|
770
770
|
throw new Error("Invalid service(s) selected.");
|
|
771
771
|
}
|
|
772
|
-
if (request.preferences.
|
|
772
|
+
if (request.preferences.enforcePaidAppointments && (!request.form.payments || request.form.payments.length < 1)) {
|
|
773
773
|
throw new Error("Insufficient payment transactions recorded.");
|
|
774
|
-
} else if (request.preferences.
|
|
774
|
+
} else if (request.preferences.enforcePaidAppointments) {
|
|
775
775
|
const maxIterations = Math.max(
|
|
776
776
|
request.form.charges.length,
|
|
777
777
|
request.form.payments.length
|
|
@@ -797,12 +797,12 @@ async function createCompanyService(request) {
|
|
|
797
797
|
stateCopy.credits.current -= request.cost;
|
|
798
798
|
stateCopy.credits.lastModified = today;
|
|
799
799
|
stateCopy.lastModified = today;
|
|
800
|
-
staffDetailsCopy.members[selectedDoctor].
|
|
800
|
+
staffDetailsCopy.members[selectedDoctor].appointments.ongoing++;
|
|
801
801
|
if (selectedPhysAsst) {
|
|
802
|
-
staffDetailsCopy.members[selectedPhysAsst].
|
|
802
|
+
staffDetailsCopy.members[selectedPhysAsst].appointments.ongoing++;
|
|
803
803
|
}
|
|
804
804
|
staffDetailsCopy.lastModified = today;
|
|
805
|
-
const
|
|
805
|
+
const appointment = {
|
|
806
806
|
_id: v4(),
|
|
807
807
|
src: stateCopy.uid,
|
|
808
808
|
tkt: request.state.tktNoCounter,
|
|
@@ -812,8 +812,8 @@ async function createCompanyService(request) {
|
|
|
812
812
|
additionalFees: Object.values(request.billing.additionalFees || {}).filter(
|
|
813
813
|
(fee) => !fee.isOptional
|
|
814
814
|
),
|
|
815
|
-
payments: request.preferences.
|
|
816
|
-
prepayments: request.preferences.
|
|
815
|
+
payments: request.preferences.enforcePaidAppointments ? request.form.payments : null,
|
|
816
|
+
prepayments: request.preferences.enforcePaidAppointments ? request.form.prepayments || [] : null,
|
|
817
817
|
charges: request.preferences.serviceSelector === "scheduler" ? request.form.charges : [],
|
|
818
818
|
client: await request.findClient(request.form.clientUid),
|
|
819
819
|
_hash: "aa.aa.aa",
|
|
@@ -823,23 +823,23 @@ async function createCompanyService(request) {
|
|
|
823
823
|
doctor: { userUid: selectedDoctor },
|
|
824
824
|
physAsst: selectedPhysAsst ? { userUid: selectedPhysAsst } : "none",
|
|
825
825
|
get cashier() {
|
|
826
|
-
if (request.preferences.
|
|
826
|
+
if (request.preferences.enforcePaidAppointments) return this.scheduler;
|
|
827
827
|
return null;
|
|
828
828
|
}
|
|
829
829
|
},
|
|
830
830
|
createdAt: today
|
|
831
831
|
};
|
|
832
|
-
|
|
833
|
-
service._hash = request.encryptCopy(omit(service, ["_hash"]));
|
|
832
|
+
appointment._hash = request.createHash(omit(appointment, ["_hash"]));
|
|
834
833
|
return {
|
|
835
834
|
updates: {
|
|
836
835
|
state: stateCopy,
|
|
837
836
|
staffDetails: staffDetailsCopy
|
|
838
837
|
},
|
|
839
|
-
appointment:
|
|
838
|
+
appointment: MutableAppointmentDetails.parse(appointment)
|
|
840
839
|
};
|
|
841
840
|
}
|
|
842
841
|
export {
|
|
842
|
+
AppointmentDetails,
|
|
843
843
|
ClientIdentity,
|
|
844
844
|
CompanyBilling,
|
|
845
845
|
CompanyDetails,
|
|
@@ -850,24 +850,23 @@ export {
|
|
|
850
850
|
CompanyStaff,
|
|
851
851
|
CompanyState,
|
|
852
852
|
CompanyUser,
|
|
853
|
-
CreateServiceForm,
|
|
854
853
|
CreditCurrency,
|
|
855
854
|
InviteResponse,
|
|
856
855
|
InvoiceNo,
|
|
857
856
|
MedicalDetails,
|
|
858
857
|
Medicine,
|
|
859
|
-
|
|
858
|
+
MiniAppointmentDetails,
|
|
859
|
+
MutableAppointmentDetails,
|
|
860
860
|
MutableCompanyBilling,
|
|
861
861
|
MutableCompanyDetails,
|
|
862
862
|
MutableCompanyIdentity,
|
|
863
863
|
MutableCompanyPreferences,
|
|
864
|
-
MutableServiceDetails,
|
|
865
864
|
Notification,
|
|
866
865
|
PriceAdjustment,
|
|
867
866
|
PriceTag,
|
|
868
867
|
Reason,
|
|
869
868
|
Receipts,
|
|
870
|
-
|
|
869
|
+
ScheduleAppointmentForm,
|
|
871
870
|
StandardTime,
|
|
872
871
|
TicketNo,
|
|
873
872
|
TierList,
|
|
@@ -875,10 +874,10 @@ export {
|
|
|
875
874
|
Timestamp,
|
|
876
875
|
UserDetails,
|
|
877
876
|
Vitals,
|
|
877
|
+
appointmentDistAlgs,
|
|
878
878
|
companyPartnerRoles,
|
|
879
879
|
companyServiceSelectors,
|
|
880
880
|
companyUserRoles,
|
|
881
|
-
createCompanyService,
|
|
882
881
|
employeeRoles,
|
|
883
882
|
findAvailableStaff,
|
|
884
883
|
findConflictingPartners,
|
|
@@ -886,7 +885,7 @@ export {
|
|
|
886
885
|
getCompatibleRoles,
|
|
887
886
|
healthcareProviderRoles,
|
|
888
887
|
paymentMethods,
|
|
889
|
-
|
|
888
|
+
scheduleAppointment,
|
|
890
889
|
serviceProviders,
|
|
891
890
|
tiers,
|
|
892
891
|
vitalKeys
|