@photonhealth/client 2.0.0-rc.1 → 2.0.0-rc.2

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 (152) hide show
  1. package/README.md +150 -5
  2. package/dist/analytics/lifecycleEvents.d.ts +29 -0
  3. package/dist/analytics/lifecycleEvents.d.ts.map +1 -0
  4. package/dist/analytics/lifecycleEvents.js +72 -0
  5. package/dist/analytics/lifecycleEvents.js.map +1 -0
  6. package/dist/api/client.d.ts +6 -1
  7. package/dist/api/client.d.ts.map +1 -1
  8. package/dist/api/client.js +47 -33
  9. package/dist/api/client.js.map +1 -1
  10. package/dist/api/index.d.ts +2 -0
  11. package/dist/api/index.d.ts.map +1 -1
  12. package/dist/api/index.js +2 -0
  13. package/dist/api/index.js.map +1 -1
  14. package/dist/api/me.d.ts +37 -0
  15. package/dist/api/me.d.ts.map +1 -0
  16. package/dist/api/me.js +6 -0
  17. package/dist/api/me.js.map +1 -0
  18. package/dist/api/orders.d.ts +1047 -0
  19. package/dist/api/orders.d.ts.map +1 -0
  20. package/dist/api/orders.js +7 -0
  21. package/dist/api/orders.js.map +1 -0
  22. package/dist/api/patient.d.ts +5 -2
  23. package/dist/api/patient.d.ts.map +1 -1
  24. package/dist/api/patient.js +1 -1
  25. package/dist/api/patient.js.map +1 -1
  26. package/dist/api/prescription.d.ts +7 -1
  27. package/dist/api/prescription.d.ts.map +1 -1
  28. package/dist/api/prescription.js +10 -1
  29. package/dist/api/prescription.js.map +1 -1
  30. package/dist/gql/gql.d.ts +11 -3
  31. package/dist/gql/gql.d.ts.map +1 -1
  32. package/dist/gql/gql.js +5 -3
  33. package/dist/gql/gql.js.map +1 -1
  34. package/dist/gql/graphql.d.ts +10507 -1563
  35. package/dist/gql/graphql.d.ts.map +1 -1
  36. package/dist/gql/graphql.js +2984 -435
  37. package/dist/gql/graphql.js.map +1 -1
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.js +1 -1
  40. package/dist/meta/version.d.ts +2 -0
  41. package/dist/meta/version.d.ts.map +1 -0
  42. package/dist/meta/version.js +2 -0
  43. package/dist/meta/version.js.map +1 -0
  44. package/dist/photon/analytics.d.ts +39 -0
  45. package/dist/photon/analytics.d.ts.map +1 -0
  46. package/dist/photon/analytics.js +91 -0
  47. package/dist/photon/analytics.js.map +1 -0
  48. package/dist/photon/auth.d.ts +9 -5
  49. package/dist/photon/auth.d.ts.map +1 -1
  50. package/dist/photon/auth.js +2 -6
  51. package/dist/photon/auth.js.map +1 -1
  52. package/dist/photon/choices.d.ts +1 -1
  53. package/dist/photon/choices.js +2 -2
  54. package/dist/photon/choices.js.map +1 -1
  55. package/dist/photon/environments.d.ts +2 -1
  56. package/dist/photon/environments.d.ts.map +1 -1
  57. package/dist/photon/environments.js +2 -1
  58. package/dist/photon/environments.js.map +1 -1
  59. package/dist/photon/index.d.ts +6 -3
  60. package/dist/photon/index.d.ts.map +1 -1
  61. package/dist/photon/index.js +2 -1
  62. package/dist/photon/index.js.map +1 -1
  63. package/dist/photon/machine.d.ts +28 -0
  64. package/dist/photon/machine.d.ts.map +1 -0
  65. package/dist/photon/machine.js +53 -0
  66. package/dist/photon/machine.js.map +1 -0
  67. package/dist/photon/map.d.ts +6 -2
  68. package/dist/photon/map.d.ts.map +1 -1
  69. package/dist/photon/map.js +133 -33
  70. package/dist/photon/map.js.map +1 -1
  71. package/dist/photon/order.d.ts +21 -1
  72. package/dist/photon/order.d.ts.map +1 -1
  73. package/dist/photon/order.js +79 -12
  74. package/dist/photon/order.js.map +1 -1
  75. package/dist/photon/orders.d.ts +5 -0
  76. package/dist/photon/orders.d.ts.map +1 -0
  77. package/dist/photon/orders.js +39 -0
  78. package/dist/photon/orders.js.map +1 -0
  79. package/dist/photon/patient.d.ts +8 -6
  80. package/dist/photon/patient.d.ts.map +1 -1
  81. package/dist/photon/patient.js +61 -30
  82. package/dist/photon/patient.js.map +1 -1
  83. package/dist/photon/photon.d.ts +39 -1
  84. package/dist/photon/photon.d.ts.map +1 -1
  85. package/dist/photon/photon.js +85 -5
  86. package/dist/photon/photon.js.map +1 -1
  87. package/dist/photon/prescription.d.ts +17 -4
  88. package/dist/photon/prescription.d.ts.map +1 -1
  89. package/dist/photon/prescription.js +48 -11
  90. package/dist/photon/prescription.js.map +1 -1
  91. package/dist/photon/session.d.ts +15 -10
  92. package/dist/photon/session.d.ts.map +1 -1
  93. package/dist/photon/session.js +5 -3
  94. package/dist/photon/session.js.map +1 -1
  95. package/dist/photon/types.d.ts +278 -46
  96. package/dist/photon/types.d.ts.map +1 -1
  97. package/dist/test-utils/msw.d.ts +2 -2
  98. package/dist/test-utils/msw.d.ts.map +1 -1
  99. package/dist/test-utils/msw.js +5 -5
  100. package/dist/test-utils/msw.js.map +1 -1
  101. package/dist/testing/{scriptedClient.d.ts → fakeNetworkApiClient.d.ts} +5 -4
  102. package/dist/testing/fakeNetworkApiClient.d.ts.map +1 -0
  103. package/dist/testing/{scriptedClient.js → fakeNetworkApiClient.js} +8 -4
  104. package/dist/testing/fakeNetworkApiClient.js.map +1 -0
  105. package/dist/testing/fixtures.d.ts +1047 -0
  106. package/dist/testing/fixtures.d.ts.map +1 -1
  107. package/dist/testing/fixtures.js +47 -13
  108. package/dist/testing/fixtures.js.map +1 -1
  109. package/dist/testing.d.ts +4 -4
  110. package/dist/testing.d.ts.map +1 -1
  111. package/dist/testing.js +4 -4
  112. package/dist/testing.js.map +1 -1
  113. package/package.json +2 -2
  114. package/src/analytics/lifecycleEvents.test.ts +417 -0
  115. package/src/analytics/lifecycleEvents.ts +155 -0
  116. package/src/api/client.ts +71 -46
  117. package/src/api/index.ts +2 -0
  118. package/src/api/me.ts +7 -0
  119. package/src/api/orders.ts +8 -0
  120. package/src/api/patient.ts +11 -2
  121. package/src/api/prescription.ts +18 -0
  122. package/src/gql/gql.ts +21 -9
  123. package/src/gql/graphql.ts +4280 -597
  124. package/src/index.ts +1 -1
  125. package/src/meta/version.test.ts +10 -0
  126. package/src/meta/version.ts +1 -0
  127. package/src/operations/fragments.graphql +166 -20
  128. package/src/operations/me.graphql +38 -0
  129. package/src/operations/orders.graphql +35 -0
  130. package/src/operations/patient.graphql +29 -3
  131. package/src/operations/prescription.graphql +20 -0
  132. package/src/photon/analytics.ts +129 -0
  133. package/src/photon/auth.ts +9 -10
  134. package/src/photon/choices.ts +2 -2
  135. package/src/photon/environments.ts +3 -1
  136. package/src/photon/index.ts +16 -2
  137. package/src/photon/machine.ts +90 -0
  138. package/src/photon/map.ts +151 -35
  139. package/src/photon/order.test.ts +142 -0
  140. package/src/photon/order.ts +92 -12
  141. package/src/photon/orders.ts +42 -0
  142. package/src/photon/patient.ts +73 -33
  143. package/src/photon/photon.ts +139 -6
  144. package/src/photon/prescription.ts +71 -12
  145. package/src/photon/session.ts +18 -9
  146. package/src/photon/types.ts +280 -26
  147. package/src/test-utils/msw.ts +16 -5
  148. package/src/testing/{scriptedClient.ts → fakeNetworkApiClient.ts} +8 -4
  149. package/src/testing/fixtures.ts +55 -13
  150. package/src/testing.ts +6 -3
  151. package/dist/testing/scriptedClient.d.ts.map +0 -1
  152. package/dist/testing/scriptedClient.js.map +0 -1
@@ -0,0 +1,155 @@
1
+ import type { AnalyticsProperties } from "../photon/analytics.ts";
2
+ import type { OrderRecord, PatientRecord, PrescriptionRecord, ScreeningAlert } from "../photon/types.ts";
3
+
4
+ export type LifecycleEventName =
5
+ | "Patient Created"
6
+ | "Patient Updated"
7
+ | "Draft Prescription Added"
8
+ | "Draft Prescription Deleted"
9
+ | "Screening Alert Acknowledged"
10
+ | "Screening Alert Canceled"
11
+ | "Prescription Signed"
12
+ | "Order Sent";
13
+
14
+ export type DraftPrescriptionSource = "form" | "template_prefill" | "prescription_id_prefill";
15
+
16
+ export type PatientForLifecycleAnalytics = Pick<PatientRecord, "id" | "demographic" | "contact" | "preferredPharmacy">;
17
+
18
+ export type DraftPrescriptionForLifecycleAnalytics = Pick<
19
+ PrescriptionRecord,
20
+ "id" | "treatment" | "dispense" | "instructions"
21
+ > & {
22
+ clinical: { notes: string | null } | null;
23
+ };
24
+
25
+ export type PrescriptionForLifecycleAnalytics = Pick<PrescriptionRecord, "id">;
26
+
27
+ export type OrderForLifecycleAnalytics = Pick<OrderRecord, "id"> & {
28
+ prescriptions: readonly PrescriptionForLifecycleAnalytics[];
29
+ pharmacy: Pick<NonNullable<OrderRecord["pharmacy"]>, "fulfillmentType"> | null;
30
+ };
31
+
32
+ export interface LifecycleAnalytics {
33
+ patientCreated(patient: PatientForLifecycleAnalytics, properties?: AnalyticsProperties): Promise<void>;
34
+ patientUpdated(patient: PatientForLifecycleAnalytics, properties?: AnalyticsProperties): Promise<void>;
35
+ draftPrescriptionAdded(
36
+ prescription: DraftPrescriptionForLifecycleAnalytics,
37
+ source: DraftPrescriptionSource,
38
+ properties?: AnalyticsProperties,
39
+ ): Promise<void>;
40
+ draftPrescriptionDeleted(prescriptionId: string, properties?: AnalyticsProperties): Promise<void>;
41
+ screeningAlertAcknowledged(
42
+ alerts: readonly ScreeningAlert[],
43
+ buttonText: string,
44
+ properties?: AnalyticsProperties,
45
+ ): Promise<void>;
46
+ screeningAlertCanceled(
47
+ alerts: readonly ScreeningAlert[],
48
+ buttonText: string,
49
+ properties?: AnalyticsProperties,
50
+ ): Promise<void>;
51
+ prescriptionSigned(prescription: PrescriptionForLifecycleAnalytics, properties?: AnalyticsProperties): Promise<void>;
52
+ orderSent(order: OrderForLifecycleAnalytics, properties?: AnalyticsProperties): Promise<void>;
53
+ }
54
+
55
+ type Track = (event: string, properties?: AnalyticsProperties) => Promise<void>;
56
+
57
+ const SEND_TO_PATIENT = "SEND_TO_PATIENT";
58
+
59
+ export function lifecycleAnalyticsSentWith(track: Track): LifecycleAnalytics {
60
+ const sendCtaClicked = (
61
+ event: LifecycleEventName,
62
+ derivedProperties: AnalyticsProperties,
63
+ callerProperties: AnalyticsProperties = {},
64
+ ) => track(event, { ...callerProperties, category: "ctaClicked", ...derivedProperties });
65
+
66
+ return {
67
+ patientCreated: (patient, properties) => sendCtaClicked("Patient Created", patientProperties(patient), properties),
68
+ patientUpdated: (patient, properties) => sendCtaClicked("Patient Updated", patientProperties(patient), properties),
69
+ draftPrescriptionAdded: (prescription, source, properties) =>
70
+ sendCtaClicked(
71
+ "Draft Prescription Added",
72
+ {
73
+ prescriptionId: prescription.id,
74
+ draftPrescriptionSource: source,
75
+ ...prescriptionFormSnapshot(prescription),
76
+ },
77
+ properties,
78
+ ),
79
+ draftPrescriptionDeleted: (prescriptionId, properties) =>
80
+ sendCtaClicked("Draft Prescription Deleted", { prescriptionId }, properties),
81
+ screeningAlertAcknowledged: (alerts, buttonText, properties) =>
82
+ sendCtaClicked("Screening Alert Acknowledged", { screeningAlertCount: alerts.length, buttonText }, properties),
83
+ screeningAlertCanceled: (alerts, buttonText, properties) =>
84
+ sendCtaClicked("Screening Alert Canceled", { screeningAlertCount: alerts.length, buttonText }, properties),
85
+ prescriptionSigned: (prescription, properties) =>
86
+ sendCtaClicked("Prescription Signed", { prescriptionId: prescription.id }, properties),
87
+ orderSent: (order, properties) =>
88
+ sendCtaClicked(
89
+ "Order Sent",
90
+ {
91
+ orderId: order.id,
92
+ prescriptionCount: order.prescriptions.length,
93
+ prescriptionIds: order.prescriptions.map((prescription) => prescription.id),
94
+ fulfillmentType: fulfillmentTypeOf(order),
95
+ },
96
+ properties,
97
+ ),
98
+ };
99
+ }
100
+
101
+ function patientProperties(patient: PatientForLifecycleAnalytics): AnalyticsProperties {
102
+ return { patientId: patient.id, ...patientFormSnapshot(patient) };
103
+ }
104
+
105
+ function fulfillmentTypeOf(order: OrderForLifecycleAnalytics): string | null {
106
+ if (!order.pharmacy) return SEND_TO_PATIENT;
107
+ const offeredTypes = order.pharmacy.fulfillmentType ?? [];
108
+ return offeredTypes.length === 1 ? offeredTypes[0]! : null;
109
+ }
110
+
111
+ function patientFormSnapshot(patient: PatientForLifecycleAnalytics): AnalyticsProperties {
112
+ const { demographic, contact, preferredPharmacy } = patient;
113
+ return completedFieldSnapshot({
114
+ firstName: demographic?.name.first,
115
+ lastName: demographic?.name.last,
116
+ dateOfBirth: demographic?.dateOfBirth,
117
+ phone: contact?.phone,
118
+ sex: demographic?.sex,
119
+ gender: demographic?.gender,
120
+ email: contact?.email,
121
+ address_street1: contact?.address?.street1,
122
+ address_street2: contact?.address?.street2,
123
+ address_city: contact?.address?.city,
124
+ address_state: contact?.address?.state,
125
+ address_zip: contact?.address?.postalCode,
126
+ preferredPharmacy,
127
+ });
128
+ }
129
+
130
+ function prescriptionFormSnapshot(prescription: DraftPrescriptionForLifecycleAnalytics): AnalyticsProperties {
131
+ const { treatment, dispense, instructions, clinical } = prescription;
132
+ return completedFieldSnapshot({
133
+ treatment,
134
+ dispenseQuantity: dispense?.quantity,
135
+ dispenseUnit: dispense?.unit,
136
+ daysSupply: dispense?.daysSupply,
137
+ refills: dispense?.refillsAllowed,
138
+ instructions,
139
+ notes: clinical?.notes,
140
+ });
141
+ }
142
+
143
+ function completedFieldSnapshot(valuesByFieldName: Record<string, unknown>): AnalyticsProperties {
144
+ return Object.fromEntries(
145
+ Object.entries(valuesByFieldName).map(([fieldName, value]) => [snapshotPropertyName(fieldName), isFilled(value)]),
146
+ );
147
+ }
148
+
149
+ function snapshotPropertyName(fieldName: string): string {
150
+ return `snap_${fieldName.replace(/([A-Z])/g, "_$1").toLowerCase()}`;
151
+ }
152
+
153
+ function isFilled(value: unknown): boolean {
154
+ return value !== undefined && value !== null && value !== "" && value !== false;
155
+ }
package/src/api/client.ts CHANGED
@@ -11,7 +11,7 @@ import type { TypedDocumentString } from "../gql/graphql.ts";
11
11
  interface NetworkClientOptions {
12
12
  /** e.g. https://network.boson.health/graphql */
13
13
  url: string;
14
- /** Returns an Auth0 access token for the prescriber (audience https://api.<env>.health). */
14
+ /** Returns a token accepted by network-api, including a patient token or a prescriber's access token. */
15
15
  getToken: () => Promise<string>;
16
16
  /** How this client is surfaced. Embeds should pass EMBEDDABLE_COMPONENT. */
17
17
  source?: RequestSource;
@@ -19,6 +19,11 @@ interface NetworkClientOptions {
19
19
  clientName?: string;
20
20
  sourceVersion?: string;
21
21
  fetch?: typeof fetch;
22
+ /**
23
+ * When network-api refuses the token (401, UNAUTHENTICATED): drop it — the call is then tried once more, with a new one. For a
24
+ * token core gets itself (client credentials); a host's `getToken` or a prescriber's session doesn't retry.
25
+ */
26
+ onUnauthorized?: () => void;
22
27
  }
23
28
 
24
29
  /** Variables for an operation, minus the metadata the client fills in. */
@@ -72,53 +77,73 @@ export function createNetworkClient(options: NetworkClientOptions): NetworkClien
72
77
  const doFetch: typeof fetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
73
78
  const clientName = options.clientName ?? "photon-rx";
74
79
 
75
- return {
80
+ const client: NetworkClient = {
76
81
  async execute(document, variables, { signal } = {}) {
77
- const operationName = operationNameOf(document);
78
- const metadata: RequestMetadata = {
79
- source: options.source ?? "WEB_APP",
80
- client: `${clientName}/${operationName}`,
81
- sourceVersion: options.sourceVersion,
82
- requestId: requestId(),
83
- };
84
- const token = await options.getToken();
85
-
86
- const response = await doFetch(options.url, {
87
- method: "POST",
88
- signal,
89
- headers: {
90
- "content-type": "application/json",
91
- accept: "application/graphql-response+json, application/json",
92
- // Standard Bearer (network-api also still takes x-photon-auth-token). CORS allows only
93
- // Authorization, Content-Type and x-photon-auth-token — any other custom header fails preflight.
94
- authorization: `Bearer ${token}`,
95
- },
96
- body: JSON.stringify({
97
- operationName,
98
- query: document.toString(),
99
- // Every mutation takes RequestMetadata; queries (Ping) just ignore it.
100
- variables: document.toString().includes("$metadata")
101
- ? { ...trimStrings(variables), metadata }
102
- : trimStrings(variables),
103
- }),
104
- });
105
-
106
- const body = (await response.json().catch(() => null)) as {
107
- data?: unknown;
108
- errors?: { message: string; extensions?: { code?: string } }[];
109
- } | null;
110
-
111
- if (body?.errors?.length || !body?.data) {
112
- const first = body?.errors?.[0];
113
- throw new NetworkTransportError(
114
- first?.message ?? `network-api responded ${response.status}`,
115
- operationName,
116
- response.status,
117
- first?.extensions?.code,
118
- body?.errors,
119
- );
82
+ try {
83
+ return await once(document, variables, signal);
84
+ } catch (e) {
85
+ if (
86
+ !options.onUnauthorized ||
87
+ !(e instanceof NetworkTransportError) ||
88
+ (e.status !== 401 && e.code !== "UNAUTHENTICATED")
89
+ )
90
+ throw e;
91
+ options.onUnauthorized();
92
+ return once(document, variables, signal);
120
93
  }
121
- return body.data as never;
122
94
  },
123
95
  };
96
+ return client;
97
+
98
+ async function once<R, V>(
99
+ document: TypedDocumentString<R, V>,
100
+ variables: OperationVariables<V>,
101
+ signal?: AbortSignal,
102
+ ): Promise<R> {
103
+ const operationName = operationNameOf(document);
104
+ const metadata: RequestMetadata = {
105
+ source: options.source ?? "WEB_APP",
106
+ client: `${clientName}/${operationName}`,
107
+ sourceVersion: options.sourceVersion,
108
+ requestId: requestId(),
109
+ };
110
+ const token = await options.getToken();
111
+
112
+ const response = await doFetch(options.url, {
113
+ method: "POST",
114
+ signal,
115
+ headers: {
116
+ "content-type": "application/json",
117
+ accept: "application/graphql-response+json, application/json",
118
+ // Standard Bearer (network-api also still takes x-photon-auth-token). CORS allows only
119
+ // Authorization, Content-Type and x-photon-auth-token — any other custom header fails preflight.
120
+ authorization: `Bearer ${token}`,
121
+ },
122
+ body: JSON.stringify({
123
+ operationName,
124
+ query: document.toString(),
125
+ // Every mutation takes RequestMetadata; queries (Ping) just ignore it.
126
+ variables: document.toString().includes("$metadata")
127
+ ? { ...trimStrings(variables), metadata }
128
+ : trimStrings(variables),
129
+ }),
130
+ });
131
+
132
+ const body = (await response.json().catch(() => null)) as {
133
+ data?: unknown;
134
+ errors?: { message: string; extensions?: { code?: string } }[];
135
+ } | null;
136
+
137
+ if (body?.errors?.length || !body?.data) {
138
+ const first = body?.errors?.[0];
139
+ throw new NetworkTransportError(
140
+ first?.message ?? `network-api responded ${response.status}`,
141
+ operationName,
142
+ response.status,
143
+ first?.extensions?.code,
144
+ body?.errors,
145
+ );
146
+ }
147
+ return body.data as never;
148
+ }
124
149
  }
package/src/api/index.ts CHANGED
@@ -14,9 +14,11 @@
14
14
  export * from "./client.ts";
15
15
  export * from "./results.ts";
16
16
  export * from "./health.ts";
17
+ export * from "./me.ts";
17
18
  export * from "./patient.ts";
18
19
  export * from "./prescription.ts";
19
20
  export * from "./order.ts";
21
+ export * from "./orders.ts";
20
22
  export * from "./changes/index.ts";
21
23
  // Schema types (inputs, enums, fragments) generated from network-api.
22
24
  export type * from "../gql/graphql.ts";
package/src/api/me.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { NetworkClient } from "./client.ts";
2
+ import { MeDocument, type MeQuery } from "../gql/graphql.ts";
3
+ import { assertNotOperationError } from "./results.ts";
4
+
5
+ export async function me(client: NetworkClient) {
6
+ return assertNotOperationError<MeQuery["me"]>((await client.execute(MeDocument, {})).me);
7
+ }
@@ -0,0 +1,8 @@
1
+ import type { NetworkClient, OperationVariables } from "./client.ts";
2
+ import { OrdersDocument, type OrdersQueryVariables } from "../gql/graphql.ts";
3
+ import { assertNotOperationError } from "./results.ts";
4
+
5
+ /** The read-only Orders query. It never routes an order, including a lone pharmacy match. */
6
+ export async function orders(client: NetworkClient, input: OperationVariables<OrdersQueryVariables>) {
7
+ return assertNotOperationError((await client.execute(OrdersDocument, input)).orders);
8
+ }
@@ -4,10 +4,13 @@ import {
4
4
  GetPatientDocument,
5
5
  SyncPatientDocument,
6
6
  UpdatePatientDocument,
7
+ type BenefitsPatch,
7
8
  type PatientClinicalInput,
9
+ type PatientContactInput,
8
10
  type PatientDemographicInput,
9
11
  type PatientFieldsFragment,
10
12
  type PatientResultFieldsFragment,
13
+ type PharmacyReferenceInput,
11
14
  } from "../gql/graphql.ts";
12
15
  import { OperationFailure, assertNotOperationError, type Outcome } from "./results.ts";
13
16
 
@@ -41,7 +44,13 @@ export async function getPatient(client: NetworkClient, id: string) {
41
44
  return settle((await client.execute(GetPatientDocument, { id })).patient, { id });
42
45
  }
43
46
 
44
- type PatientFields = { demographic?: PatientDemographicInput; clinical?: PatientClinicalInput };
47
+ type PatientFields = {
48
+ demographic?: PatientDemographicInput;
49
+ contact?: PatientContactInput;
50
+ clinical?: PatientClinicalInput;
51
+ benefits?: BenefitsPatch;
52
+ preferredPharmacy?: PharmacyReferenceInput;
53
+ };
45
54
 
46
55
  /**
47
56
  * SyncPatient — whatever's known, an id or not: the server finds the patient, lists candidates (the prescriber
@@ -52,7 +61,7 @@ export async function syncPatient(client: NetworkClient, input: PatientFields &
52
61
  return settle((await client.execute(SyncPatientDocument, input, { signal })).patient, input);
53
62
  }
54
63
 
55
- /** UpdatePatient — change that one patient: demographics and/or clinical lists. NKDA: `clinical: { allergies: { none: true } }`. */
64
+ /** UpdatePatient — change that one patient: demographics, contact, benefits, preferred pharmacy and/or clinical lists. NKDA: `clinical: { allergies: { none: true } }`. */
56
65
  export async function updatePatient(client: NetworkClient, id: string, patch: PatientFields) {
57
66
  return settle((await client.execute(UpdatePatientDocument, { id, ...patch })).patient, patch);
58
67
  }
@@ -2,12 +2,14 @@ import type { ChangeSet } from "./changes/index.ts";
2
2
  import type { NetworkClient, OperationVariables } from "./client.ts";
3
3
  import {
4
4
  GetPrescriptionDocument,
5
+ GetPrescriptionTemplatesDocument,
5
6
  SyncPrescriptionDocument,
6
7
  UpdatePrescriptionDocument,
7
8
  type SyncPrescriptionMutationVariables,
8
9
  type UpdatePrescriptionMutationVariables,
9
10
  type PrescriptionFieldsFragment,
10
11
  type PrescriptionResultFieldsFragment,
12
+ type PrescriptionTemplateFieldsFragment,
11
13
  } from "../gql/graphql.ts";
12
14
  import { assertNotOperationError, type Outcome } from "./results.ts";
13
15
 
@@ -44,6 +46,22 @@ export async function getPrescription(client: NetworkClient, id: string) {
44
46
  return settle((await client.execute(GetPrescriptionDocument, { id })).prescription, { id });
45
47
  }
46
48
 
49
+ /**
50
+ * GetPrescriptionTemplates — the templates for a prescription's drug: the caller's catalog templates, then recommended
51
+ * ones (sigs worded for its patient, and units). null when network-api has none to offer (not a draft, or the catalog
52
+ * lookup failed).
53
+ */
54
+ export async function getPrescriptionTemplates(
55
+ client: NetworkClient,
56
+ id: string,
57
+ signal?: AbortSignal,
58
+ ): Promise<readonly PrescriptionTemplateFieldsFragment[] | null> {
59
+ const result = assertNotOperationError(
60
+ (await client.execute(GetPrescriptionTemplatesDocument, { id }, { signal })).prescription,
61
+ );
62
+ return result.__typename === "PrescriptionPayload" ? (result.prescription?.treatment.templates ?? null) : null;
63
+ }
64
+
47
65
  /**
48
66
  * SyncPrescription — whatever's known. Without a patient it can only look the drug up (its choices, or why
49
67
  * nothing matched); with one it continues their in-progress draft or starts one. Always send a treatment or
package/src/gql/gql.ts CHANGED
@@ -15,28 +15,36 @@ import * as types from './graphql.js';
15
15
  * Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
16
16
  */
17
17
  type Documents = {
18
- "fragment TreatmentFields on Treatment {\n id\n name\n rxNormId\n ndc\n upc\n entityKind\n prescribableName\n brandName\n genericName\n form\n route\n strength\n medicationType\n schedule\n recommendedDispenseUnits\n}\n\nfragment ChoiceFields on Choice {\n __typename\n displayName\n reason\n operation\n argument\n value\n matchReasons {\n type\n label\n confidence\n }\n entity {\n __typename\n ... on Treatment {\n ...TreatmentFields\n }\n ... on Pharmacy {\n ...PharmacyFields\n }\n }\n}\n\nfragment PharmacyOfferFields on PharmacyOffer {\n source\n isPromoted\n attributeTags {\n kind\n label\n }\n priceSummary {\n priceType\n totalAmount\n totalRetailAmount\n totalSavings\n }\n prescriptionDeliveryEstimates {\n prescriptionId\n deliveryPromise\n deliveryPromiseRangeStart\n deliveryPromiseRangeEnd\n }\n}\n\nfragment ChangeFields on Change {\n key\n label\n status\n severity\n reason\n category\n operation\n options {\n ...ChoiceFields\n }\n before {\n ...ChoiceFields\n }\n after {\n ...ChoiceFields\n }\n}\n\nfragment ChangeSetFields on ChangeSet {\n changes {\n ...ChangeFields\n }\n}\n\nfragment OperationErrorFields on OperationError {\n __typename\n type\n code\n message\n requiredPermission\n service\n retryable\n}\n\nfragment PharmacyFields on Pharmacy {\n id\n name\n address {\n street1\n street2\n city\n state\n postalCode\n }\n latitude\n longitude\n fulfillmentType\n offers {\n ...PharmacyOfferFields\n }\n}\n\nfragment PatientDemographicFields on PatientDemographic {\n name {\n first\n middle\n last\n }\n dateOfBirth\n sex\n gender\n email\n phone\n address {\n street1\n street2\n city\n state\n postalCode\n country\n }\n benefits {\n status\n entries {\n id\n bin\n pcn\n groupId\n memberId\n }\n }\n preferredPharmacy {\n ...PharmacyFields\n }\n}\n\nfragment PatientFields on Patient {\n id\n demographic {\n ...PatientDemographicFields\n }\n clinical {\n allergies {\n status\n entries {\n id\n name\n rxNormId\n }\n }\n medications {\n status\n entries {\n id\n name\n rxNormId\n status\n }\n }\n diagnoses {\n status\n entries {\n id\n name\n icd10Code\n }\n }\n notes\n }\n}\n\nfragment PatientRecordFields on PatientRecordResult {\n __typename\n ... on Patient {\n ...PatientFields\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment ScreeningAlertFields on ScreeningAlert {\n severity\n type\n description\n category\n involvedEntities {\n id\n name\n }\n options {\n ...ChoiceFields\n }\n}\n\nfragment PrescriptionFields on Prescription {\n id\n templateId\n patient {\n id\n }\n treatment {\n ...TreatmentFields\n }\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n clinical {\n diagnoses {\n id\n name\n icd10Code\n }\n notes\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n signing {\n state\n contentHash\n message\n signedAt\n }\n}\n\nfragment OrderFields on Order {\n id\n state\n patient {\n ...PatientRecordFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n pharmacy {\n ...PharmacyFields\n }\n exceptions {\n id\n type\n message\n createdAt\n }\n}\n\nfragment PatientResultFields on PatientResult {\n __typename\n ... on PatientPayload {\n patient {\n ...PatientRecordFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPatientMatch {\n reason\n candidates {\n id\n firstName\n lastName\n dateOfBirth\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment PrescriptionResultFields on PrescriptionResult {\n __typename\n ... on PrescriptionPayload {\n prescription {\n ...PrescriptionFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPrescriptionMatch {\n reason\n candidates {\n id\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment OrderCandidateFields on OrderCandidate {\n id\n pharmacy {\n ...PharmacyFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n}\n\nfragment OrderResultFields on OrderResult {\n __typename\n ... on OrderPayload {\n order {\n ...OrderFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousOrderMatch {\n reason\n candidates {\n ...OrderCandidateFields\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}": typeof types.TreatmentFieldsFragmentDoc,
18
+ "fragment TreatmentFields on Treatment {\n id\n name\n rxNormId\n ndc\n upc\n entityKind\n prescribableName\n brandName\n genericName\n form\n route\n strength\n medicationType\n schedule\n}\n\nfragment ChoiceFields on Choice {\n __typename\n displayName\n reason\n operation\n argument\n value\n matchReasons {\n type\n label\n confidence\n value {\n displayValue\n value\n unit\n }\n }\n entity {\n __typename\n ... on Treatment {\n ...TreatmentFields\n templates {\n ...PrescriptionTemplateFields\n }\n }\n ... on Pharmacy {\n ...PharmacyFields\n }\n }\n}\n\nfragment PharmacyOfferFields on PharmacyOffer {\n source\n prescriptionId\n priceType\n isPromoted\n attributeTags {\n kind\n label\n }\n price {\n amount\n retailAmount\n promotions {\n type\n baseAmount\n amountSaved\n }\n }\n deliveryEstimate {\n deliveryPromise\n deliveryPromiseRangeStart\n deliveryPromiseRangeEnd\n }\n redemptionState\n redemptionMethods {\n ...RedemptionMethodFields\n }\n}\n\nfragment RedemptionMethodFields on RedemptionMethod {\n __typename\n ... on PharmacyDiscountCard {\n id\n prescriptionId\n bin\n pcn\n group\n memberId\n externalUrl\n }\n}\n\nfragment ChangeFields on Change {\n key\n label\n status\n severity\n reason\n category\n operation\n options {\n ...ChoiceFields\n }\n before {\n ...ChoiceFields\n }\n after {\n ...ChoiceFields\n }\n}\n\nfragment ChangeSetFields on ChangeSet {\n changes {\n ...ChangeFields\n }\n}\n\nfragment OperationErrorFields on OperationError {\n __typename\n type\n code\n message\n requiredPermission\n service\n retryable\n}\n\nfragment PharmacyFields on Pharmacy {\n id\n name\n logo\n phone\n hours {\n openFrom\n openUntil\n dayOfWeek\n is24Hr\n timezone\n }\n isOpen\n nextEvents {\n open {\n ...PharmacyEventFields\n }\n close {\n ...PharmacyEventFields\n }\n }\n address {\n street1\n street2\n city\n state\n postalCode\n }\n latitude\n longitude\n fulfillmentType\n offers {\n ...PharmacyOfferFields\n }\n}\n\nfragment PharmacyEventFields on PharmacyEvent {\n __typename\n ... on PharmacyOpenEvent {\n type\n datetime\n }\n ... on PharmacyCloseEvent {\n type\n datetime\n }\n ... on PharmacyOpen24HrEvent {\n type\n }\n}\n\nfragment OrganizationFields on Organization {\n id\n name\n customer {\n __typename\n ... on Customer {\n id\n name\n }\n }\n settings {\n brandColor\n brandLogo\n priorAuthorizationExceptionMessage\n patientUx {\n enablePatientRerouting\n enableAutomatedOps\n }\n }\n}\n\nfragment PatientDemographicFields on PatientDemographic {\n name {\n first\n middle\n last\n }\n dateOfBirth\n sex\n gender\n}\n\nfragment PatientContactFields on PatientContact {\n email\n phone\n address {\n street1\n street2\n city\n state\n postalCode\n country\n }\n}\n\nfragment PatientFields on Patient {\n id\n demographic {\n ...PatientDemographicFields\n }\n contact {\n ...PatientContactFields\n }\n benefits {\n status\n entries {\n id\n bin\n pcn\n groupId\n memberId\n }\n }\n preferredPharmacy {\n ...PharmacyFields\n }\n clinical {\n allergies {\n status\n entries {\n id\n name\n rxNormId\n }\n }\n medications {\n status\n entries {\n id\n name\n rxNormId\n status\n }\n }\n diagnoses {\n status\n entries {\n id\n name\n icd10Code\n }\n }\n notes\n }\n}\n\nfragment PatientRecordFields on PatientRecordResult {\n __typename\n ... on Patient {\n ...PatientFields\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment ScreeningAlertFields on ScreeningAlert {\n severity\n type\n description\n category\n involvedEntities {\n id\n name\n }\n options {\n ...ChoiceFields\n }\n}\n\nfragment PrescriptionFields on Prescription {\n id\n prescriber {\n id\n name {\n first\n middle\n last\n }\n }\n fulfillment {\n state\n pharmacyEstimatedReadyAt\n exceptions {\n id\n type\n message\n createdAt\n }\n }\n templateId\n patient {\n id\n }\n treatment {\n ...TreatmentFields\n }\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n clinical {\n diagnoses {\n id\n name\n icd10Code\n }\n notes\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n signing {\n state\n contentHash\n message\n signedAt\n }\n}\n\nfragment OrderFields on Order {\n id\n state\n offers {\n atPharmacy {\n ...PharmacyOfferFields\n }\n }\n organization {\n __typename\n ... on Organization {\n ...OrganizationFields\n }\n }\n patient {\n ...PatientRecordFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n pharmacy {\n ...PharmacyFields\n }\n fulfillment {\n state\n history {\n pharmacy {\n ...PharmacyFields\n }\n selector\n reason\n createdAt\n }\n routability {\n allowed\n reason\n }\n exceptions {\n id\n type\n message\n createdAt\n }\n }\n}\n\nfragment PrescriptionTemplateFields on PrescriptionTemplate {\n id\n source\n name\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n}\n\nfragment PatientResultFields on PatientResult {\n __typename\n ... on PatientPayload {\n patient {\n ...PatientRecordFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPatientMatch {\n reason\n candidates {\n id\n firstName\n lastName\n dateOfBirth\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment PrescriptionResultFields on PrescriptionResult {\n __typename\n ... on PrescriptionPayload {\n prescription {\n ...PrescriptionFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPrescriptionMatch {\n reason\n candidates {\n id\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment OrderCandidateFields on OrderCandidate {\n id\n pharmacy {\n ...PharmacyFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n}\n\nfragment OrderResultFields on OrderResult {\n __typename\n ... on OrderPayload {\n order {\n ...OrderFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousOrderMatch {\n reason\n candidates {\n ...OrderCandidateFields\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}": typeof types.TreatmentFieldsFragmentDoc,
19
19
  "query Ping {\n ping\n}": typeof types.PingDocument,
20
+ "query Me {\n me {\n __typename\n ... on User {\n id\n name {\n first\n last\n }\n organization {\n __typename\n ... on Organization {\n id\n name\n }\n }\n permissions\n }\n ... on Patient {\n id\n name {\n first\n last\n }\n }\n ... on Machine {\n organization {\n __typename\n ... on Organization {\n id\n name\n }\n }\n permissions\n }\n ...OperationErrorFields\n }\n}": typeof types.MeDocument,
20
21
  "mutation GetOrder($id: ID!, $metadata: RequestMetadata!) {\n order(order: {id: $id}, metadata: $metadata) {\n ...OrderResultFields\n }\n}\n\nmutation SyncOrder($id: ID, $patient: PatientReferenceInput, $prescriptions: OrderPrescriptionsPatch, $pharmacy: OrderPharmacyInput, $metadata: RequestMetadata!) {\n order(\n order: {id: $id, patient: $patient, prescriptions: $prescriptions, pharmacy: $pharmacy}\n metadata: $metadata\n ) {\n ...OrderResultFields\n }\n}\n\nmutation UpdateOrder($id: ID!, $prescriptions: OrderPrescriptionsPatch, $state: OrderState, $pharmacy: OrderPharmacyInput, $metadata: RequestMetadata!) {\n order(\n order: {id: $id, prescriptions: $prescriptions, state: $state, pharmacy: $pharmacy}\n metadata: $metadata\n ) {\n ...OrderResultFields\n }\n}": typeof types.GetOrderDocument,
21
- "mutation GetPatient($id: ID!, $metadata: RequestMetadata!) {\n patient(patient: {id: $id}, metadata: $metadata) {\n ...PatientResultFields\n }\n}\n\nmutation SyncPatient($id: ID, $demographic: PatientDemographicInput, $clinical: PatientClinicalInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}\n\nmutation UpdatePatient($id: ID!, $demographic: PatientDemographicInput, $clinical: PatientClinicalInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}": typeof types.GetPatientDocument,
22
- "mutation GetPrescription($id: ID!, $metadata: RequestMetadata!) {\n prescription(prescription: {id: $id}, metadata: $metadata) {\n ...PrescriptionResultFields\n }\n}\n\nmutation SyncPrescription($id: ID, $externalId: String, $patient: PatientReferenceInput, $treatment: TreatmentReferenceInput, $templateId: ID, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, patient: $patient, treatment: $treatment, templateId: $templateId, instructions: $instructions, dispense: $dispense, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}\n\nmutation UpdatePrescription($id: ID!, $externalId: String, $treatment: TreatmentReferenceInput, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $signing: PrescriptionSigningDetailsInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, treatment: $treatment, instructions: $instructions, dispense: $dispense, clinical: $clinical, signing: $signing}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}": typeof types.GetPrescriptionDocument,
22
+ "query Orders($filter: OrdersFilterInput, $limit: Int, $pharmacy: PharmacyReferenceInput, $page: PageInput, $includePharmacies: Boolean!) {\n orders(filter: $filter, limit: $limit) {\n __typename\n ... on OrdersPayload {\n orders {\n ...OrderFields\n routablePharmacies(pharmacy: $pharmacy, page: $page) @include(if: $includePharmacies) {\n options {\n ...ChoiceFields\n }\n totalCount\n nextOffset\n }\n }\n }\n ... on AmbiguousPatientMatch {\n reason\n candidates {\n id\n firstName\n lastName\n dateOfBirth\n }\n }\n ...OperationErrorFields\n }\n}": typeof types.OrdersDocument,
23
+ "mutation GetPatient($id: ID!, $metadata: RequestMetadata!) {\n patient(patient: {id: $id}, metadata: $metadata) {\n ...PatientResultFields\n }\n}\n\nmutation SyncPatient($id: ID, $demographic: PatientDemographicInput, $contact: PatientContactInput, $clinical: PatientClinicalInput, $benefits: BenefitsPatch, $preferredPharmacy: PharmacyReferenceInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, contact: $contact, clinical: $clinical, benefits: $benefits, preferredPharmacy: $preferredPharmacy}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}\n\nmutation UpdatePatient($id: ID!, $demographic: PatientDemographicInput, $contact: PatientContactInput, $clinical: PatientClinicalInput, $benefits: BenefitsPatch, $preferredPharmacy: PharmacyReferenceInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, contact: $contact, clinical: $clinical, benefits: $benefits, preferredPharmacy: $preferredPharmacy}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}": typeof types.GetPatientDocument,
24
+ "mutation GetPrescription($id: ID!, $metadata: RequestMetadata!) {\n prescription(prescription: {id: $id}, metadata: $metadata) {\n ...PrescriptionResultFields\n }\n}\n\nmutation GetPrescriptionTemplates($id: ID!, $metadata: RequestMetadata!) {\n prescription(prescription: {id: $id}, metadata: $metadata) {\n __typename\n ... on PrescriptionPayload {\n prescription {\n treatment {\n templates {\n ...PrescriptionTemplateFields\n }\n }\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n }\n}\n\nmutation SyncPrescription($id: ID, $externalId: String, $patient: PatientReferenceInput, $treatment: TreatmentReferenceInput, $templateId: ID, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, patient: $patient, treatment: $treatment, templateId: $templateId, instructions: $instructions, dispense: $dispense, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}\n\nmutation UpdatePrescription($id: ID!, $externalId: String, $treatment: TreatmentReferenceInput, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $signing: PrescriptionSigningDetailsInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, treatment: $treatment, instructions: $instructions, dispense: $dispense, clinical: $clinical, signing: $signing}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}": typeof types.GetPrescriptionDocument,
23
25
  };
24
26
  const documents: Documents = {
25
- "fragment TreatmentFields on Treatment {\n id\n name\n rxNormId\n ndc\n upc\n entityKind\n prescribableName\n brandName\n genericName\n form\n route\n strength\n medicationType\n schedule\n recommendedDispenseUnits\n}\n\nfragment ChoiceFields on Choice {\n __typename\n displayName\n reason\n operation\n argument\n value\n matchReasons {\n type\n label\n confidence\n }\n entity {\n __typename\n ... on Treatment {\n ...TreatmentFields\n }\n ... on Pharmacy {\n ...PharmacyFields\n }\n }\n}\n\nfragment PharmacyOfferFields on PharmacyOffer {\n source\n isPromoted\n attributeTags {\n kind\n label\n }\n priceSummary {\n priceType\n totalAmount\n totalRetailAmount\n totalSavings\n }\n prescriptionDeliveryEstimates {\n prescriptionId\n deliveryPromise\n deliveryPromiseRangeStart\n deliveryPromiseRangeEnd\n }\n}\n\nfragment ChangeFields on Change {\n key\n label\n status\n severity\n reason\n category\n operation\n options {\n ...ChoiceFields\n }\n before {\n ...ChoiceFields\n }\n after {\n ...ChoiceFields\n }\n}\n\nfragment ChangeSetFields on ChangeSet {\n changes {\n ...ChangeFields\n }\n}\n\nfragment OperationErrorFields on OperationError {\n __typename\n type\n code\n message\n requiredPermission\n service\n retryable\n}\n\nfragment PharmacyFields on Pharmacy {\n id\n name\n address {\n street1\n street2\n city\n state\n postalCode\n }\n latitude\n longitude\n fulfillmentType\n offers {\n ...PharmacyOfferFields\n }\n}\n\nfragment PatientDemographicFields on PatientDemographic {\n name {\n first\n middle\n last\n }\n dateOfBirth\n sex\n gender\n email\n phone\n address {\n street1\n street2\n city\n state\n postalCode\n country\n }\n benefits {\n status\n entries {\n id\n bin\n pcn\n groupId\n memberId\n }\n }\n preferredPharmacy {\n ...PharmacyFields\n }\n}\n\nfragment PatientFields on Patient {\n id\n demographic {\n ...PatientDemographicFields\n }\n clinical {\n allergies {\n status\n entries {\n id\n name\n rxNormId\n }\n }\n medications {\n status\n entries {\n id\n name\n rxNormId\n status\n }\n }\n diagnoses {\n status\n entries {\n id\n name\n icd10Code\n }\n }\n notes\n }\n}\n\nfragment PatientRecordFields on PatientRecordResult {\n __typename\n ... on Patient {\n ...PatientFields\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment ScreeningAlertFields on ScreeningAlert {\n severity\n type\n description\n category\n involvedEntities {\n id\n name\n }\n options {\n ...ChoiceFields\n }\n}\n\nfragment PrescriptionFields on Prescription {\n id\n templateId\n patient {\n id\n }\n treatment {\n ...TreatmentFields\n }\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n clinical {\n diagnoses {\n id\n name\n icd10Code\n }\n notes\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n signing {\n state\n contentHash\n message\n signedAt\n }\n}\n\nfragment OrderFields on Order {\n id\n state\n patient {\n ...PatientRecordFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n pharmacy {\n ...PharmacyFields\n }\n exceptions {\n id\n type\n message\n createdAt\n }\n}\n\nfragment PatientResultFields on PatientResult {\n __typename\n ... on PatientPayload {\n patient {\n ...PatientRecordFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPatientMatch {\n reason\n candidates {\n id\n firstName\n lastName\n dateOfBirth\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment PrescriptionResultFields on PrescriptionResult {\n __typename\n ... on PrescriptionPayload {\n prescription {\n ...PrescriptionFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPrescriptionMatch {\n reason\n candidates {\n id\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment OrderCandidateFields on OrderCandidate {\n id\n pharmacy {\n ...PharmacyFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n}\n\nfragment OrderResultFields on OrderResult {\n __typename\n ... on OrderPayload {\n order {\n ...OrderFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousOrderMatch {\n reason\n candidates {\n ...OrderCandidateFields\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}": types.TreatmentFieldsFragmentDoc,
27
+ "fragment TreatmentFields on Treatment {\n id\n name\n rxNormId\n ndc\n upc\n entityKind\n prescribableName\n brandName\n genericName\n form\n route\n strength\n medicationType\n schedule\n}\n\nfragment ChoiceFields on Choice {\n __typename\n displayName\n reason\n operation\n argument\n value\n matchReasons {\n type\n label\n confidence\n value {\n displayValue\n value\n unit\n }\n }\n entity {\n __typename\n ... on Treatment {\n ...TreatmentFields\n templates {\n ...PrescriptionTemplateFields\n }\n }\n ... on Pharmacy {\n ...PharmacyFields\n }\n }\n}\n\nfragment PharmacyOfferFields on PharmacyOffer {\n source\n prescriptionId\n priceType\n isPromoted\n attributeTags {\n kind\n label\n }\n price {\n amount\n retailAmount\n promotions {\n type\n baseAmount\n amountSaved\n }\n }\n deliveryEstimate {\n deliveryPromise\n deliveryPromiseRangeStart\n deliveryPromiseRangeEnd\n }\n redemptionState\n redemptionMethods {\n ...RedemptionMethodFields\n }\n}\n\nfragment RedemptionMethodFields on RedemptionMethod {\n __typename\n ... on PharmacyDiscountCard {\n id\n prescriptionId\n bin\n pcn\n group\n memberId\n externalUrl\n }\n}\n\nfragment ChangeFields on Change {\n key\n label\n status\n severity\n reason\n category\n operation\n options {\n ...ChoiceFields\n }\n before {\n ...ChoiceFields\n }\n after {\n ...ChoiceFields\n }\n}\n\nfragment ChangeSetFields on ChangeSet {\n changes {\n ...ChangeFields\n }\n}\n\nfragment OperationErrorFields on OperationError {\n __typename\n type\n code\n message\n requiredPermission\n service\n retryable\n}\n\nfragment PharmacyFields on Pharmacy {\n id\n name\n logo\n phone\n hours {\n openFrom\n openUntil\n dayOfWeek\n is24Hr\n timezone\n }\n isOpen\n nextEvents {\n open {\n ...PharmacyEventFields\n }\n close {\n ...PharmacyEventFields\n }\n }\n address {\n street1\n street2\n city\n state\n postalCode\n }\n latitude\n longitude\n fulfillmentType\n offers {\n ...PharmacyOfferFields\n }\n}\n\nfragment PharmacyEventFields on PharmacyEvent {\n __typename\n ... on PharmacyOpenEvent {\n type\n datetime\n }\n ... on PharmacyCloseEvent {\n type\n datetime\n }\n ... on PharmacyOpen24HrEvent {\n type\n }\n}\n\nfragment OrganizationFields on Organization {\n id\n name\n customer {\n __typename\n ... on Customer {\n id\n name\n }\n }\n settings {\n brandColor\n brandLogo\n priorAuthorizationExceptionMessage\n patientUx {\n enablePatientRerouting\n enableAutomatedOps\n }\n }\n}\n\nfragment PatientDemographicFields on PatientDemographic {\n name {\n first\n middle\n last\n }\n dateOfBirth\n sex\n gender\n}\n\nfragment PatientContactFields on PatientContact {\n email\n phone\n address {\n street1\n street2\n city\n state\n postalCode\n country\n }\n}\n\nfragment PatientFields on Patient {\n id\n demographic {\n ...PatientDemographicFields\n }\n contact {\n ...PatientContactFields\n }\n benefits {\n status\n entries {\n id\n bin\n pcn\n groupId\n memberId\n }\n }\n preferredPharmacy {\n ...PharmacyFields\n }\n clinical {\n allergies {\n status\n entries {\n id\n name\n rxNormId\n }\n }\n medications {\n status\n entries {\n id\n name\n rxNormId\n status\n }\n }\n diagnoses {\n status\n entries {\n id\n name\n icd10Code\n }\n }\n notes\n }\n}\n\nfragment PatientRecordFields on PatientRecordResult {\n __typename\n ... on Patient {\n ...PatientFields\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment ScreeningAlertFields on ScreeningAlert {\n severity\n type\n description\n category\n involvedEntities {\n id\n name\n }\n options {\n ...ChoiceFields\n }\n}\n\nfragment PrescriptionFields on Prescription {\n id\n prescriber {\n id\n name {\n first\n middle\n last\n }\n }\n fulfillment {\n state\n pharmacyEstimatedReadyAt\n exceptions {\n id\n type\n message\n createdAt\n }\n }\n templateId\n patient {\n id\n }\n treatment {\n ...TreatmentFields\n }\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n clinical {\n diagnoses {\n id\n name\n icd10Code\n }\n notes\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n signing {\n state\n contentHash\n message\n signedAt\n }\n}\n\nfragment OrderFields on Order {\n id\n state\n offers {\n atPharmacy {\n ...PharmacyOfferFields\n }\n }\n organization {\n __typename\n ... on Organization {\n ...OrganizationFields\n }\n }\n patient {\n ...PatientRecordFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n pharmacy {\n ...PharmacyFields\n }\n fulfillment {\n state\n history {\n pharmacy {\n ...PharmacyFields\n }\n selector\n reason\n createdAt\n }\n routability {\n allowed\n reason\n }\n exceptions {\n id\n type\n message\n createdAt\n }\n }\n}\n\nfragment PrescriptionTemplateFields on PrescriptionTemplate {\n id\n source\n name\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n}\n\nfragment PatientResultFields on PatientResult {\n __typename\n ... on PatientPayload {\n patient {\n ...PatientRecordFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPatientMatch {\n reason\n candidates {\n id\n firstName\n lastName\n dateOfBirth\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment PrescriptionResultFields on PrescriptionResult {\n __typename\n ... on PrescriptionPayload {\n prescription {\n ...PrescriptionFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPrescriptionMatch {\n reason\n candidates {\n id\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment OrderCandidateFields on OrderCandidate {\n id\n pharmacy {\n ...PharmacyFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n}\n\nfragment OrderResultFields on OrderResult {\n __typename\n ... on OrderPayload {\n order {\n ...OrderFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousOrderMatch {\n reason\n candidates {\n ...OrderCandidateFields\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}": types.TreatmentFieldsFragmentDoc,
26
28
  "query Ping {\n ping\n}": types.PingDocument,
29
+ "query Me {\n me {\n __typename\n ... on User {\n id\n name {\n first\n last\n }\n organization {\n __typename\n ... on Organization {\n id\n name\n }\n }\n permissions\n }\n ... on Patient {\n id\n name {\n first\n last\n }\n }\n ... on Machine {\n organization {\n __typename\n ... on Organization {\n id\n name\n }\n }\n permissions\n }\n ...OperationErrorFields\n }\n}": types.MeDocument,
27
30
  "mutation GetOrder($id: ID!, $metadata: RequestMetadata!) {\n order(order: {id: $id}, metadata: $metadata) {\n ...OrderResultFields\n }\n}\n\nmutation SyncOrder($id: ID, $patient: PatientReferenceInput, $prescriptions: OrderPrescriptionsPatch, $pharmacy: OrderPharmacyInput, $metadata: RequestMetadata!) {\n order(\n order: {id: $id, patient: $patient, prescriptions: $prescriptions, pharmacy: $pharmacy}\n metadata: $metadata\n ) {\n ...OrderResultFields\n }\n}\n\nmutation UpdateOrder($id: ID!, $prescriptions: OrderPrescriptionsPatch, $state: OrderState, $pharmacy: OrderPharmacyInput, $metadata: RequestMetadata!) {\n order(\n order: {id: $id, prescriptions: $prescriptions, state: $state, pharmacy: $pharmacy}\n metadata: $metadata\n ) {\n ...OrderResultFields\n }\n}": types.GetOrderDocument,
28
- "mutation GetPatient($id: ID!, $metadata: RequestMetadata!) {\n patient(patient: {id: $id}, metadata: $metadata) {\n ...PatientResultFields\n }\n}\n\nmutation SyncPatient($id: ID, $demographic: PatientDemographicInput, $clinical: PatientClinicalInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}\n\nmutation UpdatePatient($id: ID!, $demographic: PatientDemographicInput, $clinical: PatientClinicalInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}": types.GetPatientDocument,
29
- "mutation GetPrescription($id: ID!, $metadata: RequestMetadata!) {\n prescription(prescription: {id: $id}, metadata: $metadata) {\n ...PrescriptionResultFields\n }\n}\n\nmutation SyncPrescription($id: ID, $externalId: String, $patient: PatientReferenceInput, $treatment: TreatmentReferenceInput, $templateId: ID, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, patient: $patient, treatment: $treatment, templateId: $templateId, instructions: $instructions, dispense: $dispense, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}\n\nmutation UpdatePrescription($id: ID!, $externalId: String, $treatment: TreatmentReferenceInput, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $signing: PrescriptionSigningDetailsInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, treatment: $treatment, instructions: $instructions, dispense: $dispense, clinical: $clinical, signing: $signing}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}": types.GetPrescriptionDocument,
31
+ "query Orders($filter: OrdersFilterInput, $limit: Int, $pharmacy: PharmacyReferenceInput, $page: PageInput, $includePharmacies: Boolean!) {\n orders(filter: $filter, limit: $limit) {\n __typename\n ... on OrdersPayload {\n orders {\n ...OrderFields\n routablePharmacies(pharmacy: $pharmacy, page: $page) @include(if: $includePharmacies) {\n options {\n ...ChoiceFields\n }\n totalCount\n nextOffset\n }\n }\n }\n ... on AmbiguousPatientMatch {\n reason\n candidates {\n id\n firstName\n lastName\n dateOfBirth\n }\n }\n ...OperationErrorFields\n }\n}": types.OrdersDocument,
32
+ "mutation GetPatient($id: ID!, $metadata: RequestMetadata!) {\n patient(patient: {id: $id}, metadata: $metadata) {\n ...PatientResultFields\n }\n}\n\nmutation SyncPatient($id: ID, $demographic: PatientDemographicInput, $contact: PatientContactInput, $clinical: PatientClinicalInput, $benefits: BenefitsPatch, $preferredPharmacy: PharmacyReferenceInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, contact: $contact, clinical: $clinical, benefits: $benefits, preferredPharmacy: $preferredPharmacy}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}\n\nmutation UpdatePatient($id: ID!, $demographic: PatientDemographicInput, $contact: PatientContactInput, $clinical: PatientClinicalInput, $benefits: BenefitsPatch, $preferredPharmacy: PharmacyReferenceInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, contact: $contact, clinical: $clinical, benefits: $benefits, preferredPharmacy: $preferredPharmacy}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}": types.GetPatientDocument,
33
+ "mutation GetPrescription($id: ID!, $metadata: RequestMetadata!) {\n prescription(prescription: {id: $id}, metadata: $metadata) {\n ...PrescriptionResultFields\n }\n}\n\nmutation GetPrescriptionTemplates($id: ID!, $metadata: RequestMetadata!) {\n prescription(prescription: {id: $id}, metadata: $metadata) {\n __typename\n ... on PrescriptionPayload {\n prescription {\n treatment {\n templates {\n ...PrescriptionTemplateFields\n }\n }\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n }\n}\n\nmutation SyncPrescription($id: ID, $externalId: String, $patient: PatientReferenceInput, $treatment: TreatmentReferenceInput, $templateId: ID, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, patient: $patient, treatment: $treatment, templateId: $templateId, instructions: $instructions, dispense: $dispense, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}\n\nmutation UpdatePrescription($id: ID!, $externalId: String, $treatment: TreatmentReferenceInput, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $signing: PrescriptionSigningDetailsInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, treatment: $treatment, instructions: $instructions, dispense: $dispense, clinical: $clinical, signing: $signing}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}": types.GetPrescriptionDocument,
30
34
  };
31
35
 
32
36
  /**
33
37
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
34
38
  */
35
- export function graphql(source: "fragment TreatmentFields on Treatment {\n id\n name\n rxNormId\n ndc\n upc\n entityKind\n prescribableName\n brandName\n genericName\n form\n route\n strength\n medicationType\n schedule\n recommendedDispenseUnits\n}\n\nfragment ChoiceFields on Choice {\n __typename\n displayName\n reason\n operation\n argument\n value\n matchReasons {\n type\n label\n confidence\n }\n entity {\n __typename\n ... on Treatment {\n ...TreatmentFields\n }\n ... on Pharmacy {\n ...PharmacyFields\n }\n }\n}\n\nfragment PharmacyOfferFields on PharmacyOffer {\n source\n isPromoted\n attributeTags {\n kind\n label\n }\n priceSummary {\n priceType\n totalAmount\n totalRetailAmount\n totalSavings\n }\n prescriptionDeliveryEstimates {\n prescriptionId\n deliveryPromise\n deliveryPromiseRangeStart\n deliveryPromiseRangeEnd\n }\n}\n\nfragment ChangeFields on Change {\n key\n label\n status\n severity\n reason\n category\n operation\n options {\n ...ChoiceFields\n }\n before {\n ...ChoiceFields\n }\n after {\n ...ChoiceFields\n }\n}\n\nfragment ChangeSetFields on ChangeSet {\n changes {\n ...ChangeFields\n }\n}\n\nfragment OperationErrorFields on OperationError {\n __typename\n type\n code\n message\n requiredPermission\n service\n retryable\n}\n\nfragment PharmacyFields on Pharmacy {\n id\n name\n address {\n street1\n street2\n city\n state\n postalCode\n }\n latitude\n longitude\n fulfillmentType\n offers {\n ...PharmacyOfferFields\n }\n}\n\nfragment PatientDemographicFields on PatientDemographic {\n name {\n first\n middle\n last\n }\n dateOfBirth\n sex\n gender\n email\n phone\n address {\n street1\n street2\n city\n state\n postalCode\n country\n }\n benefits {\n status\n entries {\n id\n bin\n pcn\n groupId\n memberId\n }\n }\n preferredPharmacy {\n ...PharmacyFields\n }\n}\n\nfragment PatientFields on Patient {\n id\n demographic {\n ...PatientDemographicFields\n }\n clinical {\n allergies {\n status\n entries {\n id\n name\n rxNormId\n }\n }\n medications {\n status\n entries {\n id\n name\n rxNormId\n status\n }\n }\n diagnoses {\n status\n entries {\n id\n name\n icd10Code\n }\n }\n notes\n }\n}\n\nfragment PatientRecordFields on PatientRecordResult {\n __typename\n ... on Patient {\n ...PatientFields\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment ScreeningAlertFields on ScreeningAlert {\n severity\n type\n description\n category\n involvedEntities {\n id\n name\n }\n options {\n ...ChoiceFields\n }\n}\n\nfragment PrescriptionFields on Prescription {\n id\n templateId\n patient {\n id\n }\n treatment {\n ...TreatmentFields\n }\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n clinical {\n diagnoses {\n id\n name\n icd10Code\n }\n notes\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n signing {\n state\n contentHash\n message\n signedAt\n }\n}\n\nfragment OrderFields on Order {\n id\n state\n patient {\n ...PatientRecordFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n pharmacy {\n ...PharmacyFields\n }\n exceptions {\n id\n type\n message\n createdAt\n }\n}\n\nfragment PatientResultFields on PatientResult {\n __typename\n ... on PatientPayload {\n patient {\n ...PatientRecordFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPatientMatch {\n reason\n candidates {\n id\n firstName\n lastName\n dateOfBirth\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment PrescriptionResultFields on PrescriptionResult {\n __typename\n ... on PrescriptionPayload {\n prescription {\n ...PrescriptionFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPrescriptionMatch {\n reason\n candidates {\n id\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment OrderCandidateFields on OrderCandidate {\n id\n pharmacy {\n ...PharmacyFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n}\n\nfragment OrderResultFields on OrderResult {\n __typename\n ... on OrderPayload {\n order {\n ...OrderFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousOrderMatch {\n reason\n candidates {\n ...OrderCandidateFields\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}"): typeof import('./graphql.js').TreatmentFieldsFragmentDoc;
39
+ export function graphql(source: "fragment TreatmentFields on Treatment {\n id\n name\n rxNormId\n ndc\n upc\n entityKind\n prescribableName\n brandName\n genericName\n form\n route\n strength\n medicationType\n schedule\n}\n\nfragment ChoiceFields on Choice {\n __typename\n displayName\n reason\n operation\n argument\n value\n matchReasons {\n type\n label\n confidence\n value {\n displayValue\n value\n unit\n }\n }\n entity {\n __typename\n ... on Treatment {\n ...TreatmentFields\n templates {\n ...PrescriptionTemplateFields\n }\n }\n ... on Pharmacy {\n ...PharmacyFields\n }\n }\n}\n\nfragment PharmacyOfferFields on PharmacyOffer {\n source\n prescriptionId\n priceType\n isPromoted\n attributeTags {\n kind\n label\n }\n price {\n amount\n retailAmount\n promotions {\n type\n baseAmount\n amountSaved\n }\n }\n deliveryEstimate {\n deliveryPromise\n deliveryPromiseRangeStart\n deliveryPromiseRangeEnd\n }\n redemptionState\n redemptionMethods {\n ...RedemptionMethodFields\n }\n}\n\nfragment RedemptionMethodFields on RedemptionMethod {\n __typename\n ... on PharmacyDiscountCard {\n id\n prescriptionId\n bin\n pcn\n group\n memberId\n externalUrl\n }\n}\n\nfragment ChangeFields on Change {\n key\n label\n status\n severity\n reason\n category\n operation\n options {\n ...ChoiceFields\n }\n before {\n ...ChoiceFields\n }\n after {\n ...ChoiceFields\n }\n}\n\nfragment ChangeSetFields on ChangeSet {\n changes {\n ...ChangeFields\n }\n}\n\nfragment OperationErrorFields on OperationError {\n __typename\n type\n code\n message\n requiredPermission\n service\n retryable\n}\n\nfragment PharmacyFields on Pharmacy {\n id\n name\n logo\n phone\n hours {\n openFrom\n openUntil\n dayOfWeek\n is24Hr\n timezone\n }\n isOpen\n nextEvents {\n open {\n ...PharmacyEventFields\n }\n close {\n ...PharmacyEventFields\n }\n }\n address {\n street1\n street2\n city\n state\n postalCode\n }\n latitude\n longitude\n fulfillmentType\n offers {\n ...PharmacyOfferFields\n }\n}\n\nfragment PharmacyEventFields on PharmacyEvent {\n __typename\n ... on PharmacyOpenEvent {\n type\n datetime\n }\n ... on PharmacyCloseEvent {\n type\n datetime\n }\n ... on PharmacyOpen24HrEvent {\n type\n }\n}\n\nfragment OrganizationFields on Organization {\n id\n name\n customer {\n __typename\n ... on Customer {\n id\n name\n }\n }\n settings {\n brandColor\n brandLogo\n priorAuthorizationExceptionMessage\n patientUx {\n enablePatientRerouting\n enableAutomatedOps\n }\n }\n}\n\nfragment PatientDemographicFields on PatientDemographic {\n name {\n first\n middle\n last\n }\n dateOfBirth\n sex\n gender\n}\n\nfragment PatientContactFields on PatientContact {\n email\n phone\n address {\n street1\n street2\n city\n state\n postalCode\n country\n }\n}\n\nfragment PatientFields on Patient {\n id\n demographic {\n ...PatientDemographicFields\n }\n contact {\n ...PatientContactFields\n }\n benefits {\n status\n entries {\n id\n bin\n pcn\n groupId\n memberId\n }\n }\n preferredPharmacy {\n ...PharmacyFields\n }\n clinical {\n allergies {\n status\n entries {\n id\n name\n rxNormId\n }\n }\n medications {\n status\n entries {\n id\n name\n rxNormId\n status\n }\n }\n diagnoses {\n status\n entries {\n id\n name\n icd10Code\n }\n }\n notes\n }\n}\n\nfragment PatientRecordFields on PatientRecordResult {\n __typename\n ... on Patient {\n ...PatientFields\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment ScreeningAlertFields on ScreeningAlert {\n severity\n type\n description\n category\n involvedEntities {\n id\n name\n }\n options {\n ...ChoiceFields\n }\n}\n\nfragment PrescriptionFields on Prescription {\n id\n prescriber {\n id\n name {\n first\n middle\n last\n }\n }\n fulfillment {\n state\n pharmacyEstimatedReadyAt\n exceptions {\n id\n type\n message\n createdAt\n }\n }\n templateId\n patient {\n id\n }\n treatment {\n ...TreatmentFields\n }\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n clinical {\n diagnoses {\n id\n name\n icd10Code\n }\n notes\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n signing {\n state\n contentHash\n message\n signedAt\n }\n}\n\nfragment OrderFields on Order {\n id\n state\n offers {\n atPharmacy {\n ...PharmacyOfferFields\n }\n }\n organization {\n __typename\n ... on Organization {\n ...OrganizationFields\n }\n }\n patient {\n ...PatientRecordFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n screeningAlerts {\n ...ScreeningAlertFields\n }\n pharmacy {\n ...PharmacyFields\n }\n fulfillment {\n state\n history {\n pharmacy {\n ...PharmacyFields\n }\n selector\n reason\n createdAt\n }\n routability {\n allowed\n reason\n }\n exceptions {\n id\n type\n message\n createdAt\n }\n }\n}\n\nfragment PrescriptionTemplateFields on PrescriptionTemplate {\n id\n source\n name\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n}\n\nfragment PatientResultFields on PatientResult {\n __typename\n ... on PatientPayload {\n patient {\n ...PatientRecordFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPatientMatch {\n reason\n candidates {\n id\n firstName\n lastName\n dateOfBirth\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment PrescriptionResultFields on PrescriptionResult {\n __typename\n ... on PrescriptionPayload {\n prescription {\n ...PrescriptionFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousPrescriptionMatch {\n reason\n candidates {\n id\n instructions\n dispense {\n quantity\n unit\n daysSupply\n refillsAllowed\n dispenseAsWritten\n }\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}\n\nfragment OrderCandidateFields on OrderCandidate {\n id\n pharmacy {\n ...PharmacyFields\n }\n prescriptions {\n ...PrescriptionFields\n }\n}\n\nfragment OrderResultFields on OrderResult {\n __typename\n ... on OrderPayload {\n order {\n ...OrderFields\n }\n ...ChangeSetFields\n }\n ... on AmbiguousOrderMatch {\n reason\n candidates {\n ...OrderCandidateFields\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n}"): typeof import('./graphql.js').TreatmentFieldsFragmentDoc;
36
40
  /**
37
41
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
38
42
  */
39
43
  export function graphql(source: "query Ping {\n ping\n}"): typeof import('./graphql.js').PingDocument;
44
+ /**
45
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
46
+ */
47
+ export function graphql(source: "query Me {\n me {\n __typename\n ... on User {\n id\n name {\n first\n last\n }\n organization {\n __typename\n ... on Organization {\n id\n name\n }\n }\n permissions\n }\n ... on Patient {\n id\n name {\n first\n last\n }\n }\n ... on Machine {\n organization {\n __typename\n ... on Organization {\n id\n name\n }\n }\n permissions\n }\n ...OperationErrorFields\n }\n}"): typeof import('./graphql.js').MeDocument;
40
48
  /**
41
49
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
42
50
  */
@@ -44,11 +52,15 @@ export function graphql(source: "mutation GetOrder($id: ID!, $metadata: RequestM
44
52
  /**
45
53
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
46
54
  */
47
- export function graphql(source: "mutation GetPatient($id: ID!, $metadata: RequestMetadata!) {\n patient(patient: {id: $id}, metadata: $metadata) {\n ...PatientResultFields\n }\n}\n\nmutation SyncPatient($id: ID, $demographic: PatientDemographicInput, $clinical: PatientClinicalInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}\n\nmutation UpdatePatient($id: ID!, $demographic: PatientDemographicInput, $clinical: PatientClinicalInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}"): typeof import('./graphql.js').GetPatientDocument;
55
+ export function graphql(source: "query Orders($filter: OrdersFilterInput, $limit: Int, $pharmacy: PharmacyReferenceInput, $page: PageInput, $includePharmacies: Boolean!) {\n orders(filter: $filter, limit: $limit) {\n __typename\n ... on OrdersPayload {\n orders {\n ...OrderFields\n routablePharmacies(pharmacy: $pharmacy, page: $page) @include(if: $includePharmacies) {\n options {\n ...ChoiceFields\n }\n totalCount\n nextOffset\n }\n }\n }\n ... on AmbiguousPatientMatch {\n reason\n candidates {\n id\n firstName\n lastName\n dateOfBirth\n }\n }\n ...OperationErrorFields\n }\n}"): typeof import('./graphql.js').OrdersDocument;
56
+ /**
57
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
58
+ */
59
+ export function graphql(source: "mutation GetPatient($id: ID!, $metadata: RequestMetadata!) {\n patient(patient: {id: $id}, metadata: $metadata) {\n ...PatientResultFields\n }\n}\n\nmutation SyncPatient($id: ID, $demographic: PatientDemographicInput, $contact: PatientContactInput, $clinical: PatientClinicalInput, $benefits: BenefitsPatch, $preferredPharmacy: PharmacyReferenceInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, contact: $contact, clinical: $clinical, benefits: $benefits, preferredPharmacy: $preferredPharmacy}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}\n\nmutation UpdatePatient($id: ID!, $demographic: PatientDemographicInput, $contact: PatientContactInput, $clinical: PatientClinicalInput, $benefits: BenefitsPatch, $preferredPharmacy: PharmacyReferenceInput, $metadata: RequestMetadata!) {\n patient(\n patient: {id: $id, demographic: $demographic, contact: $contact, clinical: $clinical, benefits: $benefits, preferredPharmacy: $preferredPharmacy}\n metadata: $metadata\n ) {\n ...PatientResultFields\n }\n}"): typeof import('./graphql.js').GetPatientDocument;
48
60
  /**
49
61
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
50
62
  */
51
- export function graphql(source: "mutation GetPrescription($id: ID!, $metadata: RequestMetadata!) {\n prescription(prescription: {id: $id}, metadata: $metadata) {\n ...PrescriptionResultFields\n }\n}\n\nmutation SyncPrescription($id: ID, $externalId: String, $patient: PatientReferenceInput, $treatment: TreatmentReferenceInput, $templateId: ID, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, patient: $patient, treatment: $treatment, templateId: $templateId, instructions: $instructions, dispense: $dispense, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}\n\nmutation UpdatePrescription($id: ID!, $externalId: String, $treatment: TreatmentReferenceInput, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $signing: PrescriptionSigningDetailsInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, treatment: $treatment, instructions: $instructions, dispense: $dispense, clinical: $clinical, signing: $signing}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}"): typeof import('./graphql.js').GetPrescriptionDocument;
63
+ export function graphql(source: "mutation GetPrescription($id: ID!, $metadata: RequestMetadata!) {\n prescription(prescription: {id: $id}, metadata: $metadata) {\n ...PrescriptionResultFields\n }\n}\n\nmutation GetPrescriptionTemplates($id: ID!, $metadata: RequestMetadata!) {\n prescription(prescription: {id: $id}, metadata: $metadata) {\n __typename\n ... on PrescriptionPayload {\n prescription {\n treatment {\n templates {\n ...PrescriptionTemplateFields\n }\n }\n }\n }\n ... on OperationError {\n ...OperationErrorFields\n }\n }\n}\n\nmutation SyncPrescription($id: ID, $externalId: String, $patient: PatientReferenceInput, $treatment: TreatmentReferenceInput, $templateId: ID, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, patient: $patient, treatment: $treatment, templateId: $templateId, instructions: $instructions, dispense: $dispense, clinical: $clinical}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}\n\nmutation UpdatePrescription($id: ID!, $externalId: String, $treatment: TreatmentReferenceInput, $instructions: String, $dispense: DispenseInput, $clinical: PrescriptionClinicalInput, $signing: PrescriptionSigningDetailsInput, $metadata: RequestMetadata!) {\n prescription(\n prescription: {id: $id, externalId: $externalId, treatment: $treatment, instructions: $instructions, dispense: $dispense, clinical: $clinical, signing: $signing}\n metadata: $metadata\n ) {\n ...PrescriptionResultFields\n }\n}"): typeof import('./graphql.js').GetPrescriptionDocument;
52
64
 
53
65
 
54
66
  export function graphql(source: string) {