@photonhealth/client 0.0.0-stage → 2.0.0-rc.1

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 (178) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +89 -2
  3. package/dist/api/changes/applyOption.d.ts +41 -0
  4. package/dist/api/changes/applyOption.d.ts.map +1 -0
  5. package/dist/api/changes/applyOption.js +76 -0
  6. package/dist/api/changes/applyOption.js.map +1 -0
  7. package/dist/api/changes/classifyChanges.d.ts +9 -0
  8. package/dist/api/changes/classifyChanges.d.ts.map +1 -0
  9. package/dist/api/changes/classifyChanges.js +2 -0
  10. package/dist/api/changes/classifyChanges.js.map +1 -0
  11. package/dist/api/changes/index.d.ts +3 -0
  12. package/dist/api/changes/index.d.ts.map +1 -0
  13. package/dist/api/changes/index.js +3 -0
  14. package/dist/api/changes/index.js.map +1 -0
  15. package/dist/api/client.d.ts +43 -0
  16. package/dist/api/client.d.ts.map +1 -0
  17. package/dist/api/client.js +77 -0
  18. package/dist/api/client.js.map +1 -0
  19. package/dist/api/health.d.ts +4 -0
  20. package/dist/api/health.d.ts.map +1 -0
  21. package/dist/api/health.js +6 -0
  22. package/dist/api/health.js.map +1 -0
  23. package/dist/api/index.d.ts +22 -0
  24. package/dist/api/index.d.ts.map +1 -0
  25. package/dist/api/index.js +21 -0
  26. package/dist/api/index.js.map +1 -0
  27. package/dist/api/order.d.ts +33 -0
  28. package/dist/api/order.d.ts.map +1 -0
  29. package/dist/api/order.js +33 -0
  30. package/dist/api/order.js.map +1 -0
  31. package/dist/api/patient.d.ts +33 -0
  32. package/dist/api/patient.d.ts.map +1 -0
  33. package/dist/api/patient.js +33 -0
  34. package/dist/api/patient.js.map +1 -0
  35. package/dist/api/prescription.d.ts +31 -0
  36. package/dist/api/prescription.d.ts.map +1 -0
  37. package/dist/api/prescription.js +30 -0
  38. package/dist/api/prescription.js.map +1 -0
  39. package/dist/api/results.d.ts +30 -0
  40. package/dist/api/results.d.ts.map +1 -0
  41. package/dist/api/results.js +26 -0
  42. package/dist/api/results.js.map +1 -0
  43. package/dist/gql/gql.d.ts +21 -0
  44. package/dist/gql/gql.d.ts.map +1 -0
  45. package/dist/gql/gql.js +13 -0
  46. package/dist/gql/gql.js.map +1 -0
  47. package/dist/gql/graphql.d.ts +9674 -0
  48. package/dist/gql/graphql.d.ts.map +1 -0
  49. package/dist/gql/graphql.js +4030 -0
  50. package/dist/gql/graphql.js.map +1 -0
  51. package/dist/gql/index.d.ts +2 -0
  52. package/dist/gql/index.d.ts.map +1 -0
  53. package/dist/gql/index.js +3 -0
  54. package/dist/gql/index.js.map +1 -0
  55. package/dist/index.d.ts +15 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +15 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/photon/auth.d.ts +48 -0
  60. package/dist/photon/auth.d.ts.map +1 -0
  61. package/dist/photon/auth.js +34 -0
  62. package/dist/photon/auth.js.map +1 -0
  63. package/dist/photon/choices.d.ts +44 -0
  64. package/dist/photon/choices.d.ts.map +1 -0
  65. package/dist/photon/choices.js +58 -0
  66. package/dist/photon/choices.js.map +1 -0
  67. package/dist/photon/context.d.ts +29 -0
  68. package/dist/photon/context.d.ts.map +1 -0
  69. package/dist/photon/context.js +2 -0
  70. package/dist/photon/context.js.map +1 -0
  71. package/dist/photon/environments.d.ts +26 -0
  72. package/dist/photon/environments.d.ts.map +1 -0
  73. package/dist/photon/environments.js +26 -0
  74. package/dist/photon/environments.js.map +1 -0
  75. package/dist/photon/errors.d.ts +26 -0
  76. package/dist/photon/errors.d.ts.map +1 -0
  77. package/dist/photon/errors.js +42 -0
  78. package/dist/photon/errors.js.map +1 -0
  79. package/dist/photon/index.d.ts +23 -0
  80. package/dist/photon/index.d.ts.map +1 -0
  81. package/dist/photon/index.js +11 -0
  82. package/dist/photon/index.js.map +1 -0
  83. package/dist/photon/inputs.d.ts +7 -0
  84. package/dist/photon/inputs.d.ts.map +1 -0
  85. package/dist/photon/inputs.js +25 -0
  86. package/dist/photon/inputs.js.map +1 -0
  87. package/dist/photon/links.d.ts +68 -0
  88. package/dist/photon/links.d.ts.map +1 -0
  89. package/dist/photon/links.js +187 -0
  90. package/dist/photon/links.js.map +1 -0
  91. package/dist/photon/live.d.ts +62 -0
  92. package/dist/photon/live.d.ts.map +1 -0
  93. package/dist/photon/live.js +107 -0
  94. package/dist/photon/live.js.map +1 -0
  95. package/dist/photon/map.d.ts +10 -0
  96. package/dist/photon/map.d.ts.map +1 -0
  97. package/dist/photon/map.js +211 -0
  98. package/dist/photon/map.js.map +1 -0
  99. package/dist/photon/order.d.ts +148 -0
  100. package/dist/photon/order.d.ts.map +1 -0
  101. package/dist/photon/order.js +491 -0
  102. package/dist/photon/order.js.map +1 -0
  103. package/dist/photon/patient.d.ts +78 -0
  104. package/dist/photon/patient.d.ts.map +1 -0
  105. package/dist/photon/patient.js +316 -0
  106. package/dist/photon/patient.js.map +1 -0
  107. package/dist/photon/photon.d.ts +150 -0
  108. package/dist/photon/photon.d.ts.map +1 -0
  109. package/dist/photon/photon.js +315 -0
  110. package/dist/photon/photon.js.map +1 -0
  111. package/dist/photon/prescription.d.ts +132 -0
  112. package/dist/photon/prescription.d.ts.map +1 -0
  113. package/dist/photon/prescription.js +381 -0
  114. package/dist/photon/prescription.js.map +1 -0
  115. package/dist/photon/session.d.ts +84 -0
  116. package/dist/photon/session.d.ts.map +1 -0
  117. package/dist/photon/session.js +350 -0
  118. package/dist/photon/session.js.map +1 -0
  119. package/dist/photon/types.d.ts +411 -0
  120. package/dist/photon/types.d.ts.map +1 -0
  121. package/dist/photon/types.js +7 -0
  122. package/dist/photon/types.js.map +1 -0
  123. package/dist/test-utils/msw.d.ts +23 -0
  124. package/dist/test-utils/msw.d.ts.map +1 -0
  125. package/dist/test-utils/msw.js +51 -0
  126. package/dist/test-utils/msw.js.map +1 -0
  127. package/dist/testing/fixtures.d.ts +51 -0
  128. package/dist/testing/fixtures.d.ts.map +1 -0
  129. package/dist/testing/fixtures.js +166 -0
  130. package/dist/testing/fixtures.js.map +1 -0
  131. package/dist/testing/scriptedClient.d.ts +38 -0
  132. package/dist/testing/scriptedClient.d.ts.map +1 -0
  133. package/dist/testing/scriptedClient.js +52 -0
  134. package/dist/testing/scriptedClient.js.map +1 -0
  135. package/dist/testing.d.ts +11 -0
  136. package/dist/testing.d.ts.map +1 -0
  137. package/dist/testing.js +10 -0
  138. package/dist/testing.js.map +1 -0
  139. package/package.json +67 -4
  140. package/src/api/changes/applyOption.ts +103 -0
  141. package/src/api/changes/classifyChanges.ts +10 -0
  142. package/src/api/changes/index.ts +2 -0
  143. package/src/api/client.ts +124 -0
  144. package/src/api/health.ts +7 -0
  145. package/src/api/index.ts +22 -0
  146. package/src/api/order.ts +64 -0
  147. package/src/api/patient.ts +58 -0
  148. package/src/api/prescription.ts +68 -0
  149. package/src/api/results.ts +45 -0
  150. package/src/gql/gql.ts +56 -0
  151. package/src/gql/graphql.ts +5344 -0
  152. package/src/gql/index.ts +2 -0
  153. package/src/index.ts +14 -0
  154. package/src/operations/fragments.graphql +351 -0
  155. package/src/operations/health.graphql +4 -0
  156. package/src/operations/order.graphql +42 -0
  157. package/src/operations/patient.graphql +36 -0
  158. package/src/operations/prescription.graphql +70 -0
  159. package/src/photon/auth.ts +70 -0
  160. package/src/photon/choices.ts +79 -0
  161. package/src/photon/context.ts +30 -0
  162. package/src/photon/environments.ts +47 -0
  163. package/src/photon/errors.ts +56 -0
  164. package/src/photon/index.ts +35 -0
  165. package/src/photon/inputs.ts +24 -0
  166. package/src/photon/links.ts +197 -0
  167. package/src/photon/live.ts +135 -0
  168. package/src/photon/map.ts +255 -0
  169. package/src/photon/order.ts +581 -0
  170. package/src/photon/patient.ts +346 -0
  171. package/src/photon/photon.ts +513 -0
  172. package/src/photon/prescription.ts +447 -0
  173. package/src/photon/session.ts +445 -0
  174. package/src/photon/types.ts +329 -0
  175. package/src/test-utils/msw.ts +61 -0
  176. package/src/testing/fixtures.ts +191 -0
  177. package/src/testing/scriptedClient.ts +52 -0
  178. package/src/testing.ts +22 -0
@@ -0,0 +1,64 @@
1
+ import type { ChangeSet } from "./changes/index.ts";
2
+ import type { NetworkClient, OperationVariables } from "./client.ts";
3
+ import {
4
+ GetOrderDocument,
5
+ SyncOrderDocument,
6
+ UpdateOrderDocument,
7
+ type OrderFieldsFragment,
8
+ type OrderResultFieldsFragment,
9
+ type SyncOrderMutationVariables,
10
+ type UpdateOrderMutationVariables,
11
+ } from "../gql/graphql.ts";
12
+ import { assertNotOperationError, type Outcome } from "./results.ts";
13
+
14
+ export type Order = OrderFieldsFragment;
15
+ export type OrderCandidate = Extract<
16
+ OrderResultFieldsFragment,
17
+ { __typename: "AmbiguousOrderMatch" }
18
+ >["candidates"][number];
19
+
20
+ export type OrderOutcome = Outcome<
21
+ { order: Order | null; changes: ChangeSet },
22
+ { reason: string; candidates: OrderCandidate[] }
23
+ >;
24
+
25
+ function settle(result: OrderResultFieldsFragment, sent: unknown): OrderOutcome {
26
+ const r = assertNotOperationError(result);
27
+ if (r.__typename === "AmbiguousOrderMatch") {
28
+ return { kind: "ambiguous", reason: r.reason, candidates: r.candidates };
29
+ }
30
+ return {
31
+ kind: "ok",
32
+ order: r.order,
33
+ changes: { changes: r.changes, sent },
34
+ };
35
+ }
36
+
37
+ /**
38
+ * Fields you can patch on an order. Omit one to leave it alone; `pharmacy: { none: true }` unassigns it
39
+ * (the patient chooses again — works after submit too).
40
+ */
41
+ type OrderPatch = Omit<OperationVariables<UpdateOrderMutationVariables>, "id">;
42
+
43
+ /** GetOrder — read a known order with its patient, prescriptions and pharmacy. */
44
+ export async function getOrder(client: NetworkClient, id: string) {
45
+ return settle((await client.execute(GetOrderDocument, { id })).order, { id });
46
+ }
47
+
48
+ /**
49
+ * SyncOrder — whatever's known: the patient's DRAFT order (continued) or a new one, with the prescriptions to
50
+ * put on it; with an id, that order. Nothing is sent until submitOrder.
51
+ */
52
+ export async function syncOrder(client: NetworkClient, input: OperationVariables<SyncOrderMutationVariables>) {
53
+ return settle((await client.execute(SyncOrderDocument, input)).order, input);
54
+ }
55
+
56
+ /** UpdateOrder — e.g. `{ prescriptions: { add } }`, `{ pharmacy: { pharmacy } }`, `{ pharmacy: { none: true } }`, `{ state: "CANCELED" }`. */
57
+ export async function updateOrder(client: NetworkClient, id: string, patch: OrderPatch) {
58
+ return settle((await client.execute(UpdateOrderDocument, { id, ...patch })).order, patch);
59
+ }
60
+
61
+ /** Send = UpdateOrder to SUBMITTED. Pharmacy untouched: none → the patient chooses; an existing choice is kept. */
62
+ export function submitOrder(client: NetworkClient, id: string) {
63
+ return updateOrder(client, id, { state: "SUBMITTED" });
64
+ }
@@ -0,0 +1,58 @@
1
+ import type { ChangeSet } from "./changes/index.ts";
2
+ import type { NetworkClient } from "./client.ts";
3
+ import {
4
+ GetPatientDocument,
5
+ SyncPatientDocument,
6
+ UpdatePatientDocument,
7
+ type PatientClinicalInput,
8
+ type PatientDemographicInput,
9
+ type PatientFieldsFragment,
10
+ type PatientResultFieldsFragment,
11
+ } from "../gql/graphql.ts";
12
+ import { OperationFailure, assertNotOperationError, type Outcome } from "./results.ts";
13
+
14
+ export type Patient = PatientFieldsFragment;
15
+ export type PatientCandidate = Extract<
16
+ PatientResultFieldsFragment,
17
+ { __typename: "AmbiguousPatientMatch" }
18
+ >["candidates"][number];
19
+
20
+ export type PatientOutcome = Outcome<
21
+ { patient: Patient | null; changes: ChangeSet },
22
+ { reason: string; candidates: PatientCandidate[] }
23
+ >;
24
+
25
+ function settle(result: PatientResultFieldsFragment, sent: unknown): PatientOutcome {
26
+ const r = assertNotOperationError(result);
27
+ if (r.__typename === "AmbiguousPatientMatch") {
28
+ return { kind: "ambiguous", reason: r.reason, candidates: r.candidates };
29
+ }
30
+ const record = r.patient;
31
+ if (record?.__typename === "OperationError") throw new OperationFailure(record);
32
+ return {
33
+ kind: "ok",
34
+ patient: record ?? null,
35
+ changes: { changes: r.changes, sent },
36
+ };
37
+ }
38
+
39
+ /** GetPatient — read a known patient. */
40
+ export async function getPatient(client: NetworkClient, id: string) {
41
+ return settle((await client.execute(GetPatientDocument, { id })).patient, { id });
42
+ }
43
+
44
+ type PatientFields = { demographic?: PatientDemographicInput; clinical?: PatientClinicalInput };
45
+
46
+ /**
47
+ * SyncPatient — whatever's known, an id or not: the server finds the patient, lists candidates (the prescriber
48
+ * picks), says what's missing, or creates one when nothing matches and it has enough (today: first, last, DOB,
49
+ * sex — leave `sex` out to look without creating).
50
+ */
51
+ export async function syncPatient(client: NetworkClient, input: PatientFields & { id?: string }, signal?: AbortSignal) {
52
+ return settle((await client.execute(SyncPatientDocument, input, { signal })).patient, input);
53
+ }
54
+
55
+ /** UpdatePatient — change that one patient: demographics and/or clinical lists. NKDA: `clinical: { allergies: { none: true } }`. */
56
+ export async function updatePatient(client: NetworkClient, id: string, patch: PatientFields) {
57
+ return settle((await client.execute(UpdatePatientDocument, { id, ...patch })).patient, patch);
58
+ }
@@ -0,0 +1,68 @@
1
+ import type { ChangeSet } from "./changes/index.ts";
2
+ import type { NetworkClient, OperationVariables } from "./client.ts";
3
+ import {
4
+ GetPrescriptionDocument,
5
+ SyncPrescriptionDocument,
6
+ UpdatePrescriptionDocument,
7
+ type SyncPrescriptionMutationVariables,
8
+ type UpdatePrescriptionMutationVariables,
9
+ type PrescriptionFieldsFragment,
10
+ type PrescriptionResultFieldsFragment,
11
+ } from "../gql/graphql.ts";
12
+ import { assertNotOperationError, type Outcome } from "./results.ts";
13
+
14
+ export type Prescription = PrescriptionFieldsFragment;
15
+ export type PrescriptionCandidate = Extract<
16
+ PrescriptionResultFieldsFragment,
17
+ { __typename: "AmbiguousPrescriptionMatch" }
18
+ >["candidates"][number];
19
+
20
+ export type PrescriptionOutcome = Outcome<
21
+ { prescription: Prescription | null; changes: ChangeSet },
22
+ { reason: string; candidates: PrescriptionCandidate[] }
23
+ >;
24
+
25
+ function settle(result: PrescriptionResultFieldsFragment, sent: unknown): PrescriptionOutcome {
26
+ const r = assertNotOperationError(result);
27
+ if (r.__typename === "AmbiguousPrescriptionMatch") {
28
+ return { kind: "ambiguous", reason: r.reason, candidates: r.candidates };
29
+ }
30
+ return {
31
+ kind: "ok",
32
+ prescription: r.prescription,
33
+ changes: { changes: r.changes, sent },
34
+ };
35
+ }
36
+
37
+ /** What a sync sends: an id or not, a patient or not, and the fields known. */
38
+ type PrescriptionSync = OperationVariables<SyncPrescriptionMutationVariables>;
39
+ /** Fields you can change on a draft (everything but the id), or the signing. */
40
+ type PrescriptionPatch = Omit<OperationVariables<UpdatePrescriptionMutationVariables>, "id">;
41
+
42
+ /** GetPrescription — read a known prescription, draft or signed. */
43
+ export async function getPrescription(client: NetworkClient, id: string) {
44
+ return settle((await client.execute(GetPrescriptionDocument, { id })).prescription, { id });
45
+ }
46
+
47
+ /**
48
+ * SyncPrescription — whatever's known. Without a patient it can only look the drug up (its choices, or why
49
+ * nothing matched); with one it continues their in-progress draft or starts one. Always send a treatment or
50
+ * template with a patient (without one the server copies the patient's last Rx).
51
+ */
52
+ export async function syncPrescription(client: NetworkClient, input: PrescriptionSync, signal?: AbortSignal) {
53
+ return settle(
54
+ (
55
+ await client.execute(
56
+ SyncPrescriptionDocument,
57
+ { ...input, templateId: input.templateId ?? undefined },
58
+ { signal },
59
+ )
60
+ ).prescription,
61
+ input,
62
+ );
63
+ }
64
+
65
+ /** UpdatePrescription — change only the fields sent, or sign; screening re-runs and contentHash changes. */
66
+ export async function updatePrescription(client: NetworkClient, id: string, patch: PrescriptionPatch) {
67
+ return settle((await client.execute(UpdatePrescriptionDocument, { id, ...patch })).prescription, patch);
68
+ }
@@ -0,0 +1,45 @@
1
+ import type { OperationErrorFieldsFragment, OperationErrorType } from "../gql/graphql.ts";
2
+
3
+ /**
4
+ * network-api results are tiered unions:
5
+ * Payload — the business outcome (may still carry REJECTED/BLOCKING changes)
6
+ * Ambiguous*Match — a likely duplicate; nothing was written, pick a candidate and retry
7
+ * OperationError — a real failure (`type`: UNAUTHORIZED or UPSTREAM_SERVICE)
8
+ *
9
+ * We return the first two as a discriminated `Outcome` (the UI must handle
10
+ * both) and throw the last as `OperationFailure` (the UI shows an error).
11
+ */
12
+
13
+ export type Outcome<TOk, TAmbiguous> = ({ kind: "ok" } & TOk) | ({ kind: "ambiguous" } & TAmbiguous);
14
+
15
+ export class OperationFailure extends Error {
16
+ readonly code: string;
17
+ readonly type: OperationErrorType;
18
+ readonly requiredPermission?: string | null;
19
+ readonly service?: string | null;
20
+ readonly retryable: boolean;
21
+
22
+ constructor(error: OperationErrorFieldsFragment) {
23
+ super(error.message);
24
+ this.name = "OperationFailure";
25
+ this.code = error.code;
26
+ this.type = error.type;
27
+ this.requiredPermission = error.requiredPermission;
28
+ this.service = error.service;
29
+ this.retryable = error.retryable;
30
+ }
31
+ }
32
+
33
+ function isOperationError<T extends { __typename: string }>(
34
+ result: T,
35
+ ): result is Extract<T, { __typename: "OperationError" }> {
36
+ return result.__typename === "OperationError";
37
+ }
38
+
39
+ /** Throws on real failures so callers only ever see business outcomes. */
40
+ export function assertNotOperationError<T extends { __typename: string }>(
41
+ result: T,
42
+ ): Exclude<T, { __typename: "OperationError" }> {
43
+ if (isOperationError(result)) throw new OperationFailure(result as unknown as OperationErrorFieldsFragment);
44
+ return result as never;
45
+ }
package/src/gql/gql.ts ADDED
@@ -0,0 +1,56 @@
1
+ /* eslint-disable */
2
+ import * as types from './graphql.js';
3
+
4
+
5
+
6
+ /**
7
+ * Map of all GraphQL operations in the project.
8
+ *
9
+ * This map has several performance disadvantages:
10
+ * 1. It is not tree-shakeable, so it will include all operations in the project.
11
+ * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
12
+ * 3. It does not support dead code elimination, so it will add unused operations.
13
+ *
14
+ * Therefore it is highly recommended to use the babel or swc plugin for production.
15
+ * Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
16
+ */
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,
19
+ "query Ping {\n ping\n}": typeof types.PingDocument,
20
+ "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,
23
+ };
24
+ 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,
26
+ "query Ping {\n ping\n}": types.PingDocument,
27
+ "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,
30
+ };
31
+
32
+ /**
33
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
34
+ */
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;
36
+ /**
37
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
38
+ */
39
+ export function graphql(source: "query Ping {\n ping\n}"): typeof import('./graphql.js').PingDocument;
40
+ /**
41
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
42
+ */
43
+ export function graphql(source: "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 import('./graphql.js').GetOrderDocument;
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: "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;
48
+ /**
49
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
50
+ */
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;
52
+
53
+
54
+ export function graphql(source: string) {
55
+ return (documents as any)[source] ?? {};
56
+ }