@natch-the-storage/heathershaw-platform-types 1.18.4 → 1.18.6
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/build/validators.d.ts +28 -4
- package/build/validators.js +75 -3
- package/package.json +1 -1
package/build/validators.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const partnerPharmacyPaymentModeValues: readonly ["INVOICE", "POS
|
|
|
12
12
|
export declare const paymentStatusValues: readonly ["UNPAID", "AWAITING_PAYMENT", "PENDING_INVOICE", "PAID"];
|
|
13
13
|
export declare const repeatStorageValues: readonly ["HEATHERSHAWS", "PHARMACY", "PATIENT"];
|
|
14
14
|
export declare const scriptStatusValues: readonly ["PENDING", "PROCESSED"];
|
|
15
|
-
export declare const scriptTypeValues: readonly ["ERX", "PAPER"];
|
|
15
|
+
export declare const scriptTypeValues: readonly ["ERX", "PAPER", "OTC"];
|
|
16
16
|
export declare const shippingTypeValues: readonly ["STANDARD", "COLD_CHAIN", "SAME_DAY_COURIER"];
|
|
17
17
|
export declare const staffProfileRoleValues: readonly ["STAFF", "ADMIN", "COUNSELLING", "SALES_REP", "ALT_THERAPIES", "COMPOUNDING"];
|
|
18
18
|
export declare const staffProfileStatusValues: readonly ["ACTIVE", "SUSPENDED"];
|
|
@@ -38,6 +38,7 @@ export type StaffProfileRole = (typeof staffProfileRoleValues)[number];
|
|
|
38
38
|
export type StaffProfileStatus = (typeof staffProfileStatusValues)[number];
|
|
39
39
|
export type AuStates = (typeof auStatesValues)[number];
|
|
40
40
|
export type DiscountTiers = (typeof discountTierValues)[number];
|
|
41
|
+
export declare const CHILD_AGE: 16;
|
|
41
42
|
export type Pharmacy = {
|
|
42
43
|
name: string;
|
|
43
44
|
address: Address;
|
|
@@ -51,6 +52,30 @@ export type Pharmacy = {
|
|
|
51
52
|
email: string;
|
|
52
53
|
};
|
|
53
54
|
export declare const PHARMACIES: Pharmacy[];
|
|
55
|
+
/**
|
|
56
|
+
* Checks if the lineItems has an item with the cold chain property
|
|
57
|
+
* @param items
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
export declare function lineItemsHasColdChain(items: LineItem[]): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Gets an iso timestamp based on the current AU-Sydney/Melbourne timezone
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
export declare function getCurrentIsoTimestamp(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Formats an ISO date string (yyyy-mm-dd) into a readable format
|
|
68
|
+
* @param dateStr a date in string format, usually ISO (yyyy-mm-dd)
|
|
69
|
+
* @param toDmy format the date as dd/mm/yyyy instead
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
export declare function formatDate(dateStr?: string | null, toDmy?: boolean): string;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the age in years based on todays date vs the date of birth
|
|
75
|
+
* @param dateOfBirth An isoDate (yyyy-mm-dd) string
|
|
76
|
+
* @returns The age in years
|
|
77
|
+
*/
|
|
78
|
+
export declare function getAge(dateOfBirth: string): number;
|
|
54
79
|
export interface Address {
|
|
55
80
|
street: string;
|
|
56
81
|
suburb: string;
|
|
@@ -88,7 +113,7 @@ export interface LineItem {
|
|
|
88
113
|
adverseSymptomsStatus?: string;
|
|
89
114
|
adverseSymptoms?: string;
|
|
90
115
|
notes?: string;
|
|
91
|
-
scriptType:
|
|
116
|
+
scriptType: ScriptType;
|
|
92
117
|
scriptDetails?: {
|
|
93
118
|
token?: string;
|
|
94
119
|
fileKey?: string;
|
|
@@ -914,7 +939,7 @@ export declare const ApiRoutes: {
|
|
|
914
939
|
};
|
|
915
940
|
compoundDirect: {
|
|
916
941
|
searchCustomers: string;
|
|
917
|
-
|
|
942
|
+
getCustomerById: (id: number) => string;
|
|
918
943
|
createCustomer: string;
|
|
919
944
|
updateCustomer: string;
|
|
920
945
|
getDraftScripts: string;
|
|
@@ -922,7 +947,6 @@ export declare const ApiRoutes: {
|
|
|
922
947
|
getDraftScriptsByHousehold: string;
|
|
923
948
|
getFormulationById: (id: number) => string;
|
|
924
949
|
getProductById: (formulationId: number, pricingId: number) => string;
|
|
925
|
-
listProducts: string;
|
|
926
950
|
listProductPrices: ({ limit, page, nextToken, query }: GetAll) => string;
|
|
927
951
|
updateProductPriceOptions: string;
|
|
928
952
|
};
|
package/build/validators.js
CHANGED
|
@@ -74,7 +74,7 @@ export const repeatStorageValues = [
|
|
|
74
74
|
'PATIENT',
|
|
75
75
|
];
|
|
76
76
|
export const scriptStatusValues = ['PENDING', 'PROCESSED'];
|
|
77
|
-
export const scriptTypeValues = ['ERX', 'PAPER'];
|
|
77
|
+
export const scriptTypeValues = ['ERX', 'PAPER', 'OTC'];
|
|
78
78
|
export const shippingTypeValues = [
|
|
79
79
|
'STANDARD',
|
|
80
80
|
'COLD_CHAIN',
|
|
@@ -102,6 +102,9 @@ export const auStatesValues = [
|
|
|
102
102
|
export const discountTierValues = [
|
|
103
103
|
0.9, 0.88, 0.875, 0.85, 0.8, 0.75, 0.7,
|
|
104
104
|
];
|
|
105
|
+
//#endregion ──────────────────────────────────────────────────────────────────────
|
|
106
|
+
//#region Constants ──────────────────────────────────────────────────────────────────
|
|
107
|
+
export const CHILD_AGE = 16;
|
|
105
108
|
export const PHARMACIES = [
|
|
106
109
|
{
|
|
107
110
|
name: 'Malvern Road',
|
|
@@ -172,6 +175,76 @@ export const PHARMACIES = [
|
|
|
172
175
|
email: 'wr@hcip.com.au',
|
|
173
176
|
},
|
|
174
177
|
];
|
|
178
|
+
// #endregion
|
|
179
|
+
//#region Common functions ──────────────────────────────────────────────────────────────
|
|
180
|
+
/**
|
|
181
|
+
* Checks if the lineItems has an item with the cold chain property
|
|
182
|
+
* @param items
|
|
183
|
+
* @returns
|
|
184
|
+
*/
|
|
185
|
+
export function lineItemsHasColdChain(items) {
|
|
186
|
+
return items.some((item) => item.otherScriptProperties.properties.some((p) => p.code === 'WARN 6' || p.code === 'WARN H'));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Gets an iso timestamp based on the current AU-Sydney/Melbourne timezone
|
|
190
|
+
* @returns
|
|
191
|
+
*/
|
|
192
|
+
export function getCurrentIsoTimestamp() {
|
|
193
|
+
const now = new Date();
|
|
194
|
+
const parts = new Intl.DateTimeFormat('en-CA', {
|
|
195
|
+
timeZone: 'Australia/Sydney',
|
|
196
|
+
year: 'numeric',
|
|
197
|
+
month: '2-digit',
|
|
198
|
+
day: '2-digit',
|
|
199
|
+
hour: '2-digit',
|
|
200
|
+
minute: '2-digit',
|
|
201
|
+
second: '2-digit',
|
|
202
|
+
hourCycle: 'h23',
|
|
203
|
+
timeZoneName: 'longOffset',
|
|
204
|
+
}).formatToParts(now);
|
|
205
|
+
const get = (type) => parts.find((p) => p.type === type)?.value ?? '';
|
|
206
|
+
const offset = get('timeZoneName').replace('GMT', '') || '+00:00';
|
|
207
|
+
return `${get('year')}-${get('month')}-${get('day')}T${get('hour')}:${get('minute')}:${get('second')}${offset}`;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Formats an ISO date string (yyyy-mm-dd) into a readable format
|
|
211
|
+
* @param dateStr a date in string format, usually ISO (yyyy-mm-dd)
|
|
212
|
+
* @param toDmy format the date as dd/mm/yyyy instead
|
|
213
|
+
* @returns
|
|
214
|
+
*/
|
|
215
|
+
export function formatDate(dateStr, toDmy) {
|
|
216
|
+
if (!dateStr)
|
|
217
|
+
return '—';
|
|
218
|
+
const date = new Date(dateStr);
|
|
219
|
+
if (isNaN(date.getTime()))
|
|
220
|
+
return dateStr;
|
|
221
|
+
if (toDmy)
|
|
222
|
+
return date.toLocaleDateString('en-AU', {
|
|
223
|
+
day: '2-digit',
|
|
224
|
+
month: '2-digit',
|
|
225
|
+
year: 'numeric',
|
|
226
|
+
});
|
|
227
|
+
return date.toLocaleDateString('en-AU', {
|
|
228
|
+
day: '2-digit',
|
|
229
|
+
month: 'short',
|
|
230
|
+
year: 'numeric',
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Gets the age in years based on todays date vs the date of birth
|
|
235
|
+
* @param dateOfBirth An isoDate (yyyy-mm-dd) string
|
|
236
|
+
* @returns The age in years
|
|
237
|
+
*/
|
|
238
|
+
export function getAge(dateOfBirth) {
|
|
239
|
+
const dob = new Date(dateOfBirth);
|
|
240
|
+
const now = new Date();
|
|
241
|
+
let age = now.getFullYear() - dob.getFullYear();
|
|
242
|
+
const hadBirthdayThisYear = now.getMonth() > dob.getMonth() ||
|
|
243
|
+
(now.getMonth() === dob.getMonth() && now.getDate() >= dob.getDate());
|
|
244
|
+
if (!hadBirthdayThisYear)
|
|
245
|
+
age -= 1;
|
|
246
|
+
return age;
|
|
247
|
+
}
|
|
175
248
|
//#endregion ──────────────────────────────────────────────────────────────────────
|
|
176
249
|
//#region compound direct ────────────────────────────────────────────────────────────
|
|
177
250
|
export const CDProductCategoriesIdLabel = cDProductCategoryIdValues.map((v, i) => {
|
|
@@ -277,7 +350,7 @@ export const ApiRoutes = {
|
|
|
277
350
|
},
|
|
278
351
|
compoundDirect: {
|
|
279
352
|
searchCustomers: '/api/compound-direct/customers',
|
|
280
|
-
|
|
353
|
+
getCustomerById: (id) => `/api/compound-direct/customers/${id}`,
|
|
281
354
|
createCustomer: '/api/compound-direct/new-customers',
|
|
282
355
|
updateCustomer: '/api/compound-direct/customers',
|
|
283
356
|
getDraftScripts: '/api/compound-direct/draft-scripts',
|
|
@@ -285,7 +358,6 @@ export const ApiRoutes = {
|
|
|
285
358
|
getDraftScriptsByHousehold: '/api/compound-direct/scripts/households',
|
|
286
359
|
getFormulationById: (id) => `/api/compound-direct/formulations/${id}`,
|
|
287
360
|
getProductById: (formulationId, pricingId) => `/api/compound-direct/products/${formulationId}/${pricingId}`,
|
|
288
|
-
listProducts: '/api/compound-direct/products',
|
|
289
361
|
listProductPrices: ({ limit, page, nextToken, query }) => `/api/compound-direct/products/prices${handleParams({ limit, page, nextToken, query })}`,
|
|
290
362
|
updateProductPriceOptions: '/api/compound-direct/products/prices',
|
|
291
363
|
},
|