@joinskips/common 0.0.0-stage → 0.1.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.
Files changed (131) hide show
  1. package/README.md +104 -2
  2. package/dist/chat/SkipsChat.d.ts +37 -0
  3. package/dist/chat/SkipsChat.js +103 -0
  4. package/dist/chat/client.d.ts +53 -0
  5. package/dist/chat/client.js +178 -0
  6. package/dist/chat/connection.d.ts +4 -0
  7. package/dist/chat/connection.js +6 -0
  8. package/dist/chat/generated/skips-app/index.d.ts +1 -0
  9. package/dist/chat/generated/skips-app/index.js +2 -0
  10. package/dist/chat/generated/skips-app/types.gen.d.ts +733 -0
  11. package/dist/chat/generated/skips-app/types.gen.js +2 -0
  12. package/dist/chat/index.d.ts +3 -0
  13. package/dist/chat/index.js +2 -0
  14. package/dist/chat/platform.d.ts +4 -0
  15. package/dist/chat/platform.js +46 -0
  16. package/dist/chat/session.d.ts +19 -0
  17. package/dist/chat/session.js +95 -0
  18. package/dist/chat/useSkipsChat.d.ts +79 -0
  19. package/dist/chat/useSkipsChat.js +507 -0
  20. package/dist/chat/verify.d.ts +35 -0
  21. package/dist/chat/verify.js +84 -0
  22. package/dist/elements/skips-elements.js +18521 -0
  23. package/dist/helpers/attachments.d.ts +12 -0
  24. package/dist/helpers/attachments.js +34 -0
  25. package/dist/helpers/cable.d.ts +34 -0
  26. package/dist/helpers/cable.js +88 -0
  27. package/dist/helpers/cableFrames.d.ts +40 -0
  28. package/dist/helpers/cableFrames.js +70 -0
  29. package/dist/helpers/cardNote.d.ts +79 -0
  30. package/dist/helpers/cardNote.js +152 -0
  31. package/dist/helpers/commandNote.d.ts +4 -0
  32. package/dist/helpers/commandNote.js +23 -0
  33. package/dist/helpers/index.d.ts +19 -0
  34. package/dist/helpers/index.js +19 -0
  35. package/dist/helpers/markdown.d.ts +47 -0
  36. package/dist/helpers/markdown.js +129 -0
  37. package/dist/helpers/medicationOrder.d.ts +333 -0
  38. package/dist/helpers/medicationOrder.js +383 -0
  39. package/dist/helpers/message.d.ts +46 -0
  40. package/dist/helpers/message.js +12 -0
  41. package/dist/helpers/noteView.d.ts +35 -0
  42. package/dist/helpers/noteView.js +65 -0
  43. package/dist/helpers/orderForm.d.ts +126 -0
  44. package/dist/helpers/orderForm.js +271 -0
  45. package/dist/helpers/ordersMenu.d.ts +56 -0
  46. package/dist/helpers/ordersMenu.js +129 -0
  47. package/dist/helpers/regimenChoice.d.ts +42 -0
  48. package/dist/helpers/regimenChoice.js +73 -0
  49. package/dist/helpers/scrollBox.d.ts +5 -0
  50. package/dist/helpers/scrollBox.js +15 -0
  51. package/dist/helpers/skipTyping.d.ts +26 -0
  52. package/dist/helpers/skipTyping.js +29 -0
  53. package/dist/helpers/skipsMessage.d.ts +55 -0
  54. package/dist/helpers/skipsMessage.js +130 -0
  55. package/dist/helpers/stageRefill.d.ts +33 -0
  56. package/dist/helpers/stageRefill.js +41 -0
  57. package/dist/helpers/thread.d.ts +54 -0
  58. package/dist/helpers/thread.js +122 -0
  59. package/dist/helpers/typing.d.ts +13 -0
  60. package/dist/helpers/typing.js +68 -0
  61. package/dist/helpers/usrxNote.d.ts +22 -0
  62. package/dist/helpers/usrxNote.js +26 -0
  63. package/dist/helpers/visibleArea.d.ts +15 -0
  64. package/dist/helpers/visibleArea.js +11 -0
  65. package/dist/helpers/welcome.d.ts +25 -0
  66. package/dist/helpers/welcome.js +51 -0
  67. package/dist/hooks/index.d.ts +8 -0
  68. package/dist/hooks/index.js +8 -0
  69. package/dist/hooks/useCardNoteActions.d.ts +82 -0
  70. package/dist/hooks/useCardNoteActions.js +210 -0
  71. package/dist/hooks/useCodeEntry.d.ts +6 -0
  72. package/dist/hooks/useCodeEntry.js +14 -0
  73. package/dist/hooks/useComposer.d.ts +20 -0
  74. package/dist/hooks/useComposer.js +40 -0
  75. package/dist/hooks/useOrderForm.d.ts +80 -0
  76. package/dist/hooks/useOrderForm.js +403 -0
  77. package/dist/hooks/useOrdersMenu.d.ts +114 -0
  78. package/dist/hooks/useOrdersMenu.js +337 -0
  79. package/dist/hooks/useRegimenChoice.d.ts +23 -0
  80. package/dist/hooks/useRegimenChoice.js +50 -0
  81. package/dist/hooks/useResendCountdown.d.ts +2 -0
  82. package/dist/hooks/useResendCountdown.js +19 -0
  83. package/dist/hooks/useStepField.d.ts +8 -0
  84. package/dist/hooks/useStepField.js +17 -0
  85. package/dist/hooks/useTypingCue.d.ts +11 -0
  86. package/dist/hooks/useTypingCue.js +41 -0
  87. package/dist/hooks/useWelcomeTyping.d.ts +2 -0
  88. package/dist/hooks/useWelcomeTyping.js +25 -0
  89. package/dist/index.d.ts +5 -0
  90. package/dist/index.js +5 -0
  91. package/dist/staff/CardNoteActions.d.ts +10 -0
  92. package/dist/staff/CardNoteActions.js +16 -0
  93. package/dist/staff/OrderFormNote.d.ts +8 -0
  94. package/dist/staff/OrderFormNote.js +8 -0
  95. package/dist/staff/OrdersMenuNote.d.ts +8 -0
  96. package/dist/staff/OrdersMenuNote.js +8 -0
  97. package/dist/staff/RegimenChoiceNote.d.ts +7 -0
  98. package/dist/staff/RegimenChoiceNote.js +8 -0
  99. package/dist/staff/features.d.ts +9 -0
  100. package/dist/staff/features.js +8 -0
  101. package/dist/staff/index.d.ts +11 -0
  102. package/dist/staff/index.js +7 -0
  103. package/dist/ui/Bubble.d.ts +5 -0
  104. package/dist/ui/Bubble.js +9 -0
  105. package/dist/ui/CardActions.d.ts +34 -0
  106. package/dist/ui/CardActions.js +28 -0
  107. package/dist/ui/Conversation.d.ts +69 -0
  108. package/dist/ui/Conversation.js +192 -0
  109. package/dist/ui/Markdown.d.ts +11 -0
  110. package/dist/ui/Markdown.js +51 -0
  111. package/dist/ui/NoteFold.d.ts +19 -0
  112. package/dist/ui/NoteFold.js +12 -0
  113. package/dist/ui/NoteViewControl.d.ts +19 -0
  114. package/dist/ui/NoteViewControl.js +20 -0
  115. package/dist/ui/OrderForm.d.ts +71 -0
  116. package/dist/ui/OrderForm.js +118 -0
  117. package/dist/ui/OrdersMenu.d.ts +71 -0
  118. package/dist/ui/OrdersMenu.js +128 -0
  119. package/dist/ui/RegimenChoice.d.ts +23 -0
  120. package/dist/ui/RegimenChoice.js +16 -0
  121. package/dist/ui/SkipAvatar.d.ts +7 -0
  122. package/dist/ui/SkipAvatar.js +8 -0
  123. package/dist/ui/StaffButton.d.ts +18 -0
  124. package/dist/ui/StaffButton.js +17 -0
  125. package/dist/ui/Welcome.d.ts +91 -0
  126. package/dist/ui/Welcome.js +128 -0
  127. package/dist/ui/index.d.ts +8 -0
  128. package/dist/ui/index.js +7 -0
  129. package/dist/ui/parts.d.ts +38 -0
  130. package/dist/ui/parts.js +6 -0
  131. package/package.json +115 -4
@@ -0,0 +1,129 @@
1
+ import MarkdownIt from 'markdown-it';
2
+ // Only addresses a visitor can safely follow. markdown-it already drops javascript:, vbscript:, file: and data:.
3
+ export const LINK_PROTOCOLS = ['http:', 'https:', 'mailto:', 'tel:'];
4
+ // HTML is shown as the text it is, and only an explicit address becomes a link. A single newline is a line break
5
+ // (the tree has no soft breaks).
6
+ // Headings, tables, images and reference links are left as typed: a chat bubble has no use for them.
7
+ const reader = new MarkdownIt({ html: false, linkify: true, typographer: false })
8
+ .disable(['table', 'heading', 'lheading', 'image', 'reference'])
9
+ .enable('strikethrough');
10
+ reader.linkify.set({ fuzzyLink: false, fuzzyEmail: false, fuzzyIP: false });
11
+ function isFollowable(href) {
12
+ try {
13
+ return LINK_PROTOCOLS.includes(new URL(href).protocol);
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ }
19
+ const MARKS = {
20
+ strong_open: { type: 'strong', close: 'strong_close' },
21
+ em_open: { type: 'em', close: 'em_close' },
22
+ s_open: { type: 'del', close: 's_close' },
23
+ };
24
+ // markdown-it leaves empty and split text tokens where marks were weighed, so words are joined up here.
25
+ function addInline(nodes, node) {
26
+ const last = nodes.at(-1);
27
+ if (node.type !== 'text')
28
+ nodes.push(node);
29
+ else if (last?.type === 'text')
30
+ last.text += node.text;
31
+ else if (node.text !== '')
32
+ nodes.push({ ...node });
33
+ }
34
+ // The inline nodes from tokens[from] up to the token that closes them.
35
+ function inlinesFrom(tokens, from, closing) {
36
+ const nodes = [];
37
+ let i = from;
38
+ for (let token = tokens[i]; token !== undefined && token.type !== closing; token = tokens[i]) {
39
+ switch (token.type) {
40
+ case 'text':
41
+ addInline(nodes, { type: 'text', text: token.content });
42
+ break;
43
+ case 'softbreak':
44
+ case 'hardbreak':
45
+ addInline(nodes, { type: 'break' });
46
+ break;
47
+ case 'code_inline':
48
+ addInline(nodes, { type: 'code', text: token.content });
49
+ break;
50
+ case 'strong_open':
51
+ case 'em_open':
52
+ case 's_open': {
53
+ const mark = MARKS[token.type];
54
+ const inner = inlinesFrom(tokens, i + 1, mark.close);
55
+ addInline(nodes, { type: mark.type, children: inner.nodes });
56
+ i = inner.end;
57
+ break;
58
+ }
59
+ case 'link_open': {
60
+ const inner = inlinesFrom(tokens, i + 1, 'link_close');
61
+ // markdown-it gives every link its address. One that cannot be followed keeps its words and drops it.
62
+ const href = String(token.attrGet('href'));
63
+ if (isFollowable(href))
64
+ addInline(nodes, { type: 'link', href, children: inner.nodes });
65
+ else
66
+ for (const node of inner.nodes)
67
+ addInline(nodes, node);
68
+ i = inner.end;
69
+ break;
70
+ }
71
+ // no default
72
+ }
73
+ i += 1;
74
+ }
75
+ return { nodes, end: i };
76
+ }
77
+ // An inline token's words. markdown-it's types allow a token with no children.
78
+ export function inlinesOf(token) {
79
+ return inlinesFrom(token.children ?? [], 0, '').nodes;
80
+ }
81
+ // The blocks from tokens[from] up to the token that closes them.
82
+ function blocksFrom(tokens, from, closing) {
83
+ const blocks = [];
84
+ let i = from;
85
+ for (let token = tokens[i]; token !== undefined && token.type !== closing; token = tokens[i]) {
86
+ switch (token.type) {
87
+ case 'inline':
88
+ blocks.push({ type: 'paragraph', children: inlinesOf(token) });
89
+ break;
90
+ case 'bullet_list_open':
91
+ case 'ordered_list_open': {
92
+ const items = [];
93
+ const close = token.type === 'bullet_list_open' ? 'bullet_list_close' : 'ordered_list_close';
94
+ // Each item holds its own blocks and ends at its closing token.
95
+ for (let at = i + 1; tokens[at]?.type !== close; at = i + 1) {
96
+ const item = blocksFrom(tokens, at + 1, 'list_item_close');
97
+ items.push(item.blocks);
98
+ i = item.end;
99
+ }
100
+ blocks.push({
101
+ type: 'list',
102
+ ordered: token.type === 'ordered_list_open',
103
+ start: Number(token.attrGet('start') ?? 1),
104
+ items,
105
+ });
106
+ break;
107
+ }
108
+ case 'blockquote_open': {
109
+ const quoted = blocksFrom(tokens, i + 1, 'blockquote_close');
110
+ blocks.push({ type: 'quote', children: quoted.blocks });
111
+ i = quoted.end;
112
+ break;
113
+ }
114
+ case 'fence':
115
+ case 'code_block':
116
+ blocks.push({ type: 'code', text: token.content });
117
+ break;
118
+ case 'hr':
119
+ blocks.push({ type: 'rule' });
120
+ break;
121
+ // no default
122
+ }
123
+ i += 1;
124
+ }
125
+ return { blocks, end: i };
126
+ }
127
+ export function readMarkdown(source) {
128
+ return blocksFrom(reader.parse(source, {}), 0, '').blocks;
129
+ }
@@ -0,0 +1,333 @@
1
+ import { type StaffMessage } from './usrxNote.ts';
2
+ export declare const ORDER_VERSION = 2;
3
+ /** A form field: a number field gives a number, a text field a string, and an empty one may hold nothing. */
4
+ export type FieldValue = number | string | null | undefined;
5
+ export declare const AS_NEEDED = "PRN";
6
+ export declare function frequencyCode(name: string | null | undefined): string;
7
+ export interface SigParts {
8
+ quantity: FieldValue;
9
+ doseUnit: string | null | undefined;
10
+ frequency: string | null | undefined;
11
+ days?: FieldValue;
12
+ }
13
+ /** Quantity + Dose + Frequency + Duration, in that order, or empty until the first three are given. */
14
+ export declare function sigText({ quantity, doseUnit, frequency, days }: SigParts): string;
15
+ /** A rate as k doses every n days. */
16
+ export type Rate = [number, number];
17
+ export declare function exactRate(perDay: number): Rate;
18
+ export interface DispenseParts {
19
+ quantity: FieldValue;
20
+ frequency: string | null | undefined;
21
+ /** The doses a day Treat gives the frequency (usrx's drug lookup, count). */
22
+ perDay: number | undefined;
23
+ days: FieldValue;
24
+ /** The most times a day, which the form asks for plain as needed. */
25
+ maxPerDay?: FieldValue;
26
+ }
27
+ /**
28
+ * Quantity x the doses the course holds: a dose on its first day, then one each interval (a weekly dose over 30 days
29
+ * is 5). For plain as needed the doses a day are the most allowed. Empty when the inputs give no amount.
30
+ */
31
+ export declare function dispenseAmount({ quantity, frequency, perDay, days, maxPerDay }: DispenseParts): string;
32
+ export interface DispenseFill {
33
+ current: FieldValue;
34
+ lastFilled: FieldValue;
35
+ computed: string;
36
+ }
37
+ /**
38
+ * The dispense amount the form filled in follows a new computed one, which may be '' when the inputs no longer give
39
+ * one. A number the provider typed over it stays. Compared as text, since a number field gives a number.
40
+ */
41
+ export declare function nextDispenseAmount({ current, lastFilled, computed }: DispenseFill): FieldValue;
42
+ export interface SigSource {
43
+ quantity: FieldValue;
44
+ doseUnitId: FieldValue;
45
+ frequencyId: FieldValue;
46
+ days: FieldValue;
47
+ }
48
+ /** What the SIG is computed from, so a card can keep a SIG typed in Treat until one of these changes. */
49
+ export declare function sigInputs(item: SigSource): string;
50
+ /** A card staged in Treat and not sent, as usrx reads it. */
51
+ export interface StagedCard {
52
+ uid: string;
53
+ ddid: string;
54
+ drugName: string;
55
+ drugDetails?: string;
56
+ doseUnitId: FieldValue;
57
+ quantity: FieldValue;
58
+ frequencyId: FieldValue;
59
+ days: FieldValue;
60
+ sig: string;
61
+ dispenseUnitId: FieldValue;
62
+ dispenseAmount: FieldValue;
63
+ refills: FieldValue;
64
+ pharmacyNotes?: string | null;
65
+ earliestFillDate?: string | null;
66
+ substituteOk?: boolean;
67
+ status?: string;
68
+ /** A queued card's number in usrx's queue, which a queued card is edited and deleted by. */
69
+ queuedId?: string;
70
+ pharmacyName?: string;
71
+ pharmacy?: Pharmacy | null;
72
+ }
73
+ export interface Drug {
74
+ ddid: string;
75
+ name: string;
76
+ details?: string | undefined;
77
+ controlled?: boolean;
78
+ }
79
+ /** A dose or dispense unit, or a frequency, as Treat lists it. */
80
+ export interface TreatOption {
81
+ id: string;
82
+ name: string;
83
+ }
84
+ export interface Pharmacy {
85
+ ncpdpid: string;
86
+ name: string;
87
+ address: string;
88
+ phone?: string;
89
+ }
90
+ /** One of the Order form's medicines, as the provider fills it in. */
91
+ export interface OrderItem {
92
+ term?: string;
93
+ drug: Drug | null;
94
+ doseUnit?: TreatOption | null;
95
+ doseUnitId?: FieldValue;
96
+ quantity: FieldValue;
97
+ frequency?: TreatOption | null;
98
+ frequencyId?: FieldValue;
99
+ days?: FieldValue;
100
+ sig?: string;
101
+ dispenseUnit?: TreatOption | null;
102
+ dispenseUnitId?: FieldValue;
103
+ dispenseAmount: FieldValue;
104
+ refills: FieldValue;
105
+ pharmacyNotes?: string | null | undefined;
106
+ earliestFillDate?: string | null | undefined;
107
+ substituteOk?: boolean | undefined;
108
+ /** What it treats, the ICD-10 for it, which a new medicine asks for and usrx requires once asked (joinskips/usrx#455). */
109
+ indication?: string | undefined;
110
+ /** Discontinue the current medication Treat's duplicate therapy alert names, instead of overriding the alert. */
111
+ discontinueDuplicate?: boolean | undefined;
112
+ pharmacy?: Pharmacy | null;
113
+ /** The set and round of a medicine sent in rounds. */
114
+ set?: number;
115
+ round?: number;
116
+ cardSig?: string;
117
+ cardSigInputs?: string;
118
+ }
119
+ /** A staged card as one of the form's medicines. */
120
+ export declare function itemFromCard(card: StagedCard): OrderItem;
121
+ export type CardFields = Record<string, FieldValue | boolean>;
122
+ /** Only what the provider changed goes to usrx, which keeps the rest as Treat holds it. A number field gives a number. */
123
+ export declare function changedFields(card: StagedCard, item: OrderItem): CardFields;
124
+ /** What usrx cannot stage without (joinskips/usrx#22, REQUIRED). */
125
+ export declare function isComplete(item: OrderItem): boolean;
126
+ export declare function oneLine(text: string | null | undefined): string;
127
+ export declare const SHOWN_PHARMACIES = 50;
128
+ export interface PharmacyWords {
129
+ name: string;
130
+ address: string;
131
+ }
132
+ export declare function pharmacyMatches(pharmacy: PharmacyWords, words: string | null | undefined): boolean;
133
+ /** A medicine the form can post: every field usrx needs is there. */
134
+ export interface ReadyItem extends OrderItem {
135
+ drug: Drug;
136
+ doseUnit: TreatOption;
137
+ frequency: TreatOption;
138
+ dispenseUnit: TreatOption;
139
+ pharmacy: Pharmacy;
140
+ sig: string;
141
+ }
142
+ export interface OrderPharmacy {
143
+ ncpdp: string;
144
+ name: string;
145
+ address: string;
146
+ phone: string | undefined;
147
+ }
148
+ export interface OrderDrug {
149
+ ddid: string;
150
+ name: string;
151
+ }
152
+ export interface OrderMeasure {
153
+ amount: string;
154
+ unitId: string;
155
+ unitLabel: string;
156
+ }
157
+ export interface OrderFrequency {
158
+ id: string;
159
+ label: string;
160
+ }
161
+ export interface UsrxOrderItem {
162
+ pharmacy: OrderPharmacy;
163
+ set?: number | undefined;
164
+ round?: number;
165
+ drug: OrderDrug;
166
+ dose: OrderMeasure;
167
+ frequency: OrderFrequency;
168
+ days: string;
169
+ sig: string;
170
+ dispense: OrderMeasure;
171
+ refills: string;
172
+ earliestFillDate: string;
173
+ noteToPharmacy: string;
174
+ substituteOk: boolean;
175
+ indication?: string;
176
+ discontinueDuplicate?: true;
177
+ }
178
+ /** An order note's content_attributes.usrx_order, as usrx reads it (joinskips/usrx skips-app/order-note.ts). */
179
+ export interface UsrxOrder {
180
+ version: number;
181
+ patientUid?: string;
182
+ items: UsrxOrderItem[];
183
+ }
184
+ export interface OrderInput {
185
+ items: readonly ReadyItem[];
186
+ /** The Treat chart picked when several fit (usrx jobs/charts.ts). */
187
+ patientUid?: string | undefined;
188
+ }
189
+ export declare function buildOrder({ items, patientUid }: OrderInput): UsrxOrder;
190
+ /** One medicine of an order note, which a queued medicine is also saved as (joinskips/usrx#123). */
191
+ export declare function orderItem(item: ReadyItem): UsrxOrderItem;
192
+ /** The note's text: the order in plain words, for the people reading the conversation. */
193
+ export declare function noteText(order: UsrxOrder): string;
194
+ /**
195
+ * A round's Pharmacy Notes start with which round it is, so the pharmacy knows which it fills. The provider's own words
196
+ * follow, and a medicine back to one round loses the start.
197
+ */
198
+ export declare function roundNote(notes: string | null | undefined, round: number, rounds: number): string;
199
+ export interface CardWordsSource {
200
+ drugName: string;
201
+ sig?: string | null;
202
+ }
203
+ /** How a staged card reads in the Orders menu: drug and strength, then the whole sig, which tells two cards of one drug apart. */
204
+ export declare function cardWords(card: CardWordsSource): string;
205
+ export declare const CARD_STATUS: {
206
+ STAGED: string;
207
+ QUEUED: string;
208
+ };
209
+ export declare function isQueued(card: Pick<StagedCard, 'status'>): boolean;
210
+ /** Today where the device is, as YYYY-MM-DD, the form a supply's end day comes in and is compared in. */
211
+ export declare function localDay(now?: Date): string;
212
+ export declare const OPEN_IN_TREAT = "Open in Treat:";
213
+ export interface RefusalParts {
214
+ text: string;
215
+ link: string;
216
+ }
217
+ export declare function refusalParts(why: string | null | undefined): RefusalParts;
218
+ /** A calendar day (YYYY-MM-DD) in the viewer's own date words, read as that day wherever the viewer is. */
219
+ export declare function dayWords(day: string): string;
220
+ export declare const ORDER_STATUS: {
221
+ CURRENT: string;
222
+ COMPLETED: string;
223
+ CANCELLED: string;
224
+ DISCONTINUED: string;
225
+ };
226
+ /** The rounds a drug sent in rounds belongs to. */
227
+ export interface OrderSet {
228
+ key: string;
229
+ round: number;
230
+ rounds: number;
231
+ endsOn?: string;
232
+ }
233
+ /** A member's stop of a medicine, which `requested` marks as the member's own and not yet acted on. */
234
+ export interface OrderStop {
235
+ reason?: string | null;
236
+ requested?: boolean;
237
+ }
238
+ /** The pharmacy an order went to, as past-orders reads it. */
239
+ export interface SentPharmacy {
240
+ name?: string | null;
241
+ address?: string | null;
242
+ ncpdpid?: string | null;
243
+ }
244
+ /** A prescription sent from Treat, as usrx's past-orders reads it. */
245
+ export interface PastOrder {
246
+ uid: string;
247
+ sentAt: string;
248
+ drugName?: string;
249
+ sig?: string | null;
250
+ ddid?: string;
251
+ pharmacyName?: string | null;
252
+ pharmacy?: SentPharmacy | null;
253
+ refills?: string | number | null;
254
+ refillsLeft?: number | null;
255
+ stop?: OrderStop | null;
256
+ supplyEndsOn?: string | null;
257
+ set?: OrderSet | null;
258
+ cancelled?: boolean;
259
+ discontinued?: boolean;
260
+ cancelUntil?: string | null;
261
+ cancelStatus?: string | null;
262
+ drugDetails?: string;
263
+ doseUnitId?: FieldValue;
264
+ quantity?: FieldValue;
265
+ frequencyId?: FieldValue;
266
+ days?: FieldValue;
267
+ dispenseUnitId?: FieldValue;
268
+ dispenseAmount?: FieldValue;
269
+ pharmacyNotes?: string | null;
270
+ substituteOk?: boolean;
271
+ }
272
+ export type SupplyEnd = Pick<PastOrder, 'set' | 'supplyEndsOn'>;
273
+ /** An order whose end could not be counted has not run out. */
274
+ export declare function supplyRunning(order: SupplyEnd, today: string): boolean;
275
+ export declare function orderStatuses(order: PastOrder, today: string): string[];
276
+ export interface OrderRow {
277
+ key: string;
278
+ orders: PastOrder[];
279
+ set: OrderSet | null;
280
+ }
281
+ /** A drug sent in rounds is one row, its rounds in order, placed where its newest round is. Each other order is a row of its own. */
282
+ export declare function orderRows(orders: readonly PastOrder[]): OrderRow[];
283
+ /** A set's name is its drug's, with the strength each round changes left out. */
284
+ export declare function setName(row: OrderRow): string;
285
+ /** The round running today: the first whose own supply has not run out. */
286
+ export declare function currentRound(row: OrderRow, today: string): PastOrder | null;
287
+ export declare function cancelOpen(order: PastOrder, now?: Date): boolean;
288
+ /** The cards a row's Cancel Rx names: every round still open to a cancel. */
289
+ export declare function cancellableUids(row: Pick<OrderRow, 'orders'>, now?: Date): string[];
290
+ export declare const CANCEL_BADGES: {
291
+ PENDING: string;
292
+ DENIED: string;
293
+ FAILED: string;
294
+ };
295
+ /** A row's badge for the cancel status usrx sent, or null for none to show. */
296
+ export declare function cancelBadge(cancelStatus: string | null | undefined): string | null;
297
+ /**
298
+ * The newest usrx note after a message id, by its id, which means Treat's cards may have changed: staged after a
299
+ * payment, sent, or changed. The notes already there when the menu first read Treat are not news, and neither is a
300
+ * provider's note that quotes the tag part way through.
301
+ */
302
+ export declare function newestUsrxNote(messages: readonly StaffMessage[] | undefined, afterId: number): number | null;
303
+ /** The newest message the Skips App has numbered. A message still sending has a uuid. */
304
+ export declare function newestMessageId(messages: readonly Pick<StaffMessage, 'id'>[] | undefined): number;
305
+ export declare const LOOKUP_MESSAGES: {
306
+ NOT_SET_UP: string;
307
+ TREAT_DOWN: string;
308
+ TERM_TOO_SHORT: string;
309
+ NOT_A_ZIP: string;
310
+ MAIL_ORDER_NOT_SET_UP: string;
311
+ CONTACT_INCOMPLETE: string;
312
+ PATIENT_CHOICE: string;
313
+ CHART_PENDING: string;
314
+ BAD_REQUEST: string;
315
+ SIGN_IN_REFUSED: string;
316
+ TREAT_UNAVAILABLE: string;
317
+ TREAT_REFUSED: string;
318
+ TREAT_REFUSED_NO_STATUS: string;
319
+ LOOKUP_BUSY: string;
320
+ LOOKUP_FAILED: string;
321
+ };
322
+ export declare const SHOWN_REF_LENGTH = 8;
323
+ export interface LookupFailure {
324
+ message: string;
325
+ code: string;
326
+ status: number | undefined;
327
+ ref: string;
328
+ }
329
+ /**
330
+ * What treat_lookups answered for a failed lookup (skips-app patch 170), as the message to show and its values. Null
331
+ * for any other error, which the form does not explain.
332
+ */
333
+ export declare function lookupFailure(answer: unknown): LookupFailure | null;