@joinskips/common 0.0.0-stage → 0.1.0-develop.138
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/README.md +102 -2
- package/dist/chat/SkipsChat.d.ts +37 -0
- package/dist/chat/SkipsChat.js +103 -0
- package/dist/chat/client.d.ts +53 -0
- package/dist/chat/client.js +178 -0
- package/dist/chat/connection.d.ts +4 -0
- package/dist/chat/connection.js +6 -0
- package/dist/chat/generated/skips-app/index.d.ts +1 -0
- package/dist/chat/generated/skips-app/index.js +2 -0
- package/dist/chat/generated/skips-app/types.gen.d.ts +733 -0
- package/dist/chat/generated/skips-app/types.gen.js +2 -0
- package/dist/chat/index.d.ts +3 -0
- package/dist/chat/index.js +2 -0
- package/dist/chat/platform.d.ts +4 -0
- package/dist/chat/platform.js +46 -0
- package/dist/chat/session.d.ts +19 -0
- package/dist/chat/session.js +95 -0
- package/dist/chat/useSkipsChat.d.ts +79 -0
- package/dist/chat/useSkipsChat.js +507 -0
- package/dist/chat/verify.d.ts +35 -0
- package/dist/chat/verify.js +84 -0
- package/dist/elements/skips-elements.js +18521 -0
- package/dist/helpers/attachments.d.ts +12 -0
- package/dist/helpers/attachments.js +34 -0
- package/dist/helpers/cable.d.ts +34 -0
- package/dist/helpers/cable.js +88 -0
- package/dist/helpers/cableFrames.d.ts +40 -0
- package/dist/helpers/cableFrames.js +70 -0
- package/dist/helpers/cardNote.d.ts +79 -0
- package/dist/helpers/cardNote.js +152 -0
- package/dist/helpers/commandNote.d.ts +4 -0
- package/dist/helpers/commandNote.js +23 -0
- package/dist/helpers/index.d.ts +19 -0
- package/dist/helpers/index.js +19 -0
- package/dist/helpers/markdown.d.ts +47 -0
- package/dist/helpers/markdown.js +129 -0
- package/dist/helpers/medicationOrder.d.ts +333 -0
- package/dist/helpers/medicationOrder.js +383 -0
- package/dist/helpers/message.d.ts +46 -0
- package/dist/helpers/message.js +12 -0
- package/dist/helpers/noteView.d.ts +35 -0
- package/dist/helpers/noteView.js +65 -0
- package/dist/helpers/orderForm.d.ts +126 -0
- package/dist/helpers/orderForm.js +271 -0
- package/dist/helpers/ordersMenu.d.ts +56 -0
- package/dist/helpers/ordersMenu.js +129 -0
- package/dist/helpers/regimenChoice.d.ts +42 -0
- package/dist/helpers/regimenChoice.js +73 -0
- package/dist/helpers/scrollBox.d.ts +5 -0
- package/dist/helpers/scrollBox.js +15 -0
- package/dist/helpers/skipTyping.d.ts +26 -0
- package/dist/helpers/skipTyping.js +29 -0
- package/dist/helpers/skipsMessage.d.ts +55 -0
- package/dist/helpers/skipsMessage.js +130 -0
- package/dist/helpers/stageRefill.d.ts +33 -0
- package/dist/helpers/stageRefill.js +41 -0
- package/dist/helpers/thread.d.ts +54 -0
- package/dist/helpers/thread.js +122 -0
- package/dist/helpers/typing.d.ts +13 -0
- package/dist/helpers/typing.js +68 -0
- package/dist/helpers/usrxNote.d.ts +22 -0
- package/dist/helpers/usrxNote.js +26 -0
- package/dist/helpers/visibleArea.d.ts +15 -0
- package/dist/helpers/visibleArea.js +11 -0
- package/dist/helpers/welcome.d.ts +25 -0
- package/dist/helpers/welcome.js +51 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/useCardNoteActions.d.ts +82 -0
- package/dist/hooks/useCardNoteActions.js +210 -0
- package/dist/hooks/useCodeEntry.d.ts +6 -0
- package/dist/hooks/useCodeEntry.js +14 -0
- package/dist/hooks/useComposer.d.ts +20 -0
- package/dist/hooks/useComposer.js +40 -0
- package/dist/hooks/useOrderForm.d.ts +80 -0
- package/dist/hooks/useOrderForm.js +403 -0
- package/dist/hooks/useOrdersMenu.d.ts +114 -0
- package/dist/hooks/useOrdersMenu.js +337 -0
- package/dist/hooks/useRegimenChoice.d.ts +23 -0
- package/dist/hooks/useRegimenChoice.js +50 -0
- package/dist/hooks/useResendCountdown.d.ts +2 -0
- package/dist/hooks/useResendCountdown.js +19 -0
- package/dist/hooks/useStepField.d.ts +8 -0
- package/dist/hooks/useStepField.js +17 -0
- package/dist/hooks/useTypingCue.d.ts +11 -0
- package/dist/hooks/useTypingCue.js +41 -0
- package/dist/hooks/useWelcomeTyping.d.ts +2 -0
- package/dist/hooks/useWelcomeTyping.js +25 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/staff/CardNoteActions.d.ts +10 -0
- package/dist/staff/CardNoteActions.js +16 -0
- package/dist/staff/OrderFormNote.d.ts +8 -0
- package/dist/staff/OrderFormNote.js +8 -0
- package/dist/staff/OrdersMenuNote.d.ts +8 -0
- package/dist/staff/OrdersMenuNote.js +8 -0
- package/dist/staff/RegimenChoiceNote.d.ts +7 -0
- package/dist/staff/RegimenChoiceNote.js +8 -0
- package/dist/staff/features.d.ts +9 -0
- package/dist/staff/features.js +8 -0
- package/dist/staff/index.d.ts +11 -0
- package/dist/staff/index.js +7 -0
- package/dist/ui/Bubble.d.ts +5 -0
- package/dist/ui/Bubble.js +9 -0
- package/dist/ui/CardActions.d.ts +34 -0
- package/dist/ui/CardActions.js +28 -0
- package/dist/ui/Conversation.d.ts +69 -0
- package/dist/ui/Conversation.js +192 -0
- package/dist/ui/Markdown.d.ts +11 -0
- package/dist/ui/Markdown.js +51 -0
- package/dist/ui/NoteFold.d.ts +19 -0
- package/dist/ui/NoteFold.js +12 -0
- package/dist/ui/NoteViewControl.d.ts +19 -0
- package/dist/ui/NoteViewControl.js +20 -0
- package/dist/ui/OrderForm.d.ts +71 -0
- package/dist/ui/OrderForm.js +118 -0
- package/dist/ui/OrdersMenu.d.ts +71 -0
- package/dist/ui/OrdersMenu.js +128 -0
- package/dist/ui/RegimenChoice.d.ts +23 -0
- package/dist/ui/RegimenChoice.js +16 -0
- package/dist/ui/SkipAvatar.d.ts +7 -0
- package/dist/ui/SkipAvatar.js +8 -0
- package/dist/ui/StaffButton.d.ts +18 -0
- package/dist/ui/StaffButton.js +17 -0
- package/dist/ui/Welcome.d.ts +91 -0
- package/dist/ui/Welcome.js +128 -0
- package/dist/ui/index.d.ts +8 -0
- package/dist/ui/index.js +7 -0
- package/dist/ui/parts.d.ts +38 -0
- package/dist/ui/parts.js +6 -0
- package/package.json +115 -4
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
// The Order form's rules: the SIG and dispense amount it fills in, and the order note it posts. usrx stages the
|
|
2
|
+
// prescriptions from the note's content_attributes.usrx_order, which keeps Treat's ids (joinskips/usrx#22). Then the
|
|
3
|
+
// Orders menu's rules for the cards and orders usrx reads from Treat.
|
|
4
|
+
import { isNumber, isObject, isString } from "./skipsMessage.js";
|
|
5
|
+
import { isUsrxNote } from "./usrxNote.js";
|
|
6
|
+
export const ORDER_VERSION = 2;
|
|
7
|
+
// Treat's plain as-needed frequency states no count, so the form asks for the most times a day.
|
|
8
|
+
export const AS_NEEDED = 'PRN';
|
|
9
|
+
// Treat names a frequency "TWICE DAILY (BID)" or "EVERY 4 TO 6 HOURS (Q4-6H)".
|
|
10
|
+
const CODED = /^(.*?)\s*\(([^()\s]+)\)\s*$/;
|
|
11
|
+
export function frequencyCode(name) {
|
|
12
|
+
return CODED.exec(name ?? '')?.[2] ?? '';
|
|
13
|
+
}
|
|
14
|
+
function frequencyWords(name) {
|
|
15
|
+
// A name that is only its code, "(QD)", keeps its name.
|
|
16
|
+
const words = CODED.exec(name)?.[1] ?? name;
|
|
17
|
+
return (words === '' ? name : words).toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
const positive = (value) => Number(value) > 0;
|
|
20
|
+
/** Quantity + Dose + Frequency + Duration, in that order, or empty until the first three are given. */
|
|
21
|
+
export function sigText({ quantity, doseUnit, frequency, days }) {
|
|
22
|
+
if (!positive(quantity) || !doseUnit || !frequency)
|
|
23
|
+
return '';
|
|
24
|
+
const course = positive(days) ? `for ${String(days)} days` : '';
|
|
25
|
+
return [String(quantity), doseUnit, frequencyWords(frequency), course].filter(Boolean).join(' ');
|
|
26
|
+
}
|
|
27
|
+
const INTERVAL_DAYS = [2, 3, 7, 14];
|
|
28
|
+
const CUT_RATES = INTERVAL_DAYS.flatMap((n) => Array.from({ length: n - 1 }, (_, i) => [i + 1, n]));
|
|
29
|
+
// Treat cuts a count to two places (a week's 1/7 is 0.14), so a count under 1 is read back as the k/n it was cut from,
|
|
30
|
+
// over the intervals Treat's frequencies use.
|
|
31
|
+
export function exactRate(perDay) {
|
|
32
|
+
return CUT_RATES.find(([k, n]) => Math.floor((100 * k) / n) / 100 === perDay) ?? [perDay, 1];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Quantity x the doses the course holds: a dose on its first day, then one each interval (a weekly dose over 30 days
|
|
36
|
+
* is 5). For plain as needed the doses a day are the most allowed. Empty when the inputs give no amount.
|
|
37
|
+
*/
|
|
38
|
+
export function dispenseAmount({ quantity, frequency, perDay, days, maxPerDay }) {
|
|
39
|
+
const doses = frequencyCode(frequency) === AS_NEEDED ? Number(maxPerDay) : Number(perDay);
|
|
40
|
+
if (!positive(doses) || !positive(quantity) || !positive(days))
|
|
41
|
+
return '';
|
|
42
|
+
const [k, n] = exactRate(doses);
|
|
43
|
+
const amount = Number(quantity) * Math.ceil(Number(((k * Number(days)) / n).toFixed(6)));
|
|
44
|
+
// Liquid and pen doses are fractions of a mL, and 0.1 x 3 is 0.30000000000000004 in floating point.
|
|
45
|
+
return String(Number(amount.toFixed(3)));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The dispense amount the form filled in follows a new computed one, which may be '' when the inputs no longer give
|
|
49
|
+
* one. A number the provider typed over it stays. Compared as text, since a number field gives a number.
|
|
50
|
+
*/
|
|
51
|
+
export function nextDispenseAmount({ current, lastFilled, computed }) {
|
|
52
|
+
const shown = String(current ?? '');
|
|
53
|
+
return shown === '' || shown === String(lastFilled ?? '') ? computed : current;
|
|
54
|
+
}
|
|
55
|
+
/** What the SIG is computed from, so a card can keep a SIG typed in Treat until one of these changes. */
|
|
56
|
+
export function sigInputs(item) {
|
|
57
|
+
return [item.quantity, item.doseUnitId, item.frequencyId, item.days].map((value) => String(value ?? '')).join('|');
|
|
58
|
+
}
|
|
59
|
+
/** A staged card as one of the form's medicines. */
|
|
60
|
+
export function itemFromCard(card) {
|
|
61
|
+
return {
|
|
62
|
+
term: card.drugName,
|
|
63
|
+
drug: { ddid: card.ddid, name: card.drugName, details: card.drugDetails, controlled: false },
|
|
64
|
+
doseUnitId: card.doseUnitId,
|
|
65
|
+
quantity: card.quantity,
|
|
66
|
+
frequencyId: card.frequencyId,
|
|
67
|
+
days: card.days,
|
|
68
|
+
dispenseUnitId: card.dispenseUnitId,
|
|
69
|
+
dispenseAmount: card.dispenseAmount,
|
|
70
|
+
refills: card.refills,
|
|
71
|
+
pharmacyNotes: card.pharmacyNotes,
|
|
72
|
+
earliestFillDate: card.earliestFillDate,
|
|
73
|
+
substituteOk: card.substituteOk !== false,
|
|
74
|
+
cardSig: card.sig,
|
|
75
|
+
cardSigInputs: sigInputs(card),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Only what the provider changed goes to usrx, which keeps the rest as Treat holds it. A number field gives a number. */
|
|
79
|
+
export function changedFields(card, item) {
|
|
80
|
+
const now = {
|
|
81
|
+
ddid: item.drug?.ddid,
|
|
82
|
+
quantity: item.quantity,
|
|
83
|
+
doseUnitId: item.doseUnitId,
|
|
84
|
+
frequencyId: item.frequencyId,
|
|
85
|
+
days: item.days,
|
|
86
|
+
sig: item.sig,
|
|
87
|
+
dispenseAmount: item.dispenseAmount,
|
|
88
|
+
dispenseUnitId: item.dispenseUnitId,
|
|
89
|
+
refills: item.refills,
|
|
90
|
+
substituteOk: item.substituteOk,
|
|
91
|
+
pharmacyNotes: item.pharmacyNotes,
|
|
92
|
+
earliestFillDate: item.earliestFillDate,
|
|
93
|
+
};
|
|
94
|
+
const held = {
|
|
95
|
+
ddid: card.ddid,
|
|
96
|
+
quantity: card.quantity,
|
|
97
|
+
doseUnitId: card.doseUnitId,
|
|
98
|
+
frequencyId: card.frequencyId,
|
|
99
|
+
days: card.days,
|
|
100
|
+
sig: card.sig,
|
|
101
|
+
dispenseAmount: card.dispenseAmount,
|
|
102
|
+
dispenseUnitId: card.dispenseUnitId,
|
|
103
|
+
refills: card.refills,
|
|
104
|
+
substituteOk: card.substituteOk !== false,
|
|
105
|
+
pharmacyNotes: card.pharmacyNotes,
|
|
106
|
+
earliestFillDate: card.earliestFillDate,
|
|
107
|
+
};
|
|
108
|
+
const changed = Object.fromEntries(Object.entries(now).filter(([name, value]) => String(value ?? '') !== String(held[name] ?? '')));
|
|
109
|
+
// usrx needs a new drug's name with its id.
|
|
110
|
+
return changed.ddid ? { ...changed, drugName: item.drug?.name } : changed;
|
|
111
|
+
}
|
|
112
|
+
const isWhole = (value) => /^\d+$/.test(String(value ?? '').trim());
|
|
113
|
+
/** What usrx cannot stage without (joinskips/usrx#22, REQUIRED). */
|
|
114
|
+
export function isComplete(item) {
|
|
115
|
+
return Boolean(item.drug &&
|
|
116
|
+
item.doseUnit &&
|
|
117
|
+
positive(item.quantity) &&
|
|
118
|
+
item.frequency &&
|
|
119
|
+
item.sig &&
|
|
120
|
+
item.dispenseUnit &&
|
|
121
|
+
positive(item.dispenseAmount) &&
|
|
122
|
+
isWhole(item.refills) &&
|
|
123
|
+
item.indication?.trim() !== '');
|
|
124
|
+
}
|
|
125
|
+
// Treat's note to the pharmacy is one line, and usrx joins the lines it adds there with "; " (usrx treat/pharmacy-notes.ts).
|
|
126
|
+
export function oneLine(text) {
|
|
127
|
+
return (text ?? '')
|
|
128
|
+
.split(/\s*\n\s*/)
|
|
129
|
+
.filter(Boolean)
|
|
130
|
+
.join('; ');
|
|
131
|
+
}
|
|
132
|
+
// Treat lists thousands of pharmacies for a zip, so the form shows the nearest that hold the words.
|
|
133
|
+
export const SHOWN_PHARMACIES = 50;
|
|
134
|
+
// Treat's pharmacy search takes only a place, so the words filter its list here, as Treat's own page does (usrx
|
|
135
|
+
// treat/search-pharmacy/filter.ts): every word is in the name or address.
|
|
136
|
+
export function pharmacyMatches(pharmacy, words) {
|
|
137
|
+
const text = `${pharmacy.name} ${pharmacy.address}`.toLowerCase();
|
|
138
|
+
return (words ?? '')
|
|
139
|
+
.toLowerCase()
|
|
140
|
+
.split(/\s+/)
|
|
141
|
+
.filter(Boolean)
|
|
142
|
+
.every((word) => text.includes(word));
|
|
143
|
+
}
|
|
144
|
+
// Version 2 gives each medicine its own pharmacy, and each round of a medicine sent in rounds its set and number.
|
|
145
|
+
export function buildOrder({ items, patientUid }) {
|
|
146
|
+
return {
|
|
147
|
+
version: ORDER_VERSION,
|
|
148
|
+
...(patientUid ? { patientUid } : {}),
|
|
149
|
+
items: items.map(orderItem),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/** One medicine of an order note, which a queued medicine is also saved as (joinskips/usrx#123). */
|
|
153
|
+
export function orderItem(item) {
|
|
154
|
+
return {
|
|
155
|
+
pharmacy: {
|
|
156
|
+
ncpdp: item.pharmacy.ncpdpid,
|
|
157
|
+
name: item.pharmacy.name,
|
|
158
|
+
address: item.pharmacy.address,
|
|
159
|
+
phone: item.pharmacy.phone,
|
|
160
|
+
},
|
|
161
|
+
...(item.round ? { set: item.set, round: item.round } : {}),
|
|
162
|
+
drug: { ddid: item.drug.ddid, name: item.drug.name },
|
|
163
|
+
dose: { amount: String(item.quantity), unitId: item.doseUnit.id, unitLabel: item.doseUnit.name },
|
|
164
|
+
frequency: { id: item.frequency.id, label: item.frequency.name },
|
|
165
|
+
days: String(item.days ?? ''),
|
|
166
|
+
sig: item.sig,
|
|
167
|
+
dispense: {
|
|
168
|
+
amount: String(item.dispenseAmount),
|
|
169
|
+
unitId: item.dispenseUnit.id,
|
|
170
|
+
unitLabel: item.dispenseUnit.name,
|
|
171
|
+
},
|
|
172
|
+
refills: String(item.refills).trim(),
|
|
173
|
+
earliestFillDate: item.earliestFillDate ?? '',
|
|
174
|
+
noteToPharmacy: item.pharmacyNotes ?? '',
|
|
175
|
+
substituteOk: item.substituteOk !== false,
|
|
176
|
+
// shortcut: a refill or re-order asks no indication, so usrx stages it as before, until past orders read theirs back.
|
|
177
|
+
...(item.indication === undefined ? {} : { indication: item.indication.trim() }),
|
|
178
|
+
...(item.discontinueDuplicate ? { discontinueDuplicate: true } : {}),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/** The note's text: the order in plain words, for the people reading the conversation. */
|
|
182
|
+
export function noteText(order) {
|
|
183
|
+
const lines = ['Medication order'];
|
|
184
|
+
order.items.forEach((item, index) => {
|
|
185
|
+
const { pharmacy } = item;
|
|
186
|
+
lines.push('', `${String(index + 1)}. ${item.drug.name}`, `Pharmacy: ${pharmacy.name}, ${pharmacy.address} (NCPDP ${pharmacy.ncpdp})`, `SIG: ${item.sig}`, `Dispense: ${item.dispense.amount} ${item.dispense.unitLabel}, refills ${item.refills}`);
|
|
187
|
+
if (item.earliestFillDate)
|
|
188
|
+
lines.push(`Earliest fill date: ${item.earliestFillDate}`);
|
|
189
|
+
if (item.noteToPharmacy)
|
|
190
|
+
lines.push(`Pharmacy notes: ${item.noteToPharmacy}`);
|
|
191
|
+
});
|
|
192
|
+
return lines.join('\n');
|
|
193
|
+
}
|
|
194
|
+
const ROUND_START = /^Round \d+ of \d+\.?\s*/;
|
|
195
|
+
/**
|
|
196
|
+
* A round's Pharmacy Notes start with which round it is, so the pharmacy knows which it fills. The provider's own words
|
|
197
|
+
* follow, and a medicine back to one round loses the start.
|
|
198
|
+
*/
|
|
199
|
+
export function roundNote(notes, round, rounds) {
|
|
200
|
+
const own = (notes ?? '').replace(ROUND_START, '');
|
|
201
|
+
if (rounds < 2)
|
|
202
|
+
return own;
|
|
203
|
+
const start = `Round ${String(round)} of ${String(rounds)}`;
|
|
204
|
+
return own ? `${start}. ${own}` : start;
|
|
205
|
+
}
|
|
206
|
+
/** How a staged card reads in the Orders menu: drug and strength, then the whole sig, which tells two cards of one drug apart. */
|
|
207
|
+
export function cardWords(card) {
|
|
208
|
+
return [card.drugName, card.sig].filter(Boolean).join(': ');
|
|
209
|
+
}
|
|
210
|
+
// staged-cards marks a medicine that waits for its pharmacy's encounter, which cannot be sent yet (joinskips/usrx#123).
|
|
211
|
+
export const CARD_STATUS = { STAGED: 'staged', QUEUED: 'queued' };
|
|
212
|
+
export function isQueued(card) {
|
|
213
|
+
return card.status === CARD_STATUS.QUEUED;
|
|
214
|
+
}
|
|
215
|
+
const twoDigits = (value) => String(value).padStart(2, '0');
|
|
216
|
+
/** Today where the device is, as YYYY-MM-DD, the form a supply's end day comes in and is compared in. */
|
|
217
|
+
export function localDay(now = new Date()) {
|
|
218
|
+
return `${String(now.getFullYear())}-${twoDigits(now.getMonth() + 1)}-${twoDigits(now.getDate())}`;
|
|
219
|
+
}
|
|
220
|
+
// usrx ends a refusal that Treat's own screen settles with that screen's link (usrx jobs/update-card.ts inTreat).
|
|
221
|
+
export const OPEN_IN_TREAT = 'Open in Treat:';
|
|
222
|
+
export function refusalParts(why) {
|
|
223
|
+
const words = why ?? '';
|
|
224
|
+
const at = words.lastIndexOf(` ${OPEN_IN_TREAT} `);
|
|
225
|
+
if (at < 0)
|
|
226
|
+
return { text: words, link: '' };
|
|
227
|
+
return { text: words.slice(0, at), link: words.slice(at + ` ${OPEN_IN_TREAT}`.length).trim() };
|
|
228
|
+
}
|
|
229
|
+
/** A calendar day (YYYY-MM-DD) in the viewer's own date words, read as that day wherever the viewer is. */
|
|
230
|
+
export function dayWords(day) {
|
|
231
|
+
return new Date(`${day}T00:00:00`).toLocaleDateString();
|
|
232
|
+
}
|
|
233
|
+
// A sent order's statuses, for the Past orders filter and its tags. One can carry two, such as Cancelled and Discontinued.
|
|
234
|
+
export const ORDER_STATUS = {
|
|
235
|
+
CURRENT: 'current',
|
|
236
|
+
COMPLETED: 'completed',
|
|
237
|
+
CANCELLED: 'cancelled',
|
|
238
|
+
DISCONTINUED: 'discontinued',
|
|
239
|
+
};
|
|
240
|
+
const endOf = (order) => order.set?.endsOn ?? order.supplyEndsOn;
|
|
241
|
+
/** An order whose end could not be counted has not run out. */
|
|
242
|
+
export function supplyRunning(order, today) {
|
|
243
|
+
const end = endOf(order);
|
|
244
|
+
return !end || end >= today;
|
|
245
|
+
}
|
|
246
|
+
export function orderStatuses(order, today) {
|
|
247
|
+
let status = ORDER_STATUS.COMPLETED;
|
|
248
|
+
if (order.cancelled)
|
|
249
|
+
status = ORDER_STATUS.CANCELLED;
|
|
250
|
+
else if (supplyRunning(order, today))
|
|
251
|
+
status = ORDER_STATUS.CURRENT;
|
|
252
|
+
return order.discontinued ? [status, ORDER_STATUS.DISCONTINUED] : [status];
|
|
253
|
+
}
|
|
254
|
+
/** 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. */
|
|
255
|
+
export function orderRows(orders) {
|
|
256
|
+
const rows = [];
|
|
257
|
+
const sets = new Map();
|
|
258
|
+
for (const order of orders) {
|
|
259
|
+
const set = order.set;
|
|
260
|
+
if (!set?.key) {
|
|
261
|
+
rows.push({ key: `${order.uid}-${order.sentAt}`, orders: [order], set: null });
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
let row = sets.get(set.key);
|
|
265
|
+
if (!row) {
|
|
266
|
+
row = { key: set.key, orders: [], set };
|
|
267
|
+
sets.set(set.key, row);
|
|
268
|
+
rows.push(row);
|
|
269
|
+
}
|
|
270
|
+
row.orders.push(order);
|
|
271
|
+
}
|
|
272
|
+
for (const row of sets.values())
|
|
273
|
+
row.orders.sort((a, b) => Number(a.set?.round) - Number(b.set?.round));
|
|
274
|
+
return rows;
|
|
275
|
+
}
|
|
276
|
+
/** A set's name is its drug's, with the strength each round changes left out. */
|
|
277
|
+
export function setName(row) {
|
|
278
|
+
return (row.orders[0]?.drugName ?? '').replace(/\s+\d.*$/, '');
|
|
279
|
+
}
|
|
280
|
+
/** The round running today: the first whose own supply has not run out. */
|
|
281
|
+
export function currentRound(row, today) {
|
|
282
|
+
return row.orders.find((order) => supplyRunning({ ...order, set: null }, today)) ?? null;
|
|
283
|
+
}
|
|
284
|
+
// Treat takes a cancel only within 48 hours of the send (usrx cancel_until), and not again while one is out.
|
|
285
|
+
const CANCEL_OUT = ['CANCEL_PENDING', 'CANCEL_SUCCESS'];
|
|
286
|
+
export function cancelOpen(order, now = new Date()) {
|
|
287
|
+
return (!order.cancelled &&
|
|
288
|
+
!CANCEL_OUT.includes(order.cancelStatus ?? '') &&
|
|
289
|
+
// No deadline parses as NaN, which is never after now.
|
|
290
|
+
Date.parse(String(order.cancelUntil)) > now.getTime());
|
|
291
|
+
}
|
|
292
|
+
/** The cards a row's Cancel Rx names: every round still open to a cancel. */
|
|
293
|
+
export function cancellableUids(row, now = new Date()) {
|
|
294
|
+
return row.orders.filter((order) => cancelOpen(order, now)).map((order) => order.uid);
|
|
295
|
+
}
|
|
296
|
+
// What Treat answered the Orders menu's Cancel Rx, as the row's badge (usrx jobs/cancel-rx.ts). A cancel the pharmacy
|
|
297
|
+
// took is Cancelled, a status of its own.
|
|
298
|
+
export const CANCEL_BADGES = { PENDING: 'pending', DENIED: 'denied', FAILED: 'failed' };
|
|
299
|
+
const BADGE_OF = new Map([
|
|
300
|
+
['CANCEL_PENDING', CANCEL_BADGES.PENDING],
|
|
301
|
+
['CANCEL_DENIED', CANCEL_BADGES.DENIED],
|
|
302
|
+
['CANCEL_FAILED', CANCEL_BADGES.FAILED],
|
|
303
|
+
['CANCEL_TRANS_FAILED', CANCEL_BADGES.FAILED],
|
|
304
|
+
['CANCEL_NWE', CANCEL_BADGES.FAILED],
|
|
305
|
+
]);
|
|
306
|
+
/** A row's badge for the cancel status usrx sent, or null for none to show. */
|
|
307
|
+
export function cancelBadge(cancelStatus) {
|
|
308
|
+
return BADGE_OF.get(cancelStatus ?? '') ?? null;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* The newest usrx note after a message id, by its id, which means Treat's cards may have changed: staged after a
|
|
312
|
+
* payment, sent, or changed. The notes already there when the menu first read Treat are not news, and neither is a
|
|
313
|
+
* provider's note that quotes the tag part way through.
|
|
314
|
+
*/
|
|
315
|
+
export function newestUsrxNote(messages, afterId) {
|
|
316
|
+
const news = (messages ?? []).flatMap(({ id, private: isPrivate, content }) => isPrivate && typeof id === 'number' && id > afterId && isUsrxNote(content) ? [id] : []);
|
|
317
|
+
return news.at(-1) ?? null;
|
|
318
|
+
}
|
|
319
|
+
/** The newest message the Skips App has numbered. A message still sending has a uuid. */
|
|
320
|
+
export function newestMessageId(messages) {
|
|
321
|
+
return Math.max(0, ...(messages ?? []).flatMap(({ id }) => (typeof id === 'number' ? [id] : [])));
|
|
322
|
+
}
|
|
323
|
+
// The messages a failed Treat lookup shows, one per problem staff can act on.
|
|
324
|
+
export const LOOKUP_MESSAGES = {
|
|
325
|
+
NOT_SET_UP: 'NOT_SET_UP',
|
|
326
|
+
TREAT_DOWN: 'TREAT_DOWN',
|
|
327
|
+
TERM_TOO_SHORT: 'TERM_TOO_SHORT',
|
|
328
|
+
NOT_A_ZIP: 'NOT_A_ZIP',
|
|
329
|
+
MAIL_ORDER_NOT_SET_UP: 'MAIL_ORDER_NOT_SET_UP',
|
|
330
|
+
CONTACT_INCOMPLETE: 'CONTACT_INCOMPLETE',
|
|
331
|
+
PATIENT_CHOICE: 'PATIENT_CHOICE',
|
|
332
|
+
CHART_PENDING: 'CHART_PENDING',
|
|
333
|
+
BAD_REQUEST: 'BAD_REQUEST',
|
|
334
|
+
SIGN_IN_REFUSED: 'SIGN_IN_REFUSED',
|
|
335
|
+
TREAT_UNAVAILABLE: 'TREAT_UNAVAILABLE',
|
|
336
|
+
TREAT_REFUSED: 'TREAT_REFUSED',
|
|
337
|
+
TREAT_REFUSED_NO_STATUS: 'TREAT_REFUSED_NO_STATUS',
|
|
338
|
+
LOOKUP_BUSY: 'LOOKUP_BUSY',
|
|
339
|
+
LOOKUP_FAILED: 'LOOKUP_FAILED',
|
|
340
|
+
};
|
|
341
|
+
// The reference staff quote, enough of the lookup's messageId to find its log line.
|
|
342
|
+
export const SHOWN_REF_LENGTH = 8;
|
|
343
|
+
const REASON_MESSAGES = new Map([
|
|
344
|
+
['term-too-short', LOOKUP_MESSAGES.TERM_TOO_SHORT],
|
|
345
|
+
['not-a-zip', LOOKUP_MESSAGES.NOT_A_ZIP],
|
|
346
|
+
['mail-order-not-set-up', LOOKUP_MESSAGES.MAIL_ORDER_NOT_SET_UP],
|
|
347
|
+
['contact-incomplete', LOOKUP_MESSAGES.CONTACT_INCOMPLETE],
|
|
348
|
+
['patient-choice', LOOKUP_MESSAGES.PATIENT_CHOICE],
|
|
349
|
+
['chart-pending', LOOKUP_MESSAGES.CHART_PENDING],
|
|
350
|
+
['not-a-ddid', LOOKUP_MESSAGES.BAD_REQUEST],
|
|
351
|
+
['unknown-lookup', LOOKUP_MESSAGES.BAD_REQUEST],
|
|
352
|
+
['no-conversation', LOOKUP_MESSAGES.BAD_REQUEST],
|
|
353
|
+
['bad-request', LOOKUP_MESSAGES.BAD_REQUEST],
|
|
354
|
+
['treat-sign-in-refused', LOOKUP_MESSAGES.SIGN_IN_REFUSED],
|
|
355
|
+
['treat-unavailable', LOOKUP_MESSAGES.TREAT_UNAVAILABLE],
|
|
356
|
+
['lookup-busy', LOOKUP_MESSAGES.LOOKUP_BUSY],
|
|
357
|
+
]);
|
|
358
|
+
/**
|
|
359
|
+
* What treat_lookups answered for a failed lookup (skips-app patch 170), as the message to show and its values. Null
|
|
360
|
+
* for any other error, which the form does not explain.
|
|
361
|
+
*/
|
|
362
|
+
export function lookupFailure(answer) {
|
|
363
|
+
if (!isObject(answer))
|
|
364
|
+
return null;
|
|
365
|
+
const reason = isString(answer.reason) ? answer.reason : undefined;
|
|
366
|
+
const status = isNumber(answer.treat_status) ? answer.treat_status : undefined;
|
|
367
|
+
const failure = (message) => ({
|
|
368
|
+
message,
|
|
369
|
+
code: reason ?? 'unknown',
|
|
370
|
+
status,
|
|
371
|
+
ref: (isString(answer.ref) ? answer.ref : '').slice(0, SHOWN_REF_LENGTH),
|
|
372
|
+
});
|
|
373
|
+
if (answer.error === 'treat-lookup-not-configured')
|
|
374
|
+
return failure(LOOKUP_MESSAGES.NOT_SET_UP);
|
|
375
|
+
if (answer.error === 'treat-unavailable')
|
|
376
|
+
return failure(LOOKUP_MESSAGES.TREAT_DOWN);
|
|
377
|
+
if (answer.error !== 'treat-lookup-failed')
|
|
378
|
+
return null;
|
|
379
|
+
if (reason === 'treat-refused') {
|
|
380
|
+
return failure(status ? LOOKUP_MESSAGES.TREAT_REFUSED : LOOKUP_MESSAGES.TREAT_REFUSED_NO_STATUS);
|
|
381
|
+
}
|
|
382
|
+
return failure(REASON_MESSAGES.get(reason ?? '') ?? LOOKUP_MESSAGES.LOOKUP_FAILED);
|
|
383
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Who on Skips' side posted a line: a care team member, or the Skips App user or bot Skip's replies come from. */
|
|
2
|
+
export interface ChatAuthor {
|
|
3
|
+
id: number | null;
|
|
4
|
+
name: string;
|
|
5
|
+
avatarUrl: string | null;
|
|
6
|
+
bot: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ChatAttachment {
|
|
9
|
+
kind: 'image' | 'file';
|
|
10
|
+
url: string;
|
|
11
|
+
thumbUrl: string | null;
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
/** A photo or PDF the member picked, before it is sent. The web's picker gives the file itself. */
|
|
15
|
+
export interface PickedFile {
|
|
16
|
+
uri: string;
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
size: number;
|
|
20
|
+
file?: Blob;
|
|
21
|
+
}
|
|
22
|
+
/** One answer a question from Skips offers: the words on its button, and the value the Skips App keeps. */
|
|
23
|
+
export interface ChoiceItem {
|
|
24
|
+
title: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}
|
|
27
|
+
/** A question answered with one of its buttons. `chosen` is the answer's value, or null while there is none. */
|
|
28
|
+
export interface MessageChoice {
|
|
29
|
+
items: ChoiceItem[];
|
|
30
|
+
chosen: string | null;
|
|
31
|
+
}
|
|
32
|
+
export interface ChatMessage {
|
|
33
|
+
id: number;
|
|
34
|
+
text: string;
|
|
35
|
+
sentAt: number;
|
|
36
|
+
mine: boolean;
|
|
37
|
+
notice: boolean;
|
|
38
|
+
author: ChatAuthor | null;
|
|
39
|
+
attachments: ChatAttachment[];
|
|
40
|
+
choice?: MessageChoice;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether a line from Skips is Skip's: one with no author, a bot's, or one from the Skips App user Skip's replies are
|
|
44
|
+
* posted as. A person on the care team is none of these.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isSkip(message: Pick<ChatMessage, 'mine' | 'author'>, skipUserId: number | null): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// A message as the chat shows it. Each app maps its own Skips App API into this shape, so the chat never sees a
|
|
2
|
+
// private note or an event the member does not.
|
|
3
|
+
/**
|
|
4
|
+
* Whether a line from Skips is Skip's: one with no author, a bot's, or one from the Skips App user Skip's replies are
|
|
5
|
+
* posted as. A person on the care team is none of these.
|
|
6
|
+
*/
|
|
7
|
+
export function isSkip(message, skipUserId) {
|
|
8
|
+
if (message.mine)
|
|
9
|
+
return false;
|
|
10
|
+
const { author } = message;
|
|
11
|
+
return author === null || author.bot || author.id === null || author.id === skipUserId;
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type NoteView = 'all' | 'messages' | 'notes';
|
|
2
|
+
export declare const NOTE_VIEWS: Readonly<Record<'ALL' | 'MESSAGES' | 'NOTES', NoteView>>;
|
|
3
|
+
export declare const NOTE_VIEW_KEY = "skips.noteView";
|
|
4
|
+
export interface NoteViewMessage {
|
|
5
|
+
private?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function notesInView<Message extends NoteViewMessage>(messages: readonly Message[], view: NoteView): readonly Message[];
|
|
8
|
+
export interface ThreadLoad {
|
|
9
|
+
dataFetched?: boolean;
|
|
10
|
+
allMessagesLoaded?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface PanelSize {
|
|
13
|
+
scrollHeight: number;
|
|
14
|
+
clientHeight: number;
|
|
15
|
+
}
|
|
16
|
+
/** A view that does not fill the panel leaves nothing to scroll, so the thread loads earlier pages until it does. */
|
|
17
|
+
export declare function needsEarlierPage(view: NoteView, thread: ThreadLoad | null | undefined, panel: PanelSize | null | undefined): boolean;
|
|
18
|
+
export interface FillSteps {
|
|
19
|
+
needsMore: () => boolean;
|
|
20
|
+
count: () => number;
|
|
21
|
+
loadEarlier: () => Promise<unknown>;
|
|
22
|
+
/** Waits for the thread to draw what a load brought. */
|
|
23
|
+
settle: () => Promise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* One fill at a time per thread: each page it loads changes the list, which asks for another fill. A load that brings
|
|
27
|
+
* nothing ends it, so a failed or empty load never loops.
|
|
28
|
+
*/
|
|
29
|
+
export declare function noteViewFiller(): (steps: FillSteps) => Promise<void>;
|
|
30
|
+
export interface ViewStorage {
|
|
31
|
+
getItem: (key: string) => string | null;
|
|
32
|
+
setItem: (key: string, value: string) => void;
|
|
33
|
+
}
|
|
34
|
+
export declare function rememberedNoteView(storage?: ViewStorage): NoteView;
|
|
35
|
+
export declare function rememberNoteView(view: NoteView, storage?: ViewStorage): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export const NOTE_VIEWS = {
|
|
2
|
+
ALL: 'all',
|
|
3
|
+
MESSAGES: 'messages',
|
|
4
|
+
NOTES: 'notes',
|
|
5
|
+
};
|
|
6
|
+
export const NOTE_VIEW_KEY = 'skips.noteView';
|
|
7
|
+
const isNoteView = (value) => Object.values(NOTE_VIEWS).some((view) => view === value);
|
|
8
|
+
export function notesInView(messages, view) {
|
|
9
|
+
if (view === NOTE_VIEWS.MESSAGES)
|
|
10
|
+
return messages.filter((message) => !message.private);
|
|
11
|
+
if (view === NOTE_VIEWS.NOTES)
|
|
12
|
+
return messages.filter((message) => message.private);
|
|
13
|
+
return messages;
|
|
14
|
+
}
|
|
15
|
+
/** A view that does not fill the panel leaves nothing to scroll, so the thread loads earlier pages until it does. */
|
|
16
|
+
export function needsEarlierPage(view, thread, panel) {
|
|
17
|
+
return (view !== NOTE_VIEWS.ALL &&
|
|
18
|
+
thread?.dataFetched === true &&
|
|
19
|
+
!thread.allMessagesLoaded &&
|
|
20
|
+
panel != null &&
|
|
21
|
+
panel.scrollHeight <= panel.clientHeight);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* One fill at a time per thread: each page it loads changes the list, which asks for another fill. A load that brings
|
|
25
|
+
* nothing ends it, so a failed or empty load never loops.
|
|
26
|
+
*/
|
|
27
|
+
export function noteViewFiller() {
|
|
28
|
+
let running = false;
|
|
29
|
+
return async ({ needsMore, count, loadEarlier, settle }) => {
|
|
30
|
+
if (running)
|
|
31
|
+
return;
|
|
32
|
+
running = true;
|
|
33
|
+
try {
|
|
34
|
+
while (needsMore()) {
|
|
35
|
+
const loaded = count();
|
|
36
|
+
await loadEarlier();
|
|
37
|
+
await settle();
|
|
38
|
+
if (count() === loaded)
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
running = false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Storage can be blocked or hold anything, so a value that is not a view reads as all. Reading localStorage itself
|
|
48
|
+
// throws where site data is blocked, and there is none in React Native, so it is read inside the try.
|
|
49
|
+
export function rememberedNoteView(storage) {
|
|
50
|
+
try {
|
|
51
|
+
const view = (storage ?? localStorage).getItem(NOTE_VIEW_KEY);
|
|
52
|
+
return isNoteView(view) ? view : NOTE_VIEWS.ALL;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return NOTE_VIEWS.ALL;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function rememberNoteView(view, storage) {
|
|
59
|
+
try {
|
|
60
|
+
(storage ?? localStorage).setItem(NOTE_VIEW_KEY, view);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// A blocked storage keeps the choice for this page only.
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { type CardFields, type Drug, type FieldValue, type LookupFailure, type OrderItem, type PastOrder, type Pharmacy, type ReadyItem, type StagedCard, type TreatOption, type UsrxOrderItem } from './medicationOrder.ts';
|
|
2
|
+
/** usrx's drug search answers a term of at least this many letters. */
|
|
3
|
+
export declare const SHORTEST_TERM = 3;
|
|
4
|
+
/** The pause in typing after which the drug search runs. */
|
|
5
|
+
export declare const TYPING_PAUSE_MS = 300;
|
|
6
|
+
/** A frequency with the doses a day Treat gives it (usrx's drug options, count). */
|
|
7
|
+
export interface FrequencyOption extends TreatOption {
|
|
8
|
+
count?: number;
|
|
9
|
+
}
|
|
10
|
+
/** What Treat offers for a drug's dose, frequency and dispense unit. */
|
|
11
|
+
export interface DrugChoices {
|
|
12
|
+
ddid: string;
|
|
13
|
+
doseUnits: TreatOption[];
|
|
14
|
+
frequencies: FrequencyOption[];
|
|
15
|
+
dispenseUnits: TreatOption[];
|
|
16
|
+
}
|
|
17
|
+
/** One round of a medicine, as the provider fills it in. */
|
|
18
|
+
export interface FormItem extends OrderItem {
|
|
19
|
+
key: string;
|
|
20
|
+
term: string;
|
|
21
|
+
found: Drug[];
|
|
22
|
+
searching: boolean;
|
|
23
|
+
loadingChoices: boolean;
|
|
24
|
+
choices: DrugChoices | null;
|
|
25
|
+
doseUnitId: FieldValue;
|
|
26
|
+
frequencyId: FieldValue;
|
|
27
|
+
days: FieldValue;
|
|
28
|
+
dispenseUnitId: FieldValue;
|
|
29
|
+
maxPerDay: FieldValue;
|
|
30
|
+
/** The dispense amount the form last filled in, which it keeps following until the provider types over it. */
|
|
31
|
+
filledAmount: FieldValue;
|
|
32
|
+
}
|
|
33
|
+
export declare function newItem(key: string): FormItem;
|
|
34
|
+
/** A sent order read as the card it was sent from, which usrx keeps with it. */
|
|
35
|
+
export declare function cardOfOrder(order: PastOrder): StagedCard;
|
|
36
|
+
export declare function isPastOrder(card: StagedCard | PastOrder): card is PastOrder;
|
|
37
|
+
/** A staged card opened to change, its fields as Treat holds them. */
|
|
38
|
+
export declare function cardItem(card: StagedCard, key: string): FormItem;
|
|
39
|
+
/** A sent order to order again: a new order with no fill date and no round start, which the form numbers again. */
|
|
40
|
+
export declare function reorderItem(card: StagedCard, key: string): FormItem;
|
|
41
|
+
export declare function frequencyOf(item: FormItem): FrequencyOption | null;
|
|
42
|
+
/** Plain as needed states no count, so the form asks for the most times a day. */
|
|
43
|
+
export declare function isAsNeeded(item: FormItem): boolean;
|
|
44
|
+
export interface ResolvedItem extends OrderItem {
|
|
45
|
+
sig: string;
|
|
46
|
+
}
|
|
47
|
+
/** The item with its chosen options, its one-line notes and its SIG, which a SIG typed in Treat keeps until its inputs change. */
|
|
48
|
+
export declare function resolved(item: FormItem): ResolvedItem;
|
|
49
|
+
export declare function computedAmount(item: FormItem): string;
|
|
50
|
+
/** The search that listed a picked pharmacy, kept apart from the fields, which can change after the pick. */
|
|
51
|
+
export interface PickedWith {
|
|
52
|
+
zip: string;
|
|
53
|
+
words: string;
|
|
54
|
+
mailOrder: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** A medicine's pharmacy search and the pharmacy picked from it. */
|
|
57
|
+
export interface Picker {
|
|
58
|
+
zip: string;
|
|
59
|
+
words: string;
|
|
60
|
+
mailOrder: boolean;
|
|
61
|
+
/** Every pharmacy Treat lists for the zip or for mail order, nearest first, or null before an answer. */
|
|
62
|
+
pharmacies: Pharmacy[] | null;
|
|
63
|
+
pharmacy: Pharmacy | null;
|
|
64
|
+
pickedWith: PickedWith | null;
|
|
65
|
+
}
|
|
66
|
+
export declare function newPicker(): Picker;
|
|
67
|
+
/** The place a search is for. The words only filter its answer, so they never search again. */
|
|
68
|
+
export declare function placeOf(picker: Picker): string;
|
|
69
|
+
export declare function canSearchPharmacies(picker: Picker): boolean;
|
|
70
|
+
export declare function shownPharmacies(picker: Picker): Pharmacy[];
|
|
71
|
+
export declare function picked(picker: Picker, pharmacy: Pharmacy): Picker;
|
|
72
|
+
/** A card's new pharmacy, which usrx finds again by the search that listed it (joinskips/usrx#99). */
|
|
73
|
+
export interface PharmacyChange {
|
|
74
|
+
ncpdp_id: string;
|
|
75
|
+
zip?: string;
|
|
76
|
+
search_text: string;
|
|
77
|
+
mail_order: boolean;
|
|
78
|
+
}
|
|
79
|
+
export declare function pharmacyChange(picker: Picker): PharmacyChange | null;
|
|
80
|
+
/** A medicine with its rounds, one unless it is sent in rounds, and its own pharmacy search. */
|
|
81
|
+
export interface Medicine {
|
|
82
|
+
key: string;
|
|
83
|
+
rounds: FormItem[];
|
|
84
|
+
picker: Picker;
|
|
85
|
+
}
|
|
86
|
+
/** A medicine after the first follows the first one's pharmacy until it picks its own. */
|
|
87
|
+
export declare function pharmacyOf(medicines: readonly Medicine[], medicine: Medicine): Pharmacy | null;
|
|
88
|
+
/** Each round's notes start with which round it is, once a medicine has two or more. */
|
|
89
|
+
export declare function renumbered(rounds: readonly FormItem[]): FormItem[];
|
|
90
|
+
/**
|
|
91
|
+
* A new order's items, every round complete and going to its medicine's pharmacy, or null while any is not. A medicine
|
|
92
|
+
* in rounds is one set, numbered from 1, and a one-round medicine has none.
|
|
93
|
+
*/
|
|
94
|
+
export declare function newOrderItems(medicines: readonly Medicine[]): ReadyItem[] | null;
|
|
95
|
+
export declare const CAN_BE_BLANK: readonly string[];
|
|
96
|
+
/** A staged card's changes, or null while there are none, the choices have not loaded, or a changed field is blank. */
|
|
97
|
+
export declare function cardChanges(card: StagedCard, item: FormItem, picker: Picker): CardFields | null;
|
|
98
|
+
/** A queued medicine is saved whole, so it is one a new order could stage, changed and with a pharmacy. */
|
|
99
|
+
export declare function queuedChange(card: StagedCard, item: FormItem, picker: Picker): UsrxOrderItem | null;
|
|
100
|
+
/** The fields usrx can name in a refusal, and the input each opens the form at. */
|
|
101
|
+
export type FocusField = 'pharmacy' | 'quantity' | 'doseUnit' | 'frequency' | 'dispenseAmount' | 'dispenseUnit';
|
|
102
|
+
/** The input a refusal's field opens at: the SIG's first input for any field the form does not name. */
|
|
103
|
+
export declare function focusField(focus: string): FocusField;
|
|
104
|
+
/** One of Treat's charts that fit the patient, with what tells them apart (usrx jobs/charts.ts). */
|
|
105
|
+
export interface TreatChart {
|
|
106
|
+
uid: string;
|
|
107
|
+
firstName: string;
|
|
108
|
+
lastName: string;
|
|
109
|
+
dob: string;
|
|
110
|
+
phoneEnding: string;
|
|
111
|
+
city: string;
|
|
112
|
+
zip: string;
|
|
113
|
+
lastVisit: string;
|
|
114
|
+
pharmacy: string;
|
|
115
|
+
}
|
|
116
|
+
export interface ChartsToPick {
|
|
117
|
+
charts: TreatChart[];
|
|
118
|
+
/** Treat's patient search, for a patient who is none of them. */
|
|
119
|
+
searchLink: string;
|
|
120
|
+
}
|
|
121
|
+
/** The charts Create asks staff to pick from: only when more than one fits, since usrx stages on a lone one itself. */
|
|
122
|
+
export declare function chartsToPick(answer: unknown): ChartsToPick;
|
|
123
|
+
/** What a Treat call that rejected shows: treat_lookups' answer when it is one, or that the lookup failed. */
|
|
124
|
+
export declare function lookupFailureOf(error: unknown): LookupFailure;
|
|
125
|
+
/** usrx's words for a change it refused, '' when it gave none, or null when it took the change. */
|
|
126
|
+
export declare function refusalOf(answer: unknown): string | null;
|