@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,37 +0,0 @@
1
- export interface ParsedQuery {
2
- name?: {
3
- first?: string;
4
- last?: string;
5
- };
6
- dateOfBirth?: string;
7
- phone?: string;
8
- email?: string;
9
- }
10
- /**
11
- * What was typed, as the server takes it. Anything that reads as a date, a phone or an email is taken as
12
- * one; what's left is the name, first word first. A single word is a first name — `searchBoth` says when
13
- * it's worth trying as a last name too.
14
- */
15
- export declare function parseQuery(text: string): ParsedQuery;
16
- /** query as patient input */
17
- export declare const toSearchInput: ({ phone, email, ...demographic }: ParsedQuery) => {
18
- demographic: {
19
- name?: {
20
- first?: string;
21
- last?: string;
22
- };
23
- dateOfBirth?: string;
24
- };
25
- contact: {
26
- email?: string | undefined;
27
- phone?: string | undefined;
28
- };
29
- };
30
- /** Whether a query says anything the server can match on. */
31
- export declare const isSearchable: (q: ParsedQuery) => boolean;
32
- /**
33
- * One word could be either name. It goes as a first name; if nothing comes back, it's worth asking again
34
- * as a last name — "Lovelace" is as likely as "Ada".
35
- */
36
- export declare const searchBoth: (q: ParsedQuery) => ParsedQuery | null;
37
- //# sourceMappingURL=query.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/components/patient/query.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAoBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAuBpD;AAED,6BAA6B;AAC7B,eAAO,MAAM,aAAa,GAAI,kCAAkC,WAAW;;eAvDlE;YAAE,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,EAAE,GAAG,WAAW,EAAe,EAAE,EAAE,CAAC,CAAC;IAC/E,WAAW;IACX,OAAO,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;CACtE,CAAC,CAAC;AAEH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAc,EAAE,EAAE,CAC7C,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAc,EAAsB,EAAE,CAC/D,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC"}
@@ -1,89 +0,0 @@
1
- // @vitest-environment jsdom
2
- import { fireEvent, render, screen } from "@testing-library/react";
3
- import userEvent from "@testing-library/user-event";
4
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
5
- import { fakeNetworkApiClient, noMatch } from "@photonhealth/client/testing";
6
- import { PhotonPatient } from "../../index.ts";
7
- import {
8
- edited,
9
- leaveField,
10
- meAsPrescriber,
11
- recordAnalytics,
12
- type RecordedAnalytics,
13
- typeInto,
14
- unmountAndRestoreFetch,
15
- visitedWithoutEditing,
16
- withAnalytics,
17
- } from "../../../test/analytics.fixtures.tsx";
18
-
19
- let analytics: RecordedAnalytics;
20
- beforeEach(() => {
21
- analytics = recordAnalytics();
22
- });
23
- afterEach(unmountAndRestoreFetch);
24
-
25
- const renderPatientCard = () =>
26
- render(<PhotonPatient />, {
27
- wrapper: withAnalytics(fakeNetworkApiClient({ ...meAsPrescriber, SyncPatient: noMatch }).client),
28
- });
29
-
30
- describe("PatientIntakeForm: Field Interaction", () => {
31
- it("Find patient is find_patient's patientSearch: focus, one change, blur, and nothing typed", async () => {
32
- renderPatientCard();
33
- await typeInto("Find patient", "Zqxfirst Zqxlast");
34
-
35
- await analytics.expectEventLog([
36
- "Field Interaction patientSearch focus",
37
- "Prescribe Workflow Viewed",
38
- "Field Interaction patientSearch change",
39
- "Field Interaction patientSearch blur",
40
- ]);
41
- expect(analytics.sentFor("patientSearch")).toEqual([
42
- expect.objectContaining({ formName: "find_patient", hasValue: false, isOptional: false }),
43
- expect.objectContaining({ hasValue: true }),
44
- expect.objectContaining({ hasValue: true, changed: true, durationMs: expect.any(Number) }),
45
- ]);
46
- for (const body of analytics.bodies()) expect(body).not.toMatch(/Zqx/i);
47
- });
48
-
49
- it("adding a patient: each field visited sends focus, one change and blur as new_patient_form", async () => {
50
- renderPatientCard();
51
- await typeInto("Find patient", "Zqxfirst Zqxlast");
52
- await userEvent.click(await screen.findByRole("option", { name: /Add new patient/ }));
53
- await typeInto("First name", "Zqxa");
54
- await typeInto("Last name", "Zqxb");
55
- await userEvent.click(screen.getByLabelText("Date of birth"));
56
- fireEvent.change(screen.getByLabelText("Date of birth"), { target: { value: "1990-01-01" } });
57
- leaveField();
58
- await userEvent.selectOptions(screen.getByRole("combobox", { name: "Sex" }), "FEMALE");
59
- leaveField();
60
- await typeInto("Phone", "5555550100");
61
- await typeInto("Email", "zqx@example.com");
62
-
63
- await analytics.expectEventLog([
64
- "Field Interaction patientSearch focus",
65
- "Prescribe Workflow Viewed",
66
- "Field Interaction patientSearch change",
67
- "Field Interaction patientSearch blur",
68
- ...visitedWithoutEditing("firstName"),
69
- ...visitedWithoutEditing("sex"),
70
- ...edited("firstName"),
71
- ...edited("lastName"),
72
- ...edited("dateOfBirth"),
73
- ...edited("sex"),
74
- ...edited("phone"),
75
- ...edited("email"),
76
- ]);
77
- const sent = analytics.fieldInteractions().filter((s) => s.fieldName !== "patientSearch");
78
- expect(new Set(sent.map((s) => s.formName))).toEqual(new Set(["new_patient_form"]));
79
- expect(Object.fromEntries(sent.map((s) => [s.fieldName, s.isOptional]))).toEqual({
80
- firstName: false,
81
- lastName: false,
82
- dateOfBirth: false,
83
- sex: false,
84
- phone: true,
85
- email: true,
86
- });
87
- for (const body of analytics.bodies()) expect(body).not.toMatch(/Zqx|1990|5555550100|FEMALE/i);
88
- });
89
- });