@natch-the-storage/heathershaw-platform-types 1.0.0

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.
@@ -0,0 +1,389 @@
1
+ import { z } from 'zod';
2
+
3
+ // ─── Enum value arrays ──────────────────────────────────────────────────────────
4
+ export const paperScriptReminderStatusValues = [
5
+ 'PENDING',
6
+ 'RECEIVED',
7
+ 'ESCALATED',
8
+ ];
9
+ export const quoteStatusValues = ['PENDING', 'PROCESSING', 'RESOLVED'];
10
+ export const paymentModeAtOrderValues = ['INVOICE', 'POS'];
11
+ export const paymentStatusValues = [
12
+ 'AWAITING_PAYMENT',
13
+ 'PAID',
14
+ 'PENDING_INVOICE',
15
+ ];
16
+ export const productCategoryValues = ['TODO1', 'TODO2', 'TODO3'];
17
+ export const repeatStorageValues = ['HEATHERSHAWS', 'PHARMACY', 'PATIENT'];
18
+ export const scriptTypeValues = ['eRx', 'PAPER'];
19
+ export const shippingTypeValues = ['STANDARD', 'COLD_CHAIN'];
20
+ export const hazardTagsValues = ['Hazardous', 'Cytotoxic', 'High-Risk'];
21
+
22
+ // ─── Shared sub-schemas ─────────────────────────────────────────────────────────
23
+ export const addressSchema = z.object({
24
+ street: z.string().min(1),
25
+ suburb: z.string().min(1),
26
+ state: z.string().min(1),
27
+ postcode: z.string().min(1),
28
+ deliveryInstructions: z.string().optional(),
29
+ });
30
+
31
+ export const prescriberSelectSchema = z.object({
32
+ id: z.number(),
33
+ name: z.string(),
34
+ email: z.string(),
35
+ phone: z.string(),
36
+ });
37
+
38
+ export const healthInfoSchema = z.object({
39
+ allergies: z.string().nullable(),
40
+ conditions: z.string().nullable(),
41
+ relevantHistory: z.string().nullable(),
42
+ currentMedications: z.string().nullable(),
43
+ prescriber: prescriberSelectSchema.nullable(),
44
+ });
45
+
46
+ export const scriptSelectSchema = z.object({
47
+ id: z.number(),
48
+ prescriberId: z.number(),
49
+ patientRecordId: z.number(),
50
+ productId: z.number(),
51
+ dateIssued: z.string(),
52
+ processed: z.boolean(),
53
+ repeatsRemaining: z.number(),
54
+ daysSupply: z.number(),
55
+ repeatStorage: z.enum(repeatStorageValues),
56
+ compoundDirectId: z.string().nullable(),
57
+ imageKey: z.string().nullable(),
58
+ });
59
+
60
+ export const orderSelectSchema = z.object({
61
+ id: z.number(),
62
+ partnerPharmacyProfileId: z.number().nullable(),
63
+ patientRecordId: z.number().nullable(),
64
+ completed: z.boolean(),
65
+ paymentModeAtOrder: z.enum(paymentModeAtOrderValues),
66
+ paymentStatus: z.enum(paymentStatusValues),
67
+ scriptType: z.enum(scriptTypeValues),
68
+ paperScriptReceived: z.boolean(),
69
+ shippingType: z.enum(shippingTypeValues),
70
+ shippingFee: z.string(),
71
+ lineItems: z.unknown(),
72
+ orderChangeNotes: z.string().nullable(),
73
+ counsellingRequired: z.boolean(),
74
+ confirmationSentAt: z.date().nullable(),
75
+ hubspotContactId: z.string().nullable(),
76
+ createdByUserId: z.string().nullable(),
77
+ });
78
+
79
+ // ─── common ─────────────────────────────────────────────────────────────────────
80
+ export const getByIdSchema = z.object({
81
+ id: z.preprocess((value) => {
82
+ if (typeof value === 'string' && value !== '') return Number(value);
83
+ return value;
84
+ }, z.number().int().min(1)),
85
+ });
86
+
87
+ export const getAllSchema = z.object({
88
+ page: z.preprocess((value) => {
89
+ if (typeof value === 'string' && value !== '') return Number(value);
90
+ return undefined;
91
+ }, z.number().int().min(1).optional()),
92
+ limit: z.preprocess((value) => {
93
+ if (typeof value === 'string' && value !== '') return Number(value);
94
+ return undefined;
95
+ }, z.number().int().min(1).max(100).optional()),
96
+ });
97
+
98
+ export const devEmailSchema = z.object({
99
+ to: z.string(),
100
+ name: z.string(),
101
+ number: z.number(),
102
+ });
103
+
104
+ export const smsSchema = z.object({
105
+ body: z.string(),
106
+ to: z.string(),
107
+ from: z.string(),
108
+ });
109
+
110
+ // ─── direct-user-profile ────────────────────────────────────────────────────────
111
+ export const createDirectUserProfileBodySchema = z.object({
112
+ userId: z.string(),
113
+ patientRecordId: z.number().int().nullable().optional(),
114
+ compoundDirectId: z.string().nullable().optional(),
115
+ remindersEnabled: z.boolean().optional(),
116
+ scriptSubmissions: z.array(scriptSelectSchema).nullable(),
117
+ });
118
+
119
+ export const updateDirectUserProfileBodySchema = z.object({
120
+ id: z.number().int().min(1),
121
+ userId: z.string().optional(),
122
+ patientRecordId: z.number().int().nullable().optional(),
123
+ compoundDirectId: z.string().nullable().optional(),
124
+ remindersEnabled: z.boolean().optional(),
125
+ scriptSubmissions: z.array(scriptSelectSchema).nullable().optional(),
126
+ });
127
+
128
+ // ─── order ──────────────────────────────────────────────────────────────────────
129
+ export const createOrderBodySchema = z.object({
130
+ partnerPharmacyProfileId: z.number().int().nullable().optional(),
131
+ patientRecordId: z.number().int().nullable().optional(),
132
+ completed: z.boolean().optional(),
133
+ paymentModeAtOrder: z.enum(paymentModeAtOrderValues),
134
+ paymentStatus: z.enum(paymentStatusValues),
135
+ scriptType: z.enum(scriptTypeValues),
136
+ paperScriptReceived: z.boolean().optional(),
137
+ shippingType: z.enum(shippingTypeValues),
138
+ shippingFee: z.string(),
139
+ lineItems: z.unknown().optional(),
140
+ orderChangeNotes: z.string().nullable().optional(),
141
+ counsellingRequired: z.boolean().optional(),
142
+ confirmationSentAt: z.coerce.date().nullable().optional(),
143
+ hubspotContactId: z.string().nullable().optional(),
144
+ createdByUserId: z.string().nullable().optional(),
145
+ });
146
+
147
+ export const updateOrderBodySchema = z.object({
148
+ id: z.number().int().min(1),
149
+ partnerPharmacyProfileId: z.number().int().nullable().optional(),
150
+ patientRecordId: z.number().int().nullable().optional(),
151
+ completed: z.boolean().optional(),
152
+ paymentModeAtOrder: z.enum(paymentModeAtOrderValues).optional(),
153
+ paymentStatus: z.enum(paymentStatusValues).optional(),
154
+ scriptType: z.enum(scriptTypeValues).optional(),
155
+ paperScriptReceived: z.boolean().optional(),
156
+ shippingType: z.enum(shippingTypeValues).optional(),
157
+ shippingFee: z.string().optional(),
158
+ lineItems: z.unknown().optional(),
159
+ orderChangeNotes: z.string().nullable().optional(),
160
+ counsellingRequired: z.boolean().optional(),
161
+ confirmationSentAt: z.coerce.date().nullable().optional(),
162
+ hubspotContactId: z.string().nullable().optional(),
163
+ createdByUserId: z.string().nullable().optional(),
164
+ });
165
+
166
+ // ─── paper-script-reminder ──────────────────────────────────────────────────────
167
+ export const createPaperScriptReminderBodySchema = z.object({
168
+ orderId: z.number().int(),
169
+ partnerPharmacyProfileId: z.number().int(),
170
+ status: z.enum(paperScriptReminderStatusValues),
171
+ remindersSent: z.number().int(),
172
+ reminderIntervalDays: z.number().int().optional(),
173
+ escalationEmail: z.string(),
174
+ receivedMarked: z.boolean(),
175
+ });
176
+
177
+ export const updatePaperScriptReminderBodySchema = z.object({
178
+ id: z.number().int().min(1),
179
+ orderId: z.number().int().optional(),
180
+ partnerPharmacyProfileId: z.number().int().optional(),
181
+ status: z.enum(paperScriptReminderStatusValues).optional(),
182
+ remindersSent: z.number().int().optional(),
183
+ reminderIntervalDays: z.number().int().optional(),
184
+ escalationEmail: z.string().optional(),
185
+ receivedMarked: z.boolean().optional(),
186
+ });
187
+
188
+ // ─── partner-pharmacy-profile ───────────────────────────────────────────────────
189
+ export const createPartnerPharmacyProfileBodySchema = z.object({
190
+ userId: z.string(),
191
+ abn: z.string(),
192
+ contactName: z.string(),
193
+ invoiceEmail: z.string(),
194
+ phone: z.string(),
195
+ discountTier: z.string(),
196
+ paymentMode: z.enum(paymentModeAtOrderValues),
197
+ remindersEnabled: z.boolean().optional(),
198
+ priceMatches: z.unknown().optional(),
199
+ dispatchAddress: addressSchema.nullable(),
200
+ orders: z.unknown().optional(),
201
+ xeroContactId: z.string().nullable().optional(),
202
+ });
203
+
204
+ export const updatePartnerPharmacyProfileBodySchema = z.object({
205
+ id: z.number().int().min(1),
206
+ userId: z.string().optional(),
207
+ abn: z.string().optional(),
208
+ contactName: z.string().optional(),
209
+ invoiceEmail: z.string().optional(),
210
+ phone: z.string().optional(),
211
+ discountTier: z.string().optional(),
212
+ paymentMode: z.enum(paymentModeAtOrderValues).optional(),
213
+ remindersEnabled: z.boolean().optional(),
214
+ priceMatches: z.unknown().optional(),
215
+ dispatchAddress: addressSchema.nullable().optional(),
216
+ orders: z.unknown().optional(),
217
+ xeroContactId: z.string().nullable().optional(),
218
+ });
219
+
220
+ // ─── patient-record ─────────────────────────────────────────────────────────────
221
+ export const getPatientRecordsQuerySchema = getAllSchema.extend({
222
+ partner_pharmacy_profile_id: z.preprocess((value) => {
223
+ if (typeof value === 'string' && value !== '') return Number(value);
224
+ return undefined;
225
+ }, z.number().int().min(1).optional()),
226
+ });
227
+
228
+ export const createPatientRecordBodySchema = z.object({
229
+ partnerPharmacyProfileId: z.number().int().nullable().optional(),
230
+ userId: z.string().nullable().optional(),
231
+ firstName: z.string(),
232
+ lastName: z.string(),
233
+ dateOfBirth: z.string(),
234
+ medicareNumber: z.string().nullable().optional(),
235
+ phone: z.string(),
236
+ address: addressSchema.nullable(),
237
+ healthInfo: healthInfoSchema.nullable(),
238
+ reminderEnabled: z.boolean().optional(),
239
+ scripts: z.array(scriptSelectSchema).nullable(),
240
+ orderHistory: z.array(orderSelectSchema).nullable(),
241
+ });
242
+
243
+ export const updatePatientRecordBodySchema = z.object({
244
+ id: z.number().int().min(1),
245
+ partnerPharmacyProfileId: z.number().int().nullable().optional(),
246
+ userId: z.string().nullable().optional(),
247
+ firstName: z.string().optional(),
248
+ lastName: z.string().optional(),
249
+ dateOfBirth: z.string().optional(),
250
+ medicareNumber: z.string().nullable().optional(),
251
+ phone: z.string().optional(),
252
+ address: addressSchema.nullable().optional(),
253
+ healthInfo: healthInfoSchema.nullable().optional(),
254
+ reminderEnabled: z.boolean().optional(),
255
+ scripts: z.array(scriptSelectSchema).nullable().optional(),
256
+ orderHistory: z.array(orderSelectSchema).nullable().optional(),
257
+ });
258
+
259
+ // ─── prescriber ─────────────────────────────────────────────────────────────────
260
+ export const createPrescriberBodySchema = z.object({
261
+ name: z.string(),
262
+ email: z.string(),
263
+ phone: z.string(),
264
+ });
265
+
266
+ export const updatePrescriberBodySchema = z.object({
267
+ id: z.number().int().min(1),
268
+ name: z.string().optional(),
269
+ email: z.string().optional(),
270
+ phone: z.string().optional(),
271
+ });
272
+
273
+ // ─── price-match ────────────────────────────────────────────────────────────────
274
+ export const createPriceMatchBodySchema = z.object({
275
+ partnerPharmacyProfileId: z.number().int(),
276
+ productId: z.number().int(),
277
+ overridePrice: z.string(),
278
+ });
279
+
280
+ export const updatePriceMatchBodySchema = z.object({
281
+ id: z.number().int().min(1),
282
+ partnerPharmacyProfileId: z.number().int().optional(),
283
+ productId: z.number().int().optional(),
284
+ overridePrice: z.string().optional(),
285
+ });
286
+
287
+ // ─── product ────────────────────────────────────────────────────────────────────
288
+ export const createProductBodySchema = z.object({
289
+ name: z.string(),
290
+ imageKey: z.string().nullable().optional(),
291
+ abbreviations: z.array(z.string()).nullable().optional(),
292
+ category: z.enum(productCategoryValues),
293
+ rrp: z.string(),
294
+ hazardTags: z.array(z.enum(hazardTagsValues)).nullable().optional(),
295
+ compoundDirectId: z.string().nullable().optional(),
296
+ requiresFridge: z.boolean().optional(),
297
+ flavours: z.array(z.string()).nullable().optional(),
298
+ requiresS8Medicare: z.boolean().optional(),
299
+ });
300
+
301
+ export const updateProductBodySchema = z.object({
302
+ id: z.number().int().min(1),
303
+ name: z.string().optional(),
304
+ imageKey: z.string().nullable().optional(),
305
+ abbreviations: z.array(z.string()).nullable().optional(),
306
+ category: z.enum(productCategoryValues).optional(),
307
+ rrp: z.string().optional(),
308
+ hazardTags: z.array(z.enum(hazardTagsValues)).nullable().optional(),
309
+ compoundDirectId: z.string().nullable().optional(),
310
+ requiresFridge: z.boolean().optional(),
311
+ flavours: z.array(z.string()).nullable().optional(),
312
+ requiresS8Medicare: z.boolean().optional(),
313
+ });
314
+
315
+ // ─── quote ──────────────────────────────────────────────────────────────────────
316
+ export const createQuoteBodySchema = z.object({
317
+ status: z.enum(quoteStatusValues).optional(),
318
+ partnerPharmacyProfileId: z.number().int(),
319
+ name: z.string(),
320
+ strength: z.string(),
321
+ form: z.string(),
322
+ quantity: z.number().int(),
323
+ patientContext: z.string(),
324
+ });
325
+
326
+ export const updateQuoteBodySchema = z.object({
327
+ id: z.number().int().min(1),
328
+ status: z.enum(quoteStatusValues).optional(),
329
+ partnerPharmacyProfileId: z.number().int().optional(),
330
+ name: z.string().optional(),
331
+ strength: z.string().optional(),
332
+ form: z.string().optional(),
333
+ quantity: z.number().int().optional(),
334
+ patientContext: z.string().optional(),
335
+ });
336
+
337
+ // ─── repeat-reminder ────────────────────────────────────────────────────────────
338
+ export const createRepeatReminderBodySchema = z.object({
339
+ orderId: z.number().int(),
340
+ patientRecordId: z.number().int(),
341
+ daysSupply: z.number().int(),
342
+ dispatchedAt: z.coerce.date(),
343
+ reminderDueAt: z.coerce.date(),
344
+ reminderOffsetDays: z.number().int().optional(),
345
+ pharmacyReminderSent: z.boolean().optional(),
346
+ patientSmsSent: z.boolean().optional(),
347
+ enabled: z.boolean().optional(),
348
+ });
349
+
350
+ export const updateRepeatReminderBodySchema = z.object({
351
+ id: z.number().int().min(1),
352
+ orderId: z.number().int().optional(),
353
+ patientRecordId: z.number().int().optional(),
354
+ daysSupply: z.number().int().optional(),
355
+ dispatchedAt: z.coerce.date().optional(),
356
+ reminderDueAt: z.coerce.date().optional(),
357
+ reminderOffsetDays: z.number().int().optional(),
358
+ pharmacyReminderSent: z.boolean().optional(),
359
+ patientSmsSent: z.boolean().optional(),
360
+ enabled: z.boolean().optional(),
361
+ });
362
+
363
+ // ─── script ─────────────────────────────────────────────────────────────────────
364
+ export const createScriptBodySchema = z.object({
365
+ prescriberId: z.number().int(),
366
+ patientRecordId: z.number().int(),
367
+ productId: z.number().int(),
368
+ dateIssued: z.string(),
369
+ processed: z.boolean().optional(),
370
+ repeatsRemaining: z.number().int().optional(),
371
+ daysSupply: z.number().int(),
372
+ repeatStorage: z.enum(repeatStorageValues),
373
+ compoundDirectId: z.string().nullable().optional(),
374
+ imageKey: z.string().nullable().optional(),
375
+ });
376
+
377
+ export const updateScriptBodySchema = z.object({
378
+ id: z.number().int().min(1),
379
+ prescriberId: z.number().int().optional(),
380
+ patientRecordId: z.number().int().optional(),
381
+ productId: z.number().int().optional(),
382
+ dateIssued: z.string().optional(),
383
+ processed: z.boolean().optional(),
384
+ repeatsRemaining: z.number().int().optional(),
385
+ daysSupply: z.number().int().optional(),
386
+ repeatStorage: z.enum(repeatStorageValues).optional(),
387
+ compoundDirectId: z.string().nullable().optional(),
388
+ imageKey: z.string().nullable().optional(),
389
+ });
package/index.js ADDED
@@ -0,0 +1 @@
1
+ console.log("test");
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@natch-the-storage/heathershaw-platform-types",
3
+ "version": "1.0.0",
4
+ "description": "Validation and interfaces to use on the client",
5
+ "license": "ISC",
6
+ "author": "Natch Surana",
7
+ "type": "commonjs",
8
+ "main": "index.js",
9
+ "files": [
10
+ "build"
11
+ ],
12
+ "scripts": {
13
+ "test": "exit 0"
14
+ },
15
+ "dependencies": {
16
+ "zod": "^4.4.3"
17
+ }
18
+ }