@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.
Files changed (185) hide show
  1. package/README.md +17 -1
  2. package/dist/analytics/PhotonAnalyticsProvider.d.ts +5 -2
  3. package/dist/analytics/PhotonAnalyticsProvider.d.ts.map +1 -1
  4. package/dist/analytics/PhotonAnalyticsProvider.js +34 -15
  5. package/dist/analytics/PhotonAnalyticsProvider.js.map +1 -1
  6. package/dist/analytics/cardLifecycle.d.ts +10 -0
  7. package/dist/analytics/cardLifecycle.d.ts.map +1 -0
  8. package/dist/analytics/cardLifecycle.js +43 -0
  9. package/dist/analytics/cardLifecycle.js.map +1 -0
  10. package/dist/analytics/lifecycleOutcomes.d.ts +8 -0
  11. package/dist/analytics/lifecycleOutcomes.d.ts.map +1 -0
  12. package/dist/analytics/lifecycleOutcomes.js +16 -0
  13. package/dist/analytics/lifecycleOutcomes.js.map +1 -0
  14. package/dist/analytics/tracker.d.ts +5 -3
  15. package/dist/analytics/tracker.d.ts.map +1 -1
  16. package/dist/analytics/tracker.js +10 -5
  17. package/dist/analytics/tracker.js.map +1 -1
  18. package/dist/components/PhotonOrder.d.ts +18 -18
  19. package/dist/components/PhotonOrder.d.ts.map +1 -1
  20. package/dist/components/PhotonOrder.js +17 -6
  21. package/dist/components/PhotonOrder.js.map +1 -1
  22. package/dist/components/PhotonPatient.d.ts +7 -35
  23. package/dist/components/PhotonPatient.d.ts.map +1 -1
  24. package/dist/components/PhotonPatient.js +3 -77
  25. package/dist/components/PhotonPatient.js.map +1 -1
  26. package/dist/components/PhotonPrescription.d.ts +14 -14
  27. package/dist/components/PhotonPrescription.d.ts.map +1 -1
  28. package/dist/components/PhotonPrescription.js +0 -1
  29. package/dist/components/PhotonPrescription.js.map +1 -1
  30. package/dist/components/open.d.ts +11 -13
  31. package/dist/components/open.d.ts.map +1 -1
  32. package/dist/components/open.js +7 -2
  33. package/dist/components/open.js.map +1 -1
  34. package/dist/components/patient/PatientCard/PatientCard.d.ts +30 -0
  35. package/dist/components/patient/PatientCard/PatientCard.d.ts.map +1 -0
  36. package/dist/components/patient/PatientCard/PatientCard.js +101 -0
  37. package/dist/components/patient/PatientCard/PatientCard.js.map +1 -0
  38. package/dist/components/patient/PatientCard/usePatientToShow.d.ts +22 -0
  39. package/dist/components/patient/PatientCard/usePatientToShow.d.ts.map +1 -0
  40. package/dist/components/patient/PatientCard/usePatientToShow.js +40 -0
  41. package/dist/components/patient/PatientCard/usePatientToShow.js.map +1 -0
  42. package/dist/components/patient/PatientIntakeForm.d.ts +16 -0
  43. package/dist/components/patient/PatientIntakeForm.d.ts.map +1 -0
  44. package/dist/components/patient/PatientIntakeForm.js +114 -0
  45. package/dist/components/patient/PatientIntakeForm.js.map +1 -0
  46. package/dist/components/patient/PatientSearch.d.ts +12 -0
  47. package/dist/components/patient/PatientSearch.d.ts.map +1 -0
  48. package/dist/components/patient/PatientSearch.js +148 -0
  49. package/dist/components/patient/PatientSearch.js.map +1 -0
  50. package/dist/components/patient/{Benefits.d.ts → PatientSummary/BenefitsInputForm.d.ts} +2 -2
  51. package/dist/components/patient/PatientSummary/BenefitsInputForm.d.ts.map +1 -0
  52. package/dist/components/patient/{Benefits.js → PatientSummary/BenefitsInputForm.js} +5 -5
  53. package/dist/components/patient/PatientSummary/BenefitsInputForm.js.map +1 -0
  54. package/dist/components/patient/{Clinical.d.ts → PatientSummary/ClinicalInputForm.d.ts} +13 -15
  55. package/dist/components/patient/PatientSummary/ClinicalInputForm.d.ts.map +1 -0
  56. package/dist/components/patient/{Clinical.js → PatientSummary/ClinicalInputForm.js} +11 -11
  57. package/dist/components/patient/PatientSummary/ClinicalInputForm.js.map +1 -0
  58. package/dist/components/patient/PatientSummary/CollapsedSummary.d.ts +5 -0
  59. package/dist/components/patient/PatientSummary/CollapsedSummary.d.ts.map +1 -0
  60. package/dist/components/patient/PatientSummary/CollapsedSummary.js +30 -0
  61. package/dist/components/patient/PatientSummary/CollapsedSummary.js.map +1 -0
  62. package/dist/components/patient/PatientSummary/PatientDetailsForm.d.ts +10 -0
  63. package/dist/components/patient/PatientSummary/PatientDetailsForm.d.ts.map +1 -0
  64. package/dist/components/patient/PatientSummary/PatientDetailsForm.js +65 -0
  65. package/dist/components/patient/PatientSummary/PatientDetailsForm.js.map +1 -0
  66. package/dist/components/patient/PatientSummary/PatientDetailsSchema.d.ts +53 -0
  67. package/dist/components/patient/PatientSummary/PatientDetailsSchema.d.ts.map +1 -0
  68. package/dist/components/patient/PatientSummary/PatientDetailsSchema.js +78 -0
  69. package/dist/components/patient/PatientSummary/PatientDetailsSchema.js.map +1 -0
  70. package/dist/components/patient/PatientSummary/PatientSummary.d.ts +46 -0
  71. package/dist/components/patient/PatientSummary/PatientSummary.d.ts.map +1 -0
  72. package/dist/components/patient/PatientSummary/PatientSummary.js +57 -0
  73. package/dist/components/patient/PatientSummary/PatientSummary.js.map +1 -0
  74. package/dist/components/patient/PatientSummary/SummaryHeader.d.ts +19 -0
  75. package/dist/components/patient/PatientSummary/SummaryHeader.d.ts.map +1 -0
  76. package/dist/components/patient/PatientSummary/SummaryHeader.js +22 -0
  77. package/dist/components/patient/PatientSummary/SummaryHeader.js.map +1 -0
  78. package/dist/components/patient/fields.d.ts +7 -25
  79. package/dist/components/patient/fields.d.ts.map +1 -1
  80. package/dist/components/patient/fields.js +11 -53
  81. package/dist/components/patient/fields.js.map +1 -1
  82. package/dist/components/patient/parsePatientSearchQuery.d.ts +16 -0
  83. package/dist/components/patient/parsePatientSearchQuery.d.ts.map +1 -0
  84. package/dist/components/patient/{query.js → parsePatientSearchQuery.js} +3 -15
  85. package/dist/components/patient/parsePatientSearchQuery.js.map +1 -0
  86. package/dist/components/prescription/PrescriptionCard.d.ts +14 -8
  87. package/dist/components/prescription/PrescriptionCard.d.ts.map +1 -1
  88. package/dist/components/prescription/PrescriptionCard.js +10 -3
  89. package/dist/components/prescription/PrescriptionCard.js.map +1 -1
  90. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts +6 -6
  91. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts.map +1 -1
  92. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js +16 -8
  93. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js.map +1 -1
  94. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts +14 -1
  95. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts.map +1 -1
  96. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js +25 -7
  97. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js.map +1 -1
  98. package/dist/components/schemaErrors.d.ts +3 -2
  99. package/dist/components/schemaErrors.d.ts.map +1 -1
  100. package/dist/components/schemaErrors.js +2 -1
  101. package/dist/components/schemaErrors.js.map +1 -1
  102. package/dist/components/search.d.ts +1 -1
  103. package/dist/components/search.js +1 -1
  104. package/dist/index.d.ts +1 -1
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +1 -1
  107. package/dist/index.js.map +1 -1
  108. package/dist/meta/version.js +1 -1
  109. package/package.json +5 -2
  110. package/src/analytics/PhotonAnalyticsProvider.test.tsx +0 -1
  111. package/src/analytics/PhotonAnalyticsProvider.tsx +75 -20
  112. package/src/analytics/cardLifecycle.test.tsx +272 -0
  113. package/src/analytics/cardLifecycle.ts +44 -0
  114. package/src/analytics/fieldInteraction.test.tsx +11 -9
  115. package/src/analytics/lifecycleOutcomes.test.ts +78 -0
  116. package/src/analytics/lifecycleOutcomes.ts +29 -0
  117. package/src/analytics/tracker.test.ts +1 -1
  118. package/src/analytics/tracker.ts +13 -6
  119. package/src/analytics/usePhotonAnalytics.test.tsx +106 -0
  120. package/src/components/PhotonOrder.test.tsx +146 -8
  121. package/src/components/PhotonOrder.tsx +37 -26
  122. package/src/components/PhotonPatient.tsx +8 -163
  123. package/src/components/PhotonPrescription.test.tsx +22 -18
  124. package/src/components/PhotonPrescription.tsx +14 -14
  125. package/src/components/ScreeningAlerts.test.tsx +81 -0
  126. package/src/components/open.ts +13 -16
  127. package/src/components/order/DraftOrderPrompt.test.tsx +3 -6
  128. package/src/components/patient/PatientCard/PatientCard.test.tsx +255 -0
  129. package/src/components/patient/PatientCard/PatientCard.tsx +177 -0
  130. package/src/components/patient/PatientCard/usePatientToShow.ts +44 -0
  131. package/src/components/patient/PatientIntakeForm.test.tsx +262 -0
  132. package/src/components/patient/PatientIntakeForm.tsx +222 -0
  133. package/src/components/patient/PatientSearch.test.tsx +204 -0
  134. package/src/components/patient/PatientSearch.tsx +221 -0
  135. package/src/components/patient/PatientSummary/BenefitsInputForm.test.tsx +164 -0
  136. package/src/components/patient/{Benefits.tsx → PatientSummary/BenefitsInputForm.tsx} +4 -4
  137. package/src/components/patient/PatientSummary/ClinicalInputForm.test.tsx +247 -0
  138. package/src/components/patient/{Clinical.tsx → PatientSummary/ClinicalInputForm.tsx} +23 -23
  139. package/src/components/patient/PatientSummary/CollapsedSummary.test.tsx +90 -0
  140. package/src/components/patient/PatientSummary/CollapsedSummary.tsx +46 -0
  141. package/src/components/patient/PatientSummary/PatientDetailsForm.test.tsx +201 -0
  142. package/src/components/patient/PatientSummary/PatientDetailsForm.tsx +320 -0
  143. package/src/components/patient/PatientSummary/PatientDetailsSchema.test.ts +296 -0
  144. package/src/components/patient/PatientSummary/PatientDetailsSchema.ts +95 -0
  145. package/src/components/patient/PatientSummary/PatientSummary.test.tsx +194 -0
  146. package/src/components/patient/PatientSummary/PatientSummary.tsx +225 -0
  147. package/src/components/patient/PatientSummary/SummaryHeader.test.tsx +183 -0
  148. package/src/components/patient/PatientSummary/SummaryHeader.tsx +85 -0
  149. package/src/components/patient/fields.tsx +12 -138
  150. package/src/components/patient/parsePatientSearchQuery.test.ts +107 -0
  151. package/src/components/patient/{query.ts → parsePatientSearchQuery.ts} +4 -21
  152. package/src/components/prescription/PrescriptionCard.test.tsx +175 -12
  153. package/src/components/prescription/PrescriptionCard.tsx +28 -14
  154. package/src/components/prescription/PrescriptionDetailsForm/DirectionsInput.test.tsx +2 -5
  155. package/src/components/prescription/PrescriptionDetailsForm/DispenseInputs.test.tsx +3 -6
  156. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.test.tsx +34 -37
  157. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.tsx +24 -16
  158. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.test.ts +166 -41
  159. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.ts +41 -9
  160. package/src/components/prescription/PrescriptionDetailsForm/TemplatePicker.test.tsx +2 -5
  161. package/src/components/prescription/TreatmentSearch/TreatmentSearch.test.tsx +3 -7
  162. package/src/components/schemaErrors.ts +3 -2
  163. package/src/components/search.tsx +1 -1
  164. package/src/index.ts +1 -1
  165. package/src/meta/version.test.ts +1 -0
  166. package/src/meta/version.ts +1 -1
  167. package/dist/components/patient/Benefits.d.ts.map +0 -1
  168. package/dist/components/patient/Benefits.js.map +0 -1
  169. package/dist/components/patient/Clinical.d.ts.map +0 -1
  170. package/dist/components/patient/Clinical.js.map +0 -1
  171. package/dist/components/patient/IntakeForm.d.ts +0 -10
  172. package/dist/components/patient/IntakeForm.d.ts.map +0 -1
  173. package/dist/components/patient/IntakeForm.js +0 -333
  174. package/dist/components/patient/IntakeForm.js.map +0 -1
  175. package/dist/components/patient/Summary.d.ts +0 -48
  176. package/dist/components/patient/Summary.d.ts.map +0 -1
  177. package/dist/components/patient/Summary.js +0 -90
  178. package/dist/components/patient/Summary.js.map +0 -1
  179. package/dist/components/patient/query.d.ts +0 -37
  180. package/dist/components/patient/query.d.ts.map +0 -1
  181. package/dist/components/patient/query.js.map +0 -1
  182. package/src/components/patient/IntakeForm.test.tsx +0 -89
  183. package/src/components/patient/IntakeForm.tsx +0 -564
  184. package/src/components/patient/Summary.test.tsx +0 -106
  185. package/src/components/patient/Summary.tsx +0 -330
@@ -1,8 +1,7 @@
1
- // @vitest-environment jsdom
2
1
  import type { Prescription, PrescriptionRecord, PrescriptionTemplate, TemplateSource } from "@photonhealth/client";
3
2
  import { treatment } from "@photonhealth/client/testing";
4
- import { cleanup, fireEvent, render, screen, within } from "@testing-library/react";
5
- import { afterEach, describe, expect, it, vi } from "vitest";
3
+ import { fireEvent, render, screen, within } from "@testing-library/react";
4
+ import { describe, expect, it, vi } from "vitest";
6
5
  import { PrescriptionDetailsForm, type PrescriptionDetailsFormProps } from "./PrescriptionDetailsForm.tsx";
7
6
 
8
7
  const directions = "Take 1 capsule by mouth 3 times per day";
@@ -58,7 +57,7 @@ const renderFields = ({
58
57
  signing: { state: "UNSIGNED", contentHash: "hash_0", message: null, signedAt: null },
59
58
  };
60
59
  const save = vi.fn<PrescriptionDetailsFormProps["save"]>();
61
- const onAdd = vi.fn<PrescriptionDetailsFormProps["onAdd"]>();
60
+ const onSign = vi.fn<PrescriptionDetailsFormProps["onSign"]>();
62
61
  const props = (): PrescriptionDetailsFormProps => ({
63
62
  live,
64
63
  rx: record,
@@ -67,15 +66,15 @@ const renderFields = ({
67
66
  templates,
68
67
  spinning: null,
69
68
  save,
70
- onAdd,
71
- adding: false,
72
- addDisabled: false,
69
+ onSign,
70
+ signing: false,
71
+ signDisabled: false,
73
72
  });
74
73
  const { rerender } = render(<PrescriptionDetailsForm {...props()} />);
75
74
  return {
76
75
  save,
77
- onAdd,
78
- clickAdd: () => fireEvent.click(screen.getByRole("button", { name: "Add" })),
76
+ onSign,
77
+ clickSign: () => fireEvent.click(screen.getByRole("button", { name: "Sign" })),
79
78
  setOpen: (isOpen: boolean) => {
80
79
  open = isOpen;
81
80
  rerender(<PrescriptionDetailsForm {...props()} />);
@@ -96,14 +95,12 @@ const leave = (label: string) => fireEvent.blur(field(label));
96
95
 
97
96
  const options = () => screen.queryByRole("list", { name: "Templates" });
98
97
 
99
- // Directions, quantity and days supply — the fields Add needs — all empty.
98
+ // Directions, quantity and days supply — the fields Sign needs — all empty.
100
99
  const empty = { instructions: null, dispense: { quantity: null, daysSupply: null } };
101
100
 
102
101
  const dispenseAsWritten = () => screen.getByRole<HTMLInputElement>("checkbox", { name: "Dispense as written" });
103
102
 
104
103
  describe("PrescriptionDetailsForm", () => {
105
- afterEach(() => cleanup());
106
-
107
104
  describe("showing the prescription", () => {
108
105
  it("shows the stored directions and dispense", () => {
109
106
  renderFields();
@@ -381,7 +378,7 @@ describe("PrescriptionDetailsForm", () => {
381
378
  return note ? document.getElementById(note)?.textContent : null;
382
379
  };
383
380
 
384
- it("shows no validation errors before Add is clicked", () => {
381
+ it("shows no validation errors before Sign is clicked", () => {
385
382
  renderFields(empty);
386
383
  expect(isInvalid("Directions (sig)")).toBe(false);
387
384
  expect(isInvalid("Quantity")).toBe(false);
@@ -389,32 +386,32 @@ describe("PrescriptionDetailsForm", () => {
389
386
  expect(screen.queryByText("Required")).toBeNull();
390
387
  });
391
388
 
392
- it("on Add, shows errors for directions, quantity and days supply when they're empty", () => {
393
- const { clickAdd } = renderFields(empty);
394
- clickAdd();
389
+ it("on Sign, shows errors for directions, quantity and days supply when they're empty", () => {
390
+ const { clickSign } = renderFields(empty);
391
+ clickSign();
395
392
  expect(errorOf("Directions (sig)")).toBe("Required");
396
393
  expect(errorOf("Quantity")).toBe("Required");
397
394
  expect(errorOf("Days supply")).toBe("Required");
398
395
  });
399
396
 
400
- it("on Add, shows no errors for unit and refills", () => {
401
- const { clickAdd } = renderFields({ ...empty, dispense: { ...empty.dispense, refillsAllowed: null } });
402
- clickAdd();
397
+ it("on Sign, shows no errors for unit and refills", () => {
398
+ const { clickSign } = renderFields({ ...empty, dispense: { ...empty.dispense, refillsAllowed: null } });
399
+ clickSign();
403
400
  expect(isInvalid("Unit")).toBe(false);
404
401
  expect(isInvalid("Refills")).toBe(false);
405
402
  });
406
403
 
407
- it("on Add, shows no errors when every required field is valid", () => {
408
- const { clickAdd } = renderFields();
409
- clickAdd();
404
+ it("on Sign, shows no errors when every required field is valid", () => {
405
+ const { clickSign } = renderFields();
406
+ clickSign();
410
407
  expect(isInvalid("Directions (sig)")).toBe(false);
411
408
  expect(isInvalid("Quantity")).toBe(false);
412
409
  expect(isInvalid("Days supply")).toBe(false);
413
410
  });
414
411
 
415
412
  it("clears a field's error once it's valid, and keeps the others'", () => {
416
- const { clickAdd } = renderFields(empty);
417
- clickAdd();
413
+ const { clickSign } = renderFields(empty);
414
+ clickSign();
418
415
  type("Quantity", "30");
419
416
  expect(isInvalid("Quantity")).toBe(false);
420
417
  expect(errorOf("Days supply")).toBe("Required");
@@ -422,35 +419,35 @@ describe("PrescriptionDetailsForm", () => {
422
419
  });
423
420
 
424
421
  it("shows a field's new error when its value changes to another invalid one", () => {
425
- const { clickAdd } = renderFields({ dispense: { quantity: null } });
426
- clickAdd();
422
+ const { clickSign } = renderFields({ dispense: { quantity: null } });
423
+ clickSign();
427
424
  expect(errorOf("Quantity")).toBe("Required");
428
425
  type("Quantity", "0");
429
426
  expect(errorOf("Quantity")).toBe("Must be greater than 0");
430
427
  });
431
428
  });
432
429
 
433
- describe("clicking Add", () => {
430
+ describe("clicking Sign", () => {
434
431
  it("doesn't add while a field has an error", () => {
435
- const { clickAdd, onAdd } = renderFields({ dispense: { daysSupply: null } });
436
- clickAdd();
437
- expect(onAdd).not.toHaveBeenCalled();
432
+ const { clickSign, onSign } = renderFields({ dispense: { daysSupply: null } });
433
+ clickSign();
434
+ expect(onSign).not.toHaveBeenCalled();
438
435
  });
439
436
 
440
437
  it("adds once every field is valid", () => {
441
- const { clickAdd, onAdd } = renderFields(empty);
442
- clickAdd();
438
+ const { clickSign, onSign } = renderFields(empty);
439
+ clickSign();
443
440
  type("Directions (sig)", directions);
444
441
  type("Quantity", "30");
445
442
  type("Days supply", "10");
446
- clickAdd();
447
- expect(onAdd).toHaveBeenCalledOnce();
443
+ clickSign();
444
+ expect(onSign).toHaveBeenCalledOnce();
448
445
  });
449
446
 
450
447
  it("adds at once when the prescription already has every required field", () => {
451
- const { clickAdd, onAdd } = renderFields();
452
- clickAdd();
453
- expect(onAdd).toHaveBeenCalledOnce();
448
+ const { clickSign, onSign } = renderFields();
449
+ clickSign();
450
+ expect(onSign).toHaveBeenCalledOnce();
454
451
  });
455
452
  });
456
453
  });
@@ -23,13 +23,13 @@ export interface PrescriptionDetailsFormProps {
23
23
  /** The field whose save is in flight. */
24
24
  spinning: string | null;
25
25
  save: (edits: PrescriptionEdits, from?: string) => void;
26
- /** Beside Add: the prescription's status (e.g. changed since signing). */
26
+ /** Beside Sign: the prescription's status (e.g. changed since signing). */
27
27
  status?: ReactNode;
28
- /** Add, once every field is valid: the card signs it. */
29
- onAdd: () => void;
28
+ /** Sign, once every field is valid: the card signs it. */
29
+ onSign: () => void;
30
30
  /** The add is in flight. */
31
- adding: boolean;
32
- addDisabled: boolean;
31
+ signing: boolean;
32
+ signDisabled: boolean;
33
33
  }
34
34
 
35
35
  export function PrescriptionDetailsForm({
@@ -41,9 +41,9 @@ export function PrescriptionDetailsForm({
41
41
  spinning,
42
42
  save,
43
43
  status,
44
- onAdd,
45
- adding,
46
- addDisabled,
44
+ onSign,
45
+ signing,
46
+ signDisabled,
47
47
  }: PrescriptionDetailsFormProps) {
48
48
  const { Button, CardBody, CardFooter, Stack } = useComponents();
49
49
  const [instructions, setInstructions] = useState(rx?.instructions ?? "");
@@ -94,9 +94,16 @@ export function PrescriptionDetailsForm({
94
94
  if (d?.dispenseAsWritten) setDaw(true);
95
95
  }
96
96
 
97
- // What's wrong with the fields: shown once Add is clicked (and following the values from then on), and never sent.
97
+ // What's wrong with the fields: shown once Sign is clicked (and following the values from then on), and never sent.
98
98
  const [showErrors, setShowErrors] = useState(false);
99
- const errors = schemaErrors(PrescriptionDetailsSchema, { instructions, quantity, daysSupply });
99
+ const errors = schemaErrors(PrescriptionDetailsSchema, {
100
+ instructions,
101
+ quantity,
102
+ unit,
103
+ daysSupply,
104
+ refills,
105
+ dispenseAsWritten: daw,
106
+ });
100
107
  const shown = showErrors ? errors : {};
101
108
  const invalid = (field: string) => field in errors;
102
109
 
@@ -105,7 +112,8 @@ export function PrescriptionDetailsForm({
105
112
  const dispense = (field: string, patch: DispensePatch) => {
106
113
  clean(field);
107
114
  if (patch.dispenseAsWritten !== undefined) setDaw(patch.dispenseAsWritten);
108
- if (!invalid(field)) save({ dispense: patch }, field);
115
+ // A unit is only saved as it's picked or filled in, before the errors catch up with it
116
+ if (field === "unit" || !invalid(field)) save({ dispense: patch }, field);
109
117
  };
110
118
 
111
119
  // Memoized so typing doesn't hand DirectionsInput new options, which would reopen them.
@@ -211,16 +219,16 @@ export function PrescriptionDetailsForm({
211
219
  <CardFooter start={status}>
212
220
  <Button
213
221
  variant="secondary" // Send is the page's one primary action
214
- // Not disabled while saving: clicking Add leaves a field, which saves it — the sign waits
222
+ // Not disabled while saving: clicking Sign leaves a field, which saves it — the sign waits
215
223
  // for that save (a disabled button would swallow the click).
216
- loading={adding}
217
- disabled={addDisabled}
224
+ loading={signing}
225
+ disabled={signDisabled}
218
226
  onClick={() => {
219
227
  setShowErrors(true);
220
- if (Object.keys(errors).length === 0) onAdd();
228
+ if (Object.keys(errors).length === 0) onSign();
221
229
  }}
222
230
  >
223
- Add
231
+ Sign
224
232
  </Button>
225
233
  </CardFooter>
226
234
  </>
@@ -1,63 +1,188 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import { schemaErrors } from "../../schemaErrors.ts";
3
- import { PrescriptionDetailsSchema, type PrescriptionDetails } from "./PrescriptionDetailsSchema.ts";
3
+ import { PrescriptionDetailsSchema, type PrescriptionDetailsFormValues } from "./PrescriptionDetailsSchema.ts";
4
4
 
5
- const errorsOf = (inputs: PrescriptionDetails) => schemaErrors(PrescriptionDetailsSchema, inputs);
5
+ const errorsOf = (values: PrescriptionDetailsFormValues) => schemaErrors(PrescriptionDetailsSchema, values);
6
6
 
7
- const valid = { instructions: "Take 1 capsule by mouth 3 times per day", quantity: "30", daysSupply: "10" };
7
+ /** Amoxicillin 500 mg capsules with only the required fields filled in. */
8
+ const valid: PrescriptionDetailsFormValues = {
9
+ instructions: "Take 1 capsule by mouth 3 times per day",
10
+ quantity: "30",
11
+ unit: "Capsule",
12
+ daysSupply: "10",
13
+ refills: "",
14
+ dispenseAsWritten: false,
15
+ };
8
16
 
9
17
  describe("PrescriptionDetailsSchema", () => {
10
- it("accepts directions, quantity and days supply that are filled in", () => {
11
- expect(PrescriptionDetailsSchema.safeParse(valid).success).toBe(true);
18
+ it("only required fields filled in: no errors, quantity and days supply parse as numbers, and blank refills as undefined", () => {
19
+ expect(errorsOf(valid)).toEqual({});
20
+ expect(PrescriptionDetailsSchema.parse(valid)).toEqual({
21
+ instructions: "Take 1 capsule by mouth 3 times per day",
22
+ quantity: 30,
23
+ unit: "Capsule",
24
+ daysSupply: 10,
25
+ refills: undefined,
26
+ dispenseAsWritten: false,
27
+ });
28
+ });
29
+
30
+ it("errors in several fields at once: reports every field's error together", () => {
31
+ expect(errorsOf({ ...valid, instructions: "", quantity: "abc", unit: "", daysSupply: "0", refills: "-1" })).toEqual(
32
+ {
33
+ instructions: "Required",
34
+ quantity: "Must be a number",
35
+ unit: "Required",
36
+ daysSupply: "Must be greater than 0",
37
+ refills: "Can't be less than 0",
38
+ },
39
+ );
12
40
  });
13
41
 
14
- it("parses values by trimming directions, converting text to numbers", () => {
15
- expect(PrescriptionDetailsSchema.parse({ instructions: " test ", quantity: " 2.5 ", daysSupply: "7" })).toEqual({
16
- instructions: "test",
17
- quantity: 2.5,
18
- daysSupply: 7,
42
+ describe("instructions", () => {
43
+ it("typed with spaces around it: no errors, and trims the value", () => {
44
+ expect(errorsOf({ ...valid, instructions: " Take 1 capsule daily " })).toEqual({});
45
+ expect(PrescriptionDetailsSchema.parse({ ...valid, instructions: " Take 1 capsule daily " }).instructions).toBe(
46
+ "Take 1 capsule daily",
47
+ );
48
+ });
49
+
50
+ it('empty string: errors with "Required"', () => {
51
+ expect(errorsOf({ ...valid, instructions: "" })).toEqual({ instructions: "Required" });
52
+ });
53
+
54
+ it('only spaces: errors with "Required"', () => {
55
+ expect(errorsOf({ ...valid, instructions: " " })).toEqual({ instructions: "Required" });
19
56
  });
20
57
  });
21
- });
22
58
 
23
- describe("PrescriptionDetailsSchema errors", () => {
24
- it("has no errors when every field is valid", () => {
25
- expect(errorsOf(valid)).toEqual({});
59
+ describe("quantity", () => {
60
+ it('whole number typed as "30": no errors, and parses as 30', () => {
61
+ expect(errorsOf({ ...valid, quantity: "30" })).toEqual({});
62
+ expect(PrescriptionDetailsSchema.parse({ ...valid, quantity: "30" }).quantity).toBe(30);
63
+ });
64
+
65
+ it('typed with spaces around it, " 30 ": no errors, and trims the value before parsing it as 30', () => {
66
+ expect(errorsOf({ ...valid, quantity: " 30 " })).toEqual({});
67
+ expect(PrescriptionDetailsSchema.parse({ ...valid, quantity: " 30 " }).quantity).toBe(30);
68
+ });
69
+
70
+ // network-api stores quantity as NUMERIC, so a fractional quantity (e.g. 2.5 mL) is accepted
71
+ it.each([
72
+ ["2.5", 2.5],
73
+ ["0.5", 0.5],
74
+ ])("decimal typed as %j: no errors, and parses as %j", (quantity, parsed) => {
75
+ expect(errorsOf({ ...valid, quantity })).toEqual({});
76
+ expect(PrescriptionDetailsSchema.parse({ ...valid, quantity }).quantity).toBe(parsed);
77
+ });
78
+
79
+ it('empty string: errors with "Required"', () => {
80
+ expect(errorsOf({ ...valid, quantity: "" })).toEqual({ quantity: "Required" });
81
+ });
82
+
83
+ it('only spaces: errors with "Required"', () => {
84
+ expect(errorsOf({ ...valid, quantity: " " })).toEqual({ quantity: "Required" });
85
+ });
86
+
87
+ it.each(["abc", "12abc"])('typed as %j: errors with "Must be a number"', (quantity) => {
88
+ expect(errorsOf({ ...valid, quantity })).toEqual({ quantity: "Must be a number" });
89
+ });
90
+
91
+ it.each(["0", "-5"])('typed as %j: errors with "Must be greater than 0"', (quantity) => {
92
+ expect(errorsOf({ ...valid, quantity })).toEqual({ quantity: "Must be greater than 0" });
93
+ });
26
94
  });
27
95
 
28
- it("says each empty field is required", () => {
29
- expect(errorsOf({ instructions: "", quantity: "", daysSupply: "" })).toEqual({
30
- instructions: "Required",
31
- quantity: "Required",
32
- daysSupply: "Required",
96
+ describe("unit", () => {
97
+ it("typed with spaces around it: no errors, and trims the value", () => {
98
+ expect(errorsOf({ ...valid, unit: " Tablet " })).toEqual({});
99
+ expect(PrescriptionDetailsSchema.parse({ ...valid, unit: " Tablet " }).unit).toBe("Tablet");
100
+ });
101
+
102
+ it('empty string: errors with "Required"', () => {
103
+ expect(errorsOf({ ...valid, unit: "" })).toEqual({ unit: "Required" });
104
+ });
105
+
106
+ it('only spaces: errors with "Required"', () => {
107
+ expect(errorsOf({ ...valid, unit: " " })).toEqual({ unit: "Required" });
33
108
  });
34
109
  });
35
110
 
36
- it.each([
37
- ["instructions", " "],
38
- ["quantity", " "],
39
- ["daysSupply", " "],
40
- ] as const)("counts %s of only spaces as empty", (field, value) => {
41
- expect(errorsOf({ ...valid, [field]: value })).toEqual({ [field]: "Required" });
111
+ describe("daysSupply", () => {
112
+ it('whole number typed as "10": no errors, and parses as 10', () => {
113
+ expect(errorsOf({ ...valid, daysSupply: "10" })).toEqual({});
114
+ expect(PrescriptionDetailsSchema.parse({ ...valid, daysSupply: "10" }).daysSupply).toBe(10);
115
+ });
116
+
117
+ it('typed with spaces around it, " 90 ": no errors, and trims the value before parsing it as 90', () => {
118
+ expect(errorsOf({ ...valid, daysSupply: " 90 " })).toEqual({});
119
+ expect(PrescriptionDetailsSchema.parse({ ...valid, daysSupply: " 90 " }).daysSupply).toBe(90);
120
+ });
121
+
122
+ it('empty string: errors with "Required"', () => {
123
+ expect(errorsOf({ ...valid, daysSupply: "" })).toEqual({ daysSupply: "Required" });
124
+ });
125
+
126
+ it('only spaces: errors with "Required"', () => {
127
+ expect(errorsOf({ ...valid, daysSupply: " " })).toEqual({ daysSupply: "Required" });
128
+ });
129
+
130
+ it('typed as "abc": errors with "Must be a number"', () => {
131
+ expect(errorsOf({ ...valid, daysSupply: "abc" })).toEqual({ daysSupply: "Must be a number" });
132
+ });
133
+
134
+ it('typed as "7.5": errors with "Must be a whole number"', () => {
135
+ expect(errorsOf({ ...valid, daysSupply: "7.5" })).toEqual({ daysSupply: "Must be a whole number" });
136
+ });
137
+
138
+ it.each(["0", "-1"])('typed as %j: errors with "Must be greater than 0"', (daysSupply) => {
139
+ expect(errorsOf({ ...valid, daysSupply })).toEqual({ daysSupply: "Must be greater than 0" });
140
+ });
42
141
  });
43
142
 
44
- it.each([
45
- ["quantity", "abc", "Must be a number"],
46
- ["quantity", "12abc", "Must be a number"],
47
- ["quantity", "0", "Must be greater than 0"],
48
- ["quantity", "-5", "Must be greater than 0"],
49
- ["daysSupply", "abc", "Must be a number"],
50
- ["daysSupply", "0", "Must be greater than 0"],
51
- ["daysSupply", "-1", "Must be greater than 0"],
52
- ] as const)("says %s of %j: %s", (field, value, message) => {
53
- expect(errorsOf({ ...valid, [field]: value })).toEqual({ [field]: message });
143
+ describe("refills", () => {
144
+ it.each([
145
+ ["0", 0],
146
+ ["3", 3],
147
+ ])("whole number typed as %j: no errors, and parses as %j", (refills, parsed) => {
148
+ expect(errorsOf({ ...valid, refills })).toEqual({});
149
+ expect(PrescriptionDetailsSchema.parse({ ...valid, refills }).refills).toBe(parsed);
150
+ });
151
+
152
+ it('typed with spaces around it, " 3 ": no errors, and trims the value before parsing it as 3', () => {
153
+ expect(errorsOf({ ...valid, refills: " 3 " })).toEqual({});
154
+ expect(PrescriptionDetailsSchema.parse({ ...valid, refills: " 3 " }).refills).toBe(3);
155
+ });
156
+
157
+ it("empty string: no errors because refills are optional, and parses as undefined", () => {
158
+ expect(errorsOf({ ...valid, refills: "" })).toEqual({});
159
+ expect(PrescriptionDetailsSchema.parse({ ...valid, refills: "" }).refills).toBeUndefined();
160
+ });
161
+
162
+ it("only spaces: no errors because refills are optional, and parses as undefined", () => {
163
+ expect(errorsOf({ ...valid, refills: " " })).toEqual({});
164
+ expect(PrescriptionDetailsSchema.parse({ ...valid, refills: " " }).refills).toBeUndefined();
165
+ });
166
+
167
+ it('typed as "abc": errors with "Must be a number"', () => {
168
+ expect(errorsOf({ ...valid, refills: "abc" })).toEqual({ refills: "Must be a number" });
169
+ });
170
+
171
+ it('typed as "1.5": errors with "Must be a whole number"', () => {
172
+ expect(errorsOf({ ...valid, refills: "1.5" })).toEqual({ refills: "Must be a whole number" });
173
+ });
174
+
175
+ it('typed as "-1": errors with "Can\'t be less than 0"', () => {
176
+ expect(errorsOf({ ...valid, refills: "-1" })).toEqual({ refills: "Can't be less than 0" });
177
+ });
54
178
  });
55
179
 
56
- it.each([
57
- ["quantity", "2.5"],
58
- ["quantity", "0.5"],
59
- ["daysSupply", "90"],
60
- ] as const)("accepts %s of %j", (field, value) => {
61
- expect(errorsOf({ ...valid, [field]: value })).toEqual({});
180
+ describe("dispenseAsWritten", () => {
181
+ it.each([true, false])("%s: no errors, and parses as the value checked", (dispenseAsWritten) => {
182
+ expect(errorsOf({ ...valid, dispenseAsWritten })).toEqual({});
183
+ expect(PrescriptionDetailsSchema.parse({ ...valid, dispenseAsWritten }).dispenseAsWritten).toBe(
184
+ dispenseAsWritten,
185
+ );
186
+ });
62
187
  });
63
188
  });
@@ -1,15 +1,47 @@
1
1
  import { z } from "zod";
2
2
 
3
- const textToNumber = z
4
- .string()
5
- .trim()
6
- .min(1, "Required")
7
- .pipe(z.coerce.number<string>({ error: "Must be a number" }).gt(0, "Must be greater than 0"));
8
-
9
3
  export const PrescriptionDetailsSchema = z.object({
10
4
  instructions: z.string().trim().min(1, "Required"),
11
- quantity: textToNumber,
12
- daysSupply: textToNumber,
5
+ quantity: z
6
+ .string()
7
+ .trim()
8
+ .min(1, "Required")
9
+ .pipe(z.coerce.number<string>({ error: "Must be a number" }).gt(0, "Must be greater than 0")),
10
+ unit: z.string().trim().min(1, "Required"),
11
+ daysSupply: z
12
+ .string()
13
+ .trim()
14
+ .min(1, "Required")
15
+ .pipe(
16
+ z.coerce
17
+ .number<string>({ error: "Must be a number" })
18
+ .int("Must be a whole number")
19
+ .gt(0, "Must be greater than 0"),
20
+ ),
21
+ // Refills are optional, so a blank field parses as undefined and is left out of the update
22
+ refills: z
23
+ .string()
24
+ .trim()
25
+ .transform((value) => value || undefined)
26
+ .pipe(
27
+ z.coerce
28
+ .number<string>({ error: "Must be a number" })
29
+ .int("Must be a whole number")
30
+ .min(0, "Can't be less than 0")
31
+ .optional(),
32
+ ),
33
+ dispenseAsWritten: z.boolean(),
13
34
  });
14
35
 
15
- export type PrescriptionDetails = z.input<typeof PrescriptionDetailsSchema>;
36
+ /** The values to send, once every field is valid. */
37
+ export type PrescriptionDetails = z.output<typeof PrescriptionDetailsSchema>;
38
+
39
+ /** What the form holds while the prescriber edits it. */
40
+ export type PrescriptionDetailsFormValues = {
41
+ instructions: string;
42
+ quantity: string;
43
+ unit: string;
44
+ daysSupply: string;
45
+ refills: string;
46
+ dispenseAsWritten: boolean;
47
+ };
@@ -1,7 +1,6 @@
1
- // @vitest-environment jsdom
2
1
  import type { PrescriptionTemplate } from "@photonhealth/client";
3
- import { cleanup, fireEvent, render, screen, within } from "@testing-library/react";
4
- import { afterEach, describe, expect, it, vi } from "vitest";
2
+ import { fireEvent, render, screen, within } from "@testing-library/react";
3
+ import { describe, expect, it, vi } from "vitest";
5
4
  import { TemplatePicker, type TemplatePickerProps } from "./TemplatePicker.tsx";
6
5
 
7
6
  const sig = (instructions: string): PrescriptionTemplate => ({
@@ -21,8 +20,6 @@ const renderPicker = (props: Partial<TemplatePickerProps> = {}) => {
21
20
  };
22
21
 
23
22
  describe("TemplatePicker", () => {
24
- afterEach(() => cleanup());
25
-
26
23
  it("renders an expanded list for a new draft", () => {
27
24
  renderPicker({ templates: [sig("Take 1 capsule by mouth daily"), sig("Take 2 capsules by mouth daily")] });
28
25
  const offered = within(options()!)
@@ -1,7 +1,6 @@
1
- // @vitest-environment jsdom
2
- import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
1
+ import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
3
2
  import userEvent from "@testing-library/user-event";
4
- import { afterEach, describe, expect, it } from "vitest";
3
+ import { describe, expect, it } from "vitest";
5
4
  import { payload, rx, fakeNetworkApiClient } from "@photonhealth/client/testing";
6
5
  import { PhotonPrescription, type PhotonPrescriptionProps } from "../../../index.ts";
7
6
  import {
@@ -19,9 +18,6 @@ import {
19
18
  // Treatment search on a prescription card: finding the drug, picking its form and strength, and what the card shows
20
19
  // once the product is picked — through <PhotonPrescription>, which it saves through. In the stock building blocks:
21
20
  // every set of building blocks is held to the same contract.
22
-
23
- afterEach(cleanup);
24
-
25
21
  const lisinoprilTablets10And20Mg = choices(
26
22
  option("Lisinopril Oral Tablet 10 MG", "med_10"),
27
23
  option("Lisinopril Oral Tablet 20 MG", "med_20"),
@@ -127,7 +123,7 @@ describe("TreatmentSearch", () => {
127
123
  });
128
124
  const med = await component.typeIntoTreatment("amoxicillin 500 mg capsule");
129
125
  fireEvent.keyDown(med, { key: "Enter" });
130
- await screen.findByRole("button", { name: "Add" });
126
+ await screen.findByRole("button", { name: "Sign" });
131
127
  await new Promise((r) => setTimeout(r, 700)); // past the type-ahead debounce
132
128
  expect(component.names()).not.toContain("UpdatePrescription");
133
129
  expect(screen.getByRole("heading", { name: /amoxicillin/i })).toBeTruthy();
@@ -10,11 +10,12 @@ export type SchemaErrors<T> = T extends readonly (infer Item)[]
10
10
  type Node = Record<PropertyKey, unknown>;
11
11
 
12
12
  /**
13
- * Return errors from Zod schema.parse in a friendlier shape
13
+ * Return errors from Zod schema.parse in a friendlier shape. The input is `unknown`: it is what the form holds before
14
+ * validation, which the schema must be able to refuse.
14
15
  */
15
16
  export function schemaErrors<S extends z.ZodType<unknown, object>>(
16
17
  schema: S,
17
- input: z.input<S>,
18
+ input: unknown,
18
19
  ): SchemaErrors<z.input<S>> {
19
20
  const errors: Node = {};
20
21
  const result = schema.safeParse(input);
@@ -6,7 +6,7 @@
6
6
  * patient search 2, drugs and clinical entries 3) and typing pauses, it searches; each
7
7
  * keystroke cancels the search waiting, and the live object aborts one in flight. Leaving the field (or
8
8
  * Enter) sends at once. Patients and drugs search without writing; for allergies, meds and diagnoses a
9
- * search is an add — a unique match is the entry (see ClinicalList).
9
+ * search is an add — a unique match is the entry (see ClinicalInputForm).
10
10
  * - Results (`SearchResults`): the first five, then "Show N more". In the list, 1–9 and 0 pick one (of those shown),
11
11
  * ↑ ↓ (or K J) move, Home / End (or g / G) go to the first / last, and Esc goes back to the field that searched
12
12
  * (← → and h l are the card flow's, / its search box: flow.ts).
package/src/index.ts CHANGED
@@ -15,7 +15,7 @@
15
15
  */
16
16
  export * from "./primitives/index.ts";
17
17
  export { useLive, useSession } from "./hooks/index.ts";
18
- export { PhotonAnalyticsProvider } from "./analytics/PhotonAnalyticsProvider.tsx";
18
+ export { PhotonAnalyticsProvider, usePhotonAnalytics } from "./analytics/PhotonAnalyticsProvider.tsx";
19
19
  export type { AnalyticsProperties } from "./analytics/tracker.ts";
20
20
  export { PhotonOrder, PhotonPatient, PhotonPrescription } from "./components/index.ts";
21
21
  export type { PhotonOrderProps, PhotonPatientProps, PhotonPrescriptionProps } from "./components/index.ts";
@@ -1,3 +1,4 @@
1
+ // @vitest-environment node
1
2
  import { readFileSync } from "node:fs";
2
3
  import { describe, expect, it } from "vitest";
3
4
  import { reactPackage } from "./version.ts";
@@ -1,4 +1,4 @@
1
1
  export const reactPackage: { readonly name: string; readonly version: string } = {
2
2
  name: "@photonhealth/react",
3
- version: "0.10.0",
3
+ version: "0.13.0",
4
4
  };
@@ -1 +0,0 @@
1
- {"version":3,"file":"Benefits.d.ts","sourceRoot":"","sources":["../../../src/components/patient/Benefits.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAA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