@natch-the-storage/heathershaw-platform-types 1.18.5 → 1.18.7
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 -2
- package/build/validators.js +77 -1
- 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,31 @@ 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;
|
|
79
|
+
export declare function formatAddress(addr: Address): string;
|
|
54
80
|
export interface Address {
|
|
55
81
|
street: string;
|
|
56
82
|
suburb: string;
|
|
@@ -88,7 +114,7 @@ export interface LineItem {
|
|
|
88
114
|
adverseSymptomsStatus?: string;
|
|
89
115
|
adverseSymptoms?: string;
|
|
90
116
|
notes?: string;
|
|
91
|
-
scriptType:
|
|
117
|
+
scriptType: ScriptType;
|
|
92
118
|
scriptDetails?: {
|
|
93
119
|
token?: string;
|
|
94
120
|
fileKey?: string;
|
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,79 @@ 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
|
+
}
|
|
248
|
+
export function formatAddress(addr) {
|
|
249
|
+
return `${addr.street}, ${addr.suburb} ${addr.state} ${addr.postcode}`;
|
|
250
|
+
}
|
|
175
251
|
//#endregion ──────────────────────────────────────────────────────────────────────
|
|
176
252
|
//#region compound direct ────────────────────────────────────────────────────────────
|
|
177
253
|
export const CDProductCategoriesIdLabel = cDProductCategoryIdValues.map((v, i) => {
|