@photonhealth/react 2.0.0-rc.2 → 2.0.0-rc.4
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 +17 -1
- package/dist/analytics/PhotonAnalyticsProvider.d.ts +5 -2
- package/dist/analytics/PhotonAnalyticsProvider.d.ts.map +1 -1
- package/dist/analytics/PhotonAnalyticsProvider.js +34 -15
- package/dist/analytics/PhotonAnalyticsProvider.js.map +1 -1
- package/dist/analytics/cardLifecycle.d.ts +10 -0
- package/dist/analytics/cardLifecycle.d.ts.map +1 -0
- package/dist/analytics/cardLifecycle.js +43 -0
- package/dist/analytics/cardLifecycle.js.map +1 -0
- package/dist/analytics/lifecycleOutcomes.d.ts +8 -0
- package/dist/analytics/lifecycleOutcomes.d.ts.map +1 -0
- package/dist/analytics/lifecycleOutcomes.js +16 -0
- package/dist/analytics/lifecycleOutcomes.js.map +1 -0
- package/dist/analytics/tracker.d.ts +5 -3
- package/dist/analytics/tracker.d.ts.map +1 -1
- package/dist/analytics/tracker.js +10 -5
- package/dist/analytics/tracker.js.map +1 -1
- package/dist/components/PhotonOrder.d.ts +18 -18
- package/dist/components/PhotonOrder.d.ts.map +1 -1
- package/dist/components/PhotonOrder.js +17 -6
- package/dist/components/PhotonOrder.js.map +1 -1
- package/dist/components/PhotonPatient.d.ts +7 -35
- package/dist/components/PhotonPatient.d.ts.map +1 -1
- package/dist/components/PhotonPatient.js +3 -77
- package/dist/components/PhotonPatient.js.map +1 -1
- package/dist/components/PhotonPrescription.d.ts +14 -14
- package/dist/components/PhotonPrescription.d.ts.map +1 -1
- package/dist/components/PhotonPrescription.js +0 -1
- package/dist/components/PhotonPrescription.js.map +1 -1
- package/dist/components/open.d.ts +11 -13
- package/dist/components/open.d.ts.map +1 -1
- package/dist/components/open.js +7 -2
- package/dist/components/open.js.map +1 -1
- package/dist/components/patient/PatientCard/PatientCard.d.ts +30 -0
- package/dist/components/patient/PatientCard/PatientCard.d.ts.map +1 -0
- package/dist/components/patient/PatientCard/PatientCard.js +101 -0
- package/dist/components/patient/PatientCard/PatientCard.js.map +1 -0
- package/dist/components/patient/PatientCard/usePatientToShow.d.ts +22 -0
- package/dist/components/patient/PatientCard/usePatientToShow.d.ts.map +1 -0
- package/dist/components/patient/PatientCard/usePatientToShow.js +40 -0
- package/dist/components/patient/PatientCard/usePatientToShow.js.map +1 -0
- package/dist/components/patient/PatientIntakeForm.d.ts +16 -0
- package/dist/components/patient/PatientIntakeForm.d.ts.map +1 -0
- package/dist/components/patient/PatientIntakeForm.js +114 -0
- package/dist/components/patient/PatientIntakeForm.js.map +1 -0
- package/dist/components/patient/PatientSearch.d.ts +12 -0
- package/dist/components/patient/PatientSearch.d.ts.map +1 -0
- package/dist/components/patient/PatientSearch.js +148 -0
- package/dist/components/patient/PatientSearch.js.map +1 -0
- package/dist/components/patient/{Benefits.d.ts → PatientSummary/BenefitsInputForm.d.ts} +2 -2
- package/dist/components/patient/PatientSummary/BenefitsInputForm.d.ts.map +1 -0
- package/dist/components/patient/{Benefits.js → PatientSummary/BenefitsInputForm.js} +5 -5
- package/dist/components/patient/PatientSummary/BenefitsInputForm.js.map +1 -0
- package/dist/components/patient/{Clinical.d.ts → PatientSummary/ClinicalInputForm.d.ts} +13 -15
- package/dist/components/patient/PatientSummary/ClinicalInputForm.d.ts.map +1 -0
- package/dist/components/patient/{Clinical.js → PatientSummary/ClinicalInputForm.js} +11 -11
- package/dist/components/patient/PatientSummary/ClinicalInputForm.js.map +1 -0
- package/dist/components/patient/PatientSummary/CollapsedSummary.d.ts +5 -0
- package/dist/components/patient/PatientSummary/CollapsedSummary.d.ts.map +1 -0
- package/dist/components/patient/PatientSummary/CollapsedSummary.js +30 -0
- package/dist/components/patient/PatientSummary/CollapsedSummary.js.map +1 -0
- package/dist/components/patient/PatientSummary/PatientDetailsForm.d.ts +10 -0
- package/dist/components/patient/PatientSummary/PatientDetailsForm.d.ts.map +1 -0
- package/dist/components/patient/PatientSummary/PatientDetailsForm.js +65 -0
- package/dist/components/patient/PatientSummary/PatientDetailsForm.js.map +1 -0
- package/dist/components/patient/PatientSummary/PatientDetailsSchema.d.ts +53 -0
- package/dist/components/patient/PatientSummary/PatientDetailsSchema.d.ts.map +1 -0
- package/dist/components/patient/PatientSummary/PatientDetailsSchema.js +78 -0
- package/dist/components/patient/PatientSummary/PatientDetailsSchema.js.map +1 -0
- package/dist/components/patient/PatientSummary/PatientSummary.d.ts +46 -0
- package/dist/components/patient/PatientSummary/PatientSummary.d.ts.map +1 -0
- package/dist/components/patient/PatientSummary/PatientSummary.js +57 -0
- package/dist/components/patient/PatientSummary/PatientSummary.js.map +1 -0
- package/dist/components/patient/PatientSummary/SummaryHeader.d.ts +19 -0
- package/dist/components/patient/PatientSummary/SummaryHeader.d.ts.map +1 -0
- package/dist/components/patient/PatientSummary/SummaryHeader.js +22 -0
- package/dist/components/patient/PatientSummary/SummaryHeader.js.map +1 -0
- package/dist/components/patient/fields.d.ts +7 -25
- package/dist/components/patient/fields.d.ts.map +1 -1
- package/dist/components/patient/fields.js +11 -53
- package/dist/components/patient/fields.js.map +1 -1
- package/dist/components/patient/parsePatientSearchQuery.d.ts +16 -0
- package/dist/components/patient/parsePatientSearchQuery.d.ts.map +1 -0
- package/dist/components/patient/{query.js → parsePatientSearchQuery.js} +3 -15
- package/dist/components/patient/parsePatientSearchQuery.js.map +1 -0
- package/dist/components/prescription/PrescriptionCard.d.ts +14 -8
- package/dist/components/prescription/PrescriptionCard.d.ts.map +1 -1
- package/dist/components/prescription/PrescriptionCard.js +10 -3
- package/dist/components/prescription/PrescriptionCard.js.map +1 -1
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts +6 -6
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts.map +1 -1
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js +16 -8
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js.map +1 -1
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts +14 -1
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts.map +1 -1
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js +25 -7
- package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js.map +1 -1
- package/dist/components/schemaErrors.d.ts +3 -2
- package/dist/components/schemaErrors.d.ts.map +1 -1
- package/dist/components/schemaErrors.js +2 -1
- package/dist/components/schemaErrors.js.map +1 -1
- package/dist/components/search.d.ts +1 -1
- package/dist/components/search.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/meta/version.js +1 -1
- package/package.json +5 -2
- package/src/analytics/PhotonAnalyticsProvider.test.tsx +0 -1
- package/src/analytics/PhotonAnalyticsProvider.tsx +75 -20
- package/src/analytics/cardLifecycle.test.tsx +272 -0
- package/src/analytics/cardLifecycle.ts +44 -0
- package/src/analytics/fieldInteraction.test.tsx +11 -9
- package/src/analytics/lifecycleOutcomes.test.ts +78 -0
- package/src/analytics/lifecycleOutcomes.ts +29 -0
- package/src/analytics/tracker.test.ts +1 -1
- package/src/analytics/tracker.ts +13 -6
- package/src/analytics/usePhotonAnalytics.test.tsx +106 -0
- package/src/components/PhotonOrder.test.tsx +146 -8
- package/src/components/PhotonOrder.tsx +37 -26
- package/src/components/PhotonPatient.tsx +8 -163
- package/src/components/PhotonPrescription.test.tsx +22 -18
- package/src/components/PhotonPrescription.tsx +14 -14
- package/src/components/ScreeningAlerts.test.tsx +81 -0
- package/src/components/open.ts +13 -16
- package/src/components/order/DraftOrderPrompt.test.tsx +3 -6
- package/src/components/patient/PatientCard/PatientCard.test.tsx +255 -0
- package/src/components/patient/PatientCard/PatientCard.tsx +177 -0
- package/src/components/patient/PatientCard/usePatientToShow.ts +44 -0
- package/src/components/patient/PatientIntakeForm.test.tsx +262 -0
- package/src/components/patient/PatientIntakeForm.tsx +222 -0
- package/src/components/patient/PatientSearch.test.tsx +204 -0
- package/src/components/patient/PatientSearch.tsx +221 -0
- package/src/components/patient/PatientSummary/BenefitsInputForm.test.tsx +164 -0
- package/src/components/patient/{Benefits.tsx → PatientSummary/BenefitsInputForm.tsx} +4 -4
- package/src/components/patient/PatientSummary/ClinicalInputForm.test.tsx +247 -0
- package/src/components/patient/{Clinical.tsx → PatientSummary/ClinicalInputForm.tsx} +23 -23
- package/src/components/patient/PatientSummary/CollapsedSummary.test.tsx +90 -0
- package/src/components/patient/PatientSummary/CollapsedSummary.tsx +46 -0
- package/src/components/patient/PatientSummary/PatientDetailsForm.test.tsx +201 -0
- package/src/components/patient/PatientSummary/PatientDetailsForm.tsx +320 -0
- package/src/components/patient/PatientSummary/PatientDetailsSchema.test.ts +296 -0
- package/src/components/patient/PatientSummary/PatientDetailsSchema.ts +95 -0
- package/src/components/patient/PatientSummary/PatientSummary.test.tsx +194 -0
- package/src/components/patient/PatientSummary/PatientSummary.tsx +225 -0
- package/src/components/patient/PatientSummary/SummaryHeader.test.tsx +183 -0
- package/src/components/patient/PatientSummary/SummaryHeader.tsx +85 -0
- package/src/components/patient/fields.tsx +12 -138
- package/src/components/patient/parsePatientSearchQuery.test.ts +107 -0
- package/src/components/patient/{query.ts → parsePatientSearchQuery.ts} +4 -21
- package/src/components/prescription/PrescriptionCard.test.tsx +175 -12
- package/src/components/prescription/PrescriptionCard.tsx +28 -14
- package/src/components/prescription/PrescriptionDetailsForm/DirectionsInput.test.tsx +2 -5
- package/src/components/prescription/PrescriptionDetailsForm/DispenseInputs.test.tsx +3 -6
- package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.test.tsx +34 -37
- package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.tsx +24 -16
- package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.test.ts +166 -41
- package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.ts +41 -9
- package/src/components/prescription/PrescriptionDetailsForm/TemplatePicker.test.tsx +2 -5
- package/src/components/prescription/TreatmentSearch/TreatmentSearch.test.tsx +3 -7
- package/src/components/schemaErrors.ts +3 -2
- package/src/components/search.tsx +1 -1
- package/src/index.ts +1 -1
- package/src/meta/version.test.ts +1 -0
- package/src/meta/version.ts +1 -1
- package/dist/components/patient/Benefits.d.ts.map +0 -1
- package/dist/components/patient/Benefits.js.map +0 -1
- package/dist/components/patient/Clinical.d.ts.map +0 -1
- package/dist/components/patient/Clinical.js.map +0 -1
- package/dist/components/patient/IntakeForm.d.ts +0 -10
- package/dist/components/patient/IntakeForm.d.ts.map +0 -1
- package/dist/components/patient/IntakeForm.js +0 -333
- package/dist/components/patient/IntakeForm.js.map +0 -1
- package/dist/components/patient/Summary.d.ts +0 -48
- package/dist/components/patient/Summary.d.ts.map +0 -1
- package/dist/components/patient/Summary.js +0 -90
- package/dist/components/patient/Summary.js.map +0 -1
- package/dist/components/patient/query.d.ts +0 -37
- package/dist/components/patient/query.d.ts.map +0 -1
- package/dist/components/patient/query.js.map +0 -1
- package/src/components/patient/IntakeForm.test.tsx +0 -89
- package/src/components/patient/IntakeForm.tsx +0 -564
- package/src/components/patient/Summary.test.tsx +0 -106
- package/src/components/patient/Summary.tsx +0 -330
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { parsePatientSearchQuery } from "./parsePatientSearchQuery.ts";
|
|
3
|
+
|
|
4
|
+
describe("parsePatientSearchQuery", () => {
|
|
5
|
+
describe("parse names", () => {
|
|
6
|
+
it("one word: a first name", () => {
|
|
7
|
+
expect(parsePatientSearchQuery("Ada")).toEqual({ name: { first: "Ada" } });
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("two words: first name, then last name", () => {
|
|
11
|
+
expect(parsePatientSearchQuery("Ada Lovelace")).toEqual({ name: { first: "Ada", last: "Lovelace" } });
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("extra spaces: ignored", () => {
|
|
15
|
+
expect(parsePatientSearchQuery(" Ada Lovelace ")).toEqual({ name: { first: "Ada", last: "Lovelace" } });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("nothing typed: nothing parsed", () => {
|
|
19
|
+
expect(parsePatientSearchQuery(" ")).toEqual({});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("three words: the first word is the first name, the rest is the last name", () => {
|
|
23
|
+
expect(parsePatientSearchQuery("Mary Ann Smith")).toEqual({ name: { first: "Mary", last: "Ann Smith" } });
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe("parse dates of birth to YYYY-MM-DD format", () => {
|
|
28
|
+
it("YYYY-MM-DD format: supported", () => {
|
|
29
|
+
expect(parsePatientSearchQuery("1990-01-01")).toEqual({ dateOfBirth: "1990-01-01" });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("M/D/YYYY format: supported", () => {
|
|
33
|
+
expect(parsePatientSearchQuery("1/2/1990")).toEqual({ dateOfBirth: "1990-01-02" });
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("MM-DD-YYYY format: supported", () => {
|
|
37
|
+
expect(parsePatientSearchQuery("01-02-1990")).toEqual({ dateOfBirth: "1990-01-02" });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Pins today's behavior
|
|
41
|
+
// TODO: return nothing for impossible dates
|
|
42
|
+
it("an impossible date: still sent as a date", () => {
|
|
43
|
+
expect(parsePatientSearchQuery("13/45/1990")).toEqual({ dateOfBirth: "1990-13-45" });
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Pins today's behavior
|
|
47
|
+
// TODO: return nothing for unsupported date formats
|
|
48
|
+
it("a two-digit year or an unpadded YYYY-M-D: not supported read as a name", () => {
|
|
49
|
+
expect(parsePatientSearchQuery("1/1/90")).toEqual({ name: { first: "1/1/90" } });
|
|
50
|
+
expect(parsePatientSearchQuery("1990-1-1")).toEqual({ name: { first: "1990-1-1" } });
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("parse phone numbers to E.164", () => {
|
|
55
|
+
it("10 digits, however punctuated without spaces: supported", () => {
|
|
56
|
+
expect(parsePatientSearchQuery("4155550172")).toEqual({ phone: "+14155550172" });
|
|
57
|
+
expect(parsePatientSearchQuery("415-555-0172")).toEqual({ phone: "+14155550172" });
|
|
58
|
+
expect(parsePatientSearchQuery("(415)555-0172")).toEqual({ phone: "+14155550172" });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("11 digits starting with 1: supported", () => {
|
|
62
|
+
expect(parsePatientSearchQuery("+14155550172")).toEqual({ phone: "+14155550172" });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Pins today's behavior
|
|
66
|
+
// TODO: support a phone typed with spaces, e.g. "(415) 555-0172"
|
|
67
|
+
it("a phone with a space in it: read as a name", () => {
|
|
68
|
+
expect(parsePatientSearchQuery("(415) 555-0172")).toEqual({ name: { first: "(415)", last: "555-0172" } });
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Pins today's behavior
|
|
72
|
+
// TODO: decide what an 11-digit number not starting with 1 is
|
|
73
|
+
it("11 digits not starting with 1: sent as typed, not E.164", () => {
|
|
74
|
+
expect(parsePatientSearchQuery("25555550172")).toEqual({ phone: "25555550172" });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Pins today's behavior
|
|
78
|
+
// TODO: return nothing for invalid phone numbers
|
|
79
|
+
it("fewer than 10 digits: read as a name", () => {
|
|
80
|
+
expect(parsePatientSearchQuery("5550172")).toEqual({ name: { first: "5550172" } });
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe("parse email", () => {
|
|
85
|
+
it("an email: parsed as is", () => {
|
|
86
|
+
expect(parsePatientSearchQuery("ada@example.com")).toEqual({ email: "ada@example.com" });
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// TODO: we don't need to support combined inputs if it complicates code implementation
|
|
91
|
+
describe("parse combined inputs", () => {
|
|
92
|
+
it("date of birth with a name, in any order: both parsed", () => {
|
|
93
|
+
const expected = { name: { first: "Ada", last: "Lovelace" }, dateOfBirth: "1990-01-01" };
|
|
94
|
+
expect(parsePatientSearchQuery("Ada Lovelace 1/1/1990")).toEqual(expected);
|
|
95
|
+
expect(parsePatientSearchQuery("1/1/1990 Ada Lovelace")).toEqual(expected);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("name, date of birth, phone and email at once: each part parsed", () => {
|
|
99
|
+
expect(parsePatientSearchQuery("Ada Lovelace 1/1/1990 4155550172 ada@example.com")).toEqual({
|
|
100
|
+
name: { first: "Ada", last: "Lovelace" },
|
|
101
|
+
dateOfBirth: "1990-01-01",
|
|
102
|
+
phone: "+14155550172",
|
|
103
|
+
email: "ada@example.com",
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { toE164 } from "../format.ts";
|
|
12
12
|
|
|
13
|
-
export interface
|
|
13
|
+
export interface ParsedPatientSearchQuery {
|
|
14
14
|
name?: { first?: string; last?: string };
|
|
15
15
|
dateOfBirth?: string;
|
|
16
16
|
phone?: string;
|
|
@@ -37,11 +37,11 @@ function asPhone(token: string): string | undefined {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* What was typed, as the server takes it. Anything that reads as a date, a phone or an email is taken as
|
|
40
|
-
* one; what's left is the name, first word first. A single word is a first name — `searchBoth` says when
|
|
40
|
+
* one; what's left is the name, first word first. A single word is a first name — PatientSearch's `searchBoth` says when
|
|
41
41
|
* it's worth trying as a last name too.
|
|
42
42
|
*/
|
|
43
|
-
export function
|
|
44
|
-
const parsed:
|
|
43
|
+
export function parsePatientSearchQuery(text: string): ParsedPatientSearchQuery {
|
|
44
|
+
const parsed: ParsedPatientSearchQuery = {};
|
|
45
45
|
const words: string[] = [];
|
|
46
46
|
for (const token of text.trim().split(/\s+/).filter(Boolean)) {
|
|
47
47
|
const date = asDate(token);
|
|
@@ -64,20 +64,3 @@ export function parseQuery(text: string): ParsedQuery {
|
|
|
64
64
|
if (first) parsed.name = rest.length ? { first, last: rest.join(" ") } : { first };
|
|
65
65
|
return parsed;
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
/** query as patient input */
|
|
69
|
-
export const toSearchInput = ({ phone, email, ...demographic }: ParsedQuery) => ({
|
|
70
|
-
demographic,
|
|
71
|
-
contact: { ...(phone ? { phone } : {}), ...(email ? { email } : {}) },
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
/** Whether a query says anything the server can match on. */
|
|
75
|
-
export const isSearchable = (q: ParsedQuery) =>
|
|
76
|
-
Boolean(q.name?.first || q.name?.last || q.dateOfBirth || q.phone || q.email);
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* One word could be either name. It goes as a first name; if nothing comes back, it's worth asking again
|
|
80
|
-
* as a last name — "Lovelace" is as likely as "Ada".
|
|
81
|
-
*/
|
|
82
|
-
export const searchBoth = (q: ParsedQuery): ParsedQuery | null =>
|
|
83
|
-
q.name?.first && !q.name.last && !q.dateOfBirth && !q.phone && !q.email ? { name: { last: q.name.first } } : null;
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { fakeNetworkApiClient, payload } from "@photonhealth/client/testing";
|
|
1
|
+
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
3
|
+
import { alert, type change, fakeNetworkApiClient, payload, rx } from "@photonhealth/client/testing";
|
|
5
4
|
import { PrescriptionCard } from "./PrescriptionCard.tsx";
|
|
6
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
fakeNetworkApi,
|
|
7
|
+
patient,
|
|
8
|
+
screeningUnavailableChange,
|
|
9
|
+
tapDrug,
|
|
10
|
+
withPhoton,
|
|
11
|
+
} from "../../../test/cards.fixtures.tsx";
|
|
12
|
+
import {
|
|
13
|
+
meAsPrescriber,
|
|
14
|
+
recordAnalytics,
|
|
15
|
+
type RecordedAnalytics,
|
|
16
|
+
unmountAndRestoreFetch,
|
|
17
|
+
withAnalytics,
|
|
18
|
+
} from "../../../test/analytics.fixtures.tsx";
|
|
7
19
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
afterEach(cleanup);
|
|
20
|
+
const allergyAlertTitle = "allergen · moderate";
|
|
21
|
+
const anyScreeningAlertTitle = /^(allergen|drug|condition) · /;
|
|
11
22
|
|
|
12
23
|
describe("PrescriptionCard", () => {
|
|
13
24
|
it("finds a drug, picks its form and strength, takes the server's directions, and is signed", async () => {
|
|
@@ -36,7 +47,7 @@ describe("PrescriptionCard", () => {
|
|
|
36
47
|
expect(((await screen.findByLabelText("Directions (sig)")) as HTMLTextAreaElement).value).toBe("Take as directed");
|
|
37
48
|
expect((screen.getByLabelText("Quantity") as HTMLInputElement).value).toBe("30");
|
|
38
49
|
|
|
39
|
-
fireEvent.click(await screen.findByRole("button", { name: "
|
|
50
|
+
fireEvent.click(await screen.findByRole("button", { name: "Sign" }));
|
|
40
51
|
expect(await screen.findByText("Signed")).toBeTruthy();
|
|
41
52
|
await waitFor(() => expect(screen.queryByLabelText("Directions (sig)")).toBeNull()); // signed is read-only
|
|
42
53
|
expect(names()).toContain("SignPrescription");
|
|
@@ -56,12 +67,12 @@ describe("PrescriptionCard", () => {
|
|
|
56
67
|
await screen.findByLabelText("Directions (sig)");
|
|
57
68
|
fireEvent.change(screen.getByLabelText("Quantity"), { target: { value: "" } });
|
|
58
69
|
|
|
59
|
-
fireEvent.click(screen.getByRole("button", { name: "
|
|
70
|
+
fireEvent.click(screen.getByRole("button", { name: "Sign" }));
|
|
60
71
|
expect(await screen.findByText("Required")).toBeTruthy();
|
|
61
72
|
expect(names()).not.toContain("SignPrescription");
|
|
62
73
|
});
|
|
63
74
|
|
|
64
|
-
it("offers
|
|
75
|
+
it("offers Sign once a product is picked before there's a patient, and says a patient is required", async () => {
|
|
65
76
|
const { client, names } = fakeNetworkApiClient({
|
|
66
77
|
...fakeNetworkApi({ prescriptions: { amox: [["Amoxicillin", "Capsule", "500 MG"]] } }),
|
|
67
78
|
});
|
|
@@ -75,11 +86,163 @@ describe("PrescriptionCard", () => {
|
|
|
75
86
|
// Nothing is drafted without a patient, so the required fields start empty.
|
|
76
87
|
fireEvent.change(screen.getByLabelText("Directions (sig)"), { target: { value: "1 cap PO TID" } });
|
|
77
88
|
fireEvent.change(screen.getByLabelText("Quantity"), { target: { value: "21" } });
|
|
89
|
+
fireEvent.change(screen.getByLabelText("Unit"), { target: { value: "Capsule" } });
|
|
78
90
|
fireEvent.change(screen.getByLabelText("Days supply"), { target: { value: "7" } });
|
|
79
91
|
|
|
80
|
-
fireEvent.click(screen.getByRole("button", { name: "
|
|
92
|
+
fireEvent.click(screen.getByRole("button", { name: "Sign" }));
|
|
81
93
|
expect(await screen.findByText("A patient is required for signing")).toBeTruthy();
|
|
82
94
|
expect(names()).not.toContain("SyncPrescription");
|
|
83
95
|
expect(names()).not.toContain("SignPrescription");
|
|
84
96
|
});
|
|
85
97
|
});
|
|
98
|
+
|
|
99
|
+
describe("PrescriptionCard: screening alerts", () => {
|
|
100
|
+
it("a picked drug's alert shows above its directions, and Sign is still offered", async () => {
|
|
101
|
+
renderCardDraftingAmoxicillin({ screeningAlerts: [alert] });
|
|
102
|
+
await pickAmoxicillin();
|
|
103
|
+
|
|
104
|
+
const alertTitle = await screen.findByText(allergyAlertTitle);
|
|
105
|
+
const directions = await screen.findByLabelText("Directions (sig)");
|
|
106
|
+
expect(alertTitle.compareDocumentPosition(directions) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
107
|
+
expect(screen.getByText(`${alert.description} (amoxicillin)`)).toBeInTheDocument();
|
|
108
|
+
expect(screen.getByRole("button", { name: "Sign" })).toBeEnabled();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("Sign signs a prescription that has alerts without asking for confirmation", async () => {
|
|
112
|
+
const { names } = renderCardDraftingAmoxicillin({ screeningAlerts: [alert] });
|
|
113
|
+
await pickAmoxicillin();
|
|
114
|
+
await screen.findByText(allergyAlertTitle);
|
|
115
|
+
|
|
116
|
+
fireEvent.click(await screen.findByRole("button", { name: "Sign" }));
|
|
117
|
+
|
|
118
|
+
expect(await screen.findByText("Signed")).toBeInTheDocument();
|
|
119
|
+
expect(names()).toContain("SignPrescription");
|
|
120
|
+
expect(screen.queryByRole("dialog")).toBeNull();
|
|
121
|
+
expect(screen.queryByRole("alertdialog")).toBeNull();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("the alerts are no longer shown once the prescription is signed", async () => {
|
|
125
|
+
renderCardDraftingAmoxicillin({ screeningAlerts: [alert] });
|
|
126
|
+
await pickAmoxicillin();
|
|
127
|
+
await screen.findByText(allergyAlertTitle);
|
|
128
|
+
|
|
129
|
+
fireEvent.click(await screen.findByRole("button", { name: "Sign" }));
|
|
130
|
+
|
|
131
|
+
await screen.findByText("Signed");
|
|
132
|
+
await waitFor(() => expect(screen.queryByText(allergyAlertTitle)).toBeNull());
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("a locked prescription that isn't signed still shows its alerts", async () => {
|
|
136
|
+
renderCardOpening(rx({ screeningAlerts: [alert] }), { locked: true });
|
|
137
|
+
expect(await screen.findByText(allergyAlertTitle)).toBeInTheDocument();
|
|
138
|
+
expect(screen.queryByRole("button", { name: "Sign" })).toBeNull();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("a signed prescription opened later shows none of its alerts", async () => {
|
|
142
|
+
renderCardOpening(rx({ screeningAlerts: [alert], signing: { ...rx().signing, state: "SIGNED" } }));
|
|
143
|
+
expect(await screen.findByText("Signed")).toBeInTheDocument();
|
|
144
|
+
expect(screen.queryByText(allergyAlertTitle)).toBeNull();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("screening that failed while drafting shows a dismissible notice in the info tone and no alerts", async () => {
|
|
148
|
+
renderCardDraftingAmoxicillin({ screeningAlerts: null });
|
|
149
|
+
await pickAmoxicillin();
|
|
150
|
+
|
|
151
|
+
const notice = (await screen.findByText("Prescription screening")).closest<HTMLElement>("[data-tone]")!;
|
|
152
|
+
expect(notice).toHaveAttribute("data-tone", "info");
|
|
153
|
+
expect(within(notice).getByText("Prescription screening could not be completed.")).toBeInTheDocument();
|
|
154
|
+
expect(screen.queryByText(anyScreeningAlertTitle)).toBeNull();
|
|
155
|
+
|
|
156
|
+
fireEvent.click(within(notice).getByRole("button", { name: "Dismiss" }));
|
|
157
|
+
expect(screen.queryByText("Prescription screening")).toBeNull();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("screening that failed while drafting doesn't stop Sign from signing", async () => {
|
|
161
|
+
const { names } = renderCardDraftingAmoxicillin({ screeningAlerts: null });
|
|
162
|
+
await pickAmoxicillin();
|
|
163
|
+
await screen.findByText("Prescription screening");
|
|
164
|
+
|
|
165
|
+
fireEvent.click(await screen.findByRole("button", { name: "Sign" }));
|
|
166
|
+
|
|
167
|
+
expect(await screen.findByText("Signed")).toBeInTheDocument();
|
|
168
|
+
expect(names()).toContain("SignPrescription");
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("a prescription whose screening failed, opened later, shows neither alerts nor the notice", async () => {
|
|
172
|
+
renderCardOpening(rx({ screeningAlerts: null }), { changes: [screeningUnavailableChange] });
|
|
173
|
+
expect(await screen.findByLabelText("Directions (sig)")).toBeInTheDocument();
|
|
174
|
+
expect(screen.queryByText(anyScreeningAlertTitle)).toBeNull();
|
|
175
|
+
expect(screen.queryByText("Prescription screening")).toBeNull();
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
describe("PrescriptionCard: screening alert analytics", () => {
|
|
180
|
+
let analytics: RecordedAnalytics;
|
|
181
|
+
beforeEach(() => {
|
|
182
|
+
analytics = recordAnalytics();
|
|
183
|
+
});
|
|
184
|
+
afterEach(unmountAndRestoreFetch);
|
|
185
|
+
|
|
186
|
+
it("signing a prescription that has alerts sends no screening alert event: Prescription Signed counts them", async () => {
|
|
187
|
+
const { client } = fakeNetworkApiClient({
|
|
188
|
+
...meAsPrescriber,
|
|
189
|
+
GetPatient: () => payload("patient", "PatientPayload", patient),
|
|
190
|
+
...fakeNetworkApi({ prescriptions: amoxicillinSearch, screeningAlerts: [alert] }),
|
|
191
|
+
});
|
|
192
|
+
render(<PrescriptionCard patient="pat_1" />, { wrapper: withAnalytics(client) });
|
|
193
|
+
await pickAmoxicillin();
|
|
194
|
+
await screen.findByText(allergyAlertTitle);
|
|
195
|
+
|
|
196
|
+
fireEvent.click(await screen.findByRole("button", { name: "Sign" }));
|
|
197
|
+
await screen.findByText("Signed");
|
|
198
|
+
|
|
199
|
+
await analytics.expectSentOnce("Field Interaction treatment focus");
|
|
200
|
+
await analytics.expectSentOnce("Field Interaction treatment change");
|
|
201
|
+
await analytics.expectSentOnce("Field Interaction treatment blur");
|
|
202
|
+
await analytics.expectSentOnce("Draft Prescription Added");
|
|
203
|
+
await analytics.expectSentOnce("Prescription Signed");
|
|
204
|
+
await analytics.expectEventCount(5);
|
|
205
|
+
expect(prescriptionSignedSent(analytics)).toMatchObject({ screeningAlertCount: 1 });
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const amoxicillinSearch = { amox: [["Amoxicillin", "Capsule", "500 MG"]] } satisfies Parameters<
|
|
210
|
+
typeof fakeNetworkApi
|
|
211
|
+
>[0]["prescriptions"];
|
|
212
|
+
|
|
213
|
+
type ScreeningAlertsFromServer = Parameters<typeof fakeNetworkApi>[0]["screeningAlerts"];
|
|
214
|
+
|
|
215
|
+
function renderCardDraftingAmoxicillin({ screeningAlerts }: { screeningAlerts: ScreeningAlertsFromServer }) {
|
|
216
|
+
const { client, names } = fakeNetworkApiClient({
|
|
217
|
+
GetPatient: () => payload("patient", "PatientPayload", patient),
|
|
218
|
+
...fakeNetworkApi({ prescriptions: amoxicillinSearch, screeningAlerts }),
|
|
219
|
+
});
|
|
220
|
+
render(<PrescriptionCard patient="pat_1" />, { wrapper: withPhoton(client) });
|
|
221
|
+
return { names };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function renderCardOpening(
|
|
225
|
+
prescription: ReturnType<typeof rx>,
|
|
226
|
+
{ locked, changes = [] }: { locked?: boolean; changes?: ReturnType<typeof change>[] } = {},
|
|
227
|
+
) {
|
|
228
|
+
const { client } = fakeNetworkApiClient({
|
|
229
|
+
GetPatient: () => payload("patient", "PatientPayload", patient),
|
|
230
|
+
GetPrescription: () => payload("prescription", "PrescriptionPayload", prescription, { changes } as never),
|
|
231
|
+
});
|
|
232
|
+
render(<PrescriptionCard prescription={prescription.id} locked={locked} />, { wrapper: withPhoton(client) });
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
async function pickAmoxicillin() {
|
|
236
|
+
const treatment = await screen.findByLabelText("Treatment");
|
|
237
|
+
treatment.focus();
|
|
238
|
+
fireEvent.change(treatment, { target: { value: "amox" } });
|
|
239
|
+
await tapDrug(/^Amoxicillin/);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function prescriptionSignedSent(analytics: RecordedAnalytics) {
|
|
243
|
+
const sent = analytics
|
|
244
|
+
.bodies()
|
|
245
|
+
.map((body) => JSON.parse(body) as { event: string; properties: Record<string, unknown> })
|
|
246
|
+
.find(({ event }) => event === "Prescription Signed");
|
|
247
|
+
return sent?.properties;
|
|
248
|
+
}
|
|
@@ -15,13 +15,15 @@ import { useLive, useOnChange } from "../../hooks/index.ts";
|
|
|
15
15
|
import { useEffect, useRef, useState, type ReactNode } from "react";
|
|
16
16
|
import { useHeldActivity } from "../activity.ts";
|
|
17
17
|
import { SearchResults } from "../search.tsx";
|
|
18
|
-
import { NotFound, openFailed, toOpen, useOpened
|
|
18
|
+
import { NotFound, openFailed, toOpen, useOpened } from "../open.ts";
|
|
19
19
|
import { treatmentHeading } from "../display.ts";
|
|
20
20
|
import { dispenseSummary } from "../format.ts";
|
|
21
21
|
import { ChangeList } from "../ChangeList.tsx";
|
|
22
22
|
import { PrescriptionDetailsForm } from "./PrescriptionDetailsForm/PrescriptionDetailsForm.tsx";
|
|
23
23
|
import { ScreeningAlerts } from "../ScreeningAlerts.tsx";
|
|
24
24
|
import { TreatmentSearch, type TreatmentChoice } from "./TreatmentSearch/TreatmentSearch.tsx";
|
|
25
|
+
import { usePhotonAnalytics } from "../../analytics/PhotonAnalyticsProvider.tsx";
|
|
26
|
+
import { useSendDraftPrescriptionAdded } from "../../analytics/cardLifecycle.ts";
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* One prescription line, bound to a live Prescription: PhotonPrescription's card (which adds the analytics workflow
|
|
@@ -29,16 +31,23 @@ import { TreatmentSearch, type TreatmentChoice } from "./TreatmentSearch/Treatme
|
|
|
29
31
|
*/
|
|
30
32
|
export interface PrescriptionCardProps {
|
|
31
33
|
/**
|
|
32
|
-
* The prescription
|
|
33
|
-
*
|
|
34
|
-
*
|
|
34
|
+
* The prescription, one of:
|
|
35
|
+
* - a live `Prescription`: used as is; anything else holding it sees the same changes
|
|
36
|
+
* - its id, `"rx_…"` or `{ id }`: gets the prescription
|
|
37
|
+
* - its id with fields, `{ id, … }`: updates the prescription
|
|
38
|
+
* - fields without an id, e.g. `{ templateId }` or `{ treatment: { name } }`: upserts the prescription
|
|
35
39
|
*/
|
|
36
|
-
prescription?: Prescription |
|
|
40
|
+
prescription?: Prescription | PrescriptionInput | string | null;
|
|
37
41
|
/**
|
|
38
|
-
* Who it's for
|
|
39
|
-
*
|
|
42
|
+
* Who it's for, one of:
|
|
43
|
+
* - a live `Patient`: used as is
|
|
44
|
+
* - its id, `"pat_…"` or `{ id }`: gets the patient
|
|
45
|
+
* - its id with fields, `{ id, … }`: updates the patient
|
|
46
|
+
* - fields without an id: upserts the patient
|
|
47
|
+
*
|
|
48
|
+
* Until it's known, a new line only looks drugs up (a line from an order already knows).
|
|
40
49
|
*/
|
|
41
|
-
patient?: Patient |
|
|
50
|
+
patient?: Patient | PatientInput | string | null;
|
|
42
51
|
/** Read-only (e.g. on a finalized order). A signed prescription is always read-only. */
|
|
43
52
|
locked?: boolean;
|
|
44
53
|
/** The prescriber signed it on this card — once per prescription. */
|
|
@@ -74,6 +83,7 @@ export function StatusBadge({ rx }: { rx: PrescriptionRecord | null }) {
|
|
|
74
83
|
|
|
75
84
|
// One empty list, so a line with no templates doesn't hand PrescriptionDetailsForm new options every render.
|
|
76
85
|
const NO_TEMPLATES: readonly PrescriptionTemplate[] = [];
|
|
86
|
+
// At module level, not inline: useOpened re-runs its server call when these functions change.
|
|
77
87
|
const prescriptionOf = (r: PrescriptionResult) => r.prescription;
|
|
78
88
|
const patientOf = (r: PatientResult) => r.patient;
|
|
79
89
|
|
|
@@ -109,6 +119,8 @@ export function PrescriptionCard({
|
|
|
109
119
|
const live = shared ?? opened ?? own;
|
|
110
120
|
const snap = useLive(live);
|
|
111
121
|
useOnChange(live, (rx) => rx.state, onPrescription);
|
|
122
|
+
useSendDraftPrescriptionAdded(live);
|
|
123
|
+
const analytics = usePhotonAnalytics();
|
|
112
124
|
const signedHere = useRef(new Set<string>()); // onSigned: once per prescription
|
|
113
125
|
useEffect(() => {
|
|
114
126
|
if (live && patientId !== undefined)
|
|
@@ -118,13 +130,13 @@ export function PrescriptionCard({
|
|
|
118
130
|
const rx = snap?.state ?? null;
|
|
119
131
|
const changes = classify(snap?.changes ?? { applied: [], unapplied: [] });
|
|
120
132
|
const [signing, setSigning] = useState(false);
|
|
121
|
-
// The error showing came from
|
|
133
|
+
// The error showing came from Sign, which signs (its title says so); the next save's error is a save's again.
|
|
122
134
|
const [signFailed, setSignFailed] = useState(false);
|
|
123
135
|
const busy = signing || snap?.status === "saving" || snap?.status === "loading";
|
|
124
136
|
// Signing is per prescription, and a signed one is final here: no edits (any change would void the
|
|
125
137
|
// signature). A different drug or sig is a new line.
|
|
126
138
|
const readOnly = Boolean(locked) || Boolean(live?.signed);
|
|
127
|
-
//
|
|
139
|
+
// Sign (the signature) is offered once the server left nothing open. Screening alerts don't stop it: signing is the
|
|
128
140
|
// prescriber's acknowledgement of what they show (network-api can't acknowledge an alert yet).
|
|
129
141
|
const canSign = Boolean(rx) && changes.settled;
|
|
130
142
|
// The field whose change sent the call in flight shows a spinner — nowhere else, so nothing opens and
|
|
@@ -143,6 +155,7 @@ export function PrescriptionCard({
|
|
|
143
155
|
};
|
|
144
156
|
const add = () => {
|
|
145
157
|
if (!live) return;
|
|
158
|
+
const alertsShownWhenSigning = openAlerts(rx);
|
|
146
159
|
setSigning(true);
|
|
147
160
|
setSignFailed(false);
|
|
148
161
|
void live
|
|
@@ -150,6 +163,7 @@ export function PrescriptionCard({
|
|
|
150
163
|
.then(() => {
|
|
151
164
|
if (!live.signed || !live.id || signedHere.current.has(live.id)) return;
|
|
152
165
|
signedHere.current.add(live.id);
|
|
166
|
+
void analytics.prescriptionSigned({ id: live.id, screeningAlerts: alertsShownWhenSigning });
|
|
153
167
|
onSigned?.(live);
|
|
154
168
|
})
|
|
155
169
|
.catch(() => setSignFailed(true)) // a refusal or failure lands on the object (snap.error)
|
|
@@ -299,7 +313,7 @@ export function PrescriptionCard({
|
|
|
299
313
|
</Stack>
|
|
300
314
|
</CardBody>
|
|
301
315
|
)}
|
|
302
|
-
{/* Once a drug is set: the directions first, then quantity / unit / days / refills, then DAW — and
|
|
316
|
+
{/* Once a drug is set: the directions first, then quantity / unit / days / refills, then DAW — and Sign, which
|
|
303
317
|
signs it (before a patient too: signing then says a patient is required). */}
|
|
304
318
|
{!readOnly && (
|
|
305
319
|
<PrescriptionDetailsForm
|
|
@@ -311,9 +325,9 @@ export function PrescriptionCard({
|
|
|
311
325
|
spinning={spinning}
|
|
312
326
|
save={save}
|
|
313
327
|
status={<StatusBadge rx={rx} />}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
328
|
+
onSign={add}
|
|
329
|
+
signing={signing}
|
|
330
|
+
signDisabled={snap?.status === "loading" || (Boolean(rx) && !canSign)}
|
|
317
331
|
/>
|
|
318
332
|
)}
|
|
319
333
|
</Card>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
1
|
+
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
3
|
import { DirectionsInput, type DirectionsInputProps } from "./DirectionsInput.tsx";
|
|
5
4
|
|
|
6
5
|
const directions = "Take 1 capsule by mouth 3 times per day";
|
|
@@ -19,8 +18,6 @@ const renderInput = (props: Partial<DirectionsInputProps> = {}) => {
|
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
describe("DirectionsInput", () => {
|
|
22
|
-
afterEach(() => cleanup());
|
|
23
|
-
|
|
24
21
|
it("shows the directions", () => {
|
|
25
22
|
const { input } = renderInput();
|
|
26
23
|
expect(input.value).toBe(directions);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import { act, cleanup, fireEvent, render, screen, within } from "@testing-library/react";
|
|
1
|
+
import { act, fireEvent, render, screen, within } from "@testing-library/react";
|
|
3
2
|
import userEvent from "@testing-library/user-event";
|
|
4
3
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
4
|
import { fakeNetworkApiClient } from "@photonhealth/client/testing";
|
|
6
5
|
import { DispenseInputs, type DispenseInputsProps, type DispenseValues } from "./DispenseInputs.tsx";
|
|
7
6
|
import {
|
|
8
|
-
|
|
7
|
+
buildEditedEventsFor,
|
|
9
8
|
leaveField,
|
|
10
9
|
meAsPrescriber,
|
|
11
10
|
recordAnalytics,
|
|
@@ -44,8 +43,6 @@ const unitOptions = () =>
|
|
|
44
43
|
.map((option) => option.textContent);
|
|
45
44
|
|
|
46
45
|
describe("DispenseInputs", () => {
|
|
47
|
-
afterEach(() => cleanup());
|
|
48
|
-
|
|
49
46
|
it("shows the dispense", () => {
|
|
50
47
|
renderInputs();
|
|
51
48
|
expect(input("Quantity").value).toBe("30");
|
|
@@ -196,7 +193,7 @@ describe("DispenseInputs", () => {
|
|
|
196
193
|
await userEvent.selectOptions(screen.getByRole("combobox", { name: "Unit" }), "Tablet");
|
|
197
194
|
leaveField();
|
|
198
195
|
|
|
199
|
-
await analytics.expectEventLog([...
|
|
196
|
+
await analytics.expectEventLog([...buildEditedEventsFor("dispenseUnit")]);
|
|
200
197
|
expect(analytics.sentFor("dispenseUnit")).toEqual([
|
|
201
198
|
expect.objectContaining({ hasValue: false, isOptional: false }),
|
|
202
199
|
expect.objectContaining({ hasValue: true }),
|