@photonhealth/client 0.0.0-stage → 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 (218) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +234 -2
  3. package/dist/analytics/lifecycleEvents.d.ts +29 -0
  4. package/dist/analytics/lifecycleEvents.d.ts.map +1 -0
  5. package/dist/analytics/lifecycleEvents.js +72 -0
  6. package/dist/analytics/lifecycleEvents.js.map +1 -0
  7. package/dist/api/changes/applyOption.d.ts +41 -0
  8. package/dist/api/changes/applyOption.d.ts.map +1 -0
  9. package/dist/api/changes/applyOption.js +76 -0
  10. package/dist/api/changes/applyOption.js.map +1 -0
  11. package/dist/api/changes/classifyChanges.d.ts +9 -0
  12. package/dist/api/changes/classifyChanges.d.ts.map +1 -0
  13. package/dist/api/changes/classifyChanges.js +2 -0
  14. package/dist/api/changes/classifyChanges.js.map +1 -0
  15. package/dist/api/changes/index.d.ts +3 -0
  16. package/dist/api/changes/index.d.ts.map +1 -0
  17. package/dist/api/changes/index.js +3 -0
  18. package/dist/api/changes/index.js.map +1 -0
  19. package/dist/api/client.d.ts +48 -0
  20. package/dist/api/client.d.ts.map +1 -0
  21. package/dist/api/client.js +91 -0
  22. package/dist/api/client.js.map +1 -0
  23. package/dist/api/health.d.ts +4 -0
  24. package/dist/api/health.d.ts.map +1 -0
  25. package/dist/api/health.js +6 -0
  26. package/dist/api/health.js.map +1 -0
  27. package/dist/api/index.d.ts +24 -0
  28. package/dist/api/index.d.ts.map +1 -0
  29. package/dist/api/index.js +23 -0
  30. package/dist/api/index.js.map +1 -0
  31. package/dist/api/me.d.ts +37 -0
  32. package/dist/api/me.d.ts.map +1 -0
  33. package/dist/api/me.js +6 -0
  34. package/dist/api/me.js.map +1 -0
  35. package/dist/api/order.d.ts +33 -0
  36. package/dist/api/order.d.ts.map +1 -0
  37. package/dist/api/order.js +33 -0
  38. package/dist/api/order.js.map +1 -0
  39. package/dist/api/orders.d.ts +1047 -0
  40. package/dist/api/orders.d.ts.map +1 -0
  41. package/dist/api/orders.js +7 -0
  42. package/dist/api/orders.js.map +1 -0
  43. package/dist/api/patient.d.ts +36 -0
  44. package/dist/api/patient.d.ts.map +1 -0
  45. package/dist/api/patient.js +33 -0
  46. package/dist/api/patient.js.map +1 -0
  47. package/dist/api/prescription.d.ts +37 -0
  48. package/dist/api/prescription.d.ts.map +1 -0
  49. package/dist/api/prescription.js +39 -0
  50. package/dist/api/prescription.js.map +1 -0
  51. package/dist/api/results.d.ts +30 -0
  52. package/dist/api/results.d.ts.map +1 -0
  53. package/dist/api/results.js +26 -0
  54. package/dist/api/results.js.map +1 -0
  55. package/dist/gql/gql.d.ts +29 -0
  56. package/dist/gql/gql.d.ts.map +1 -0
  57. package/dist/gql/gql.js +15 -0
  58. package/dist/gql/gql.js.map +1 -0
  59. package/dist/gql/graphql.d.ts +18618 -0
  60. package/dist/gql/graphql.d.ts.map +1 -0
  61. package/dist/gql/graphql.js +6579 -0
  62. package/dist/gql/graphql.js.map +1 -0
  63. package/dist/gql/index.d.ts +2 -0
  64. package/dist/gql/index.d.ts.map +1 -0
  65. package/dist/gql/index.js +3 -0
  66. package/dist/gql/index.js.map +1 -0
  67. package/dist/index.d.ts +15 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +15 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/meta/version.d.ts +2 -0
  72. package/dist/meta/version.d.ts.map +1 -0
  73. package/dist/meta/version.js +2 -0
  74. package/dist/meta/version.js.map +1 -0
  75. package/dist/photon/analytics.d.ts +39 -0
  76. package/dist/photon/analytics.d.ts.map +1 -0
  77. package/dist/photon/analytics.js +91 -0
  78. package/dist/photon/analytics.js.map +1 -0
  79. package/dist/photon/auth.d.ts +52 -0
  80. package/dist/photon/auth.d.ts.map +1 -0
  81. package/dist/photon/auth.js +30 -0
  82. package/dist/photon/auth.js.map +1 -0
  83. package/dist/photon/choices.d.ts +44 -0
  84. package/dist/photon/choices.d.ts.map +1 -0
  85. package/dist/photon/choices.js +58 -0
  86. package/dist/photon/choices.js.map +1 -0
  87. package/dist/photon/context.d.ts +29 -0
  88. package/dist/photon/context.d.ts.map +1 -0
  89. package/dist/photon/context.js +2 -0
  90. package/dist/photon/context.js.map +1 -0
  91. package/dist/photon/environments.d.ts +27 -0
  92. package/dist/photon/environments.d.ts.map +1 -0
  93. package/dist/photon/environments.js +27 -0
  94. package/dist/photon/environments.js.map +1 -0
  95. package/dist/photon/errors.d.ts +26 -0
  96. package/dist/photon/errors.d.ts.map +1 -0
  97. package/dist/photon/errors.js +42 -0
  98. package/dist/photon/errors.js.map +1 -0
  99. package/dist/photon/index.d.ts +26 -0
  100. package/dist/photon/index.d.ts.map +1 -0
  101. package/dist/photon/index.js +12 -0
  102. package/dist/photon/index.js.map +1 -0
  103. package/dist/photon/inputs.d.ts +7 -0
  104. package/dist/photon/inputs.d.ts.map +1 -0
  105. package/dist/photon/inputs.js +25 -0
  106. package/dist/photon/inputs.js.map +1 -0
  107. package/dist/photon/links.d.ts +68 -0
  108. package/dist/photon/links.d.ts.map +1 -0
  109. package/dist/photon/links.js +187 -0
  110. package/dist/photon/links.js.map +1 -0
  111. package/dist/photon/live.d.ts +62 -0
  112. package/dist/photon/live.d.ts.map +1 -0
  113. package/dist/photon/live.js +107 -0
  114. package/dist/photon/live.js.map +1 -0
  115. package/dist/photon/machine.d.ts +28 -0
  116. package/dist/photon/machine.d.ts.map +1 -0
  117. package/dist/photon/machine.js +53 -0
  118. package/dist/photon/machine.js.map +1 -0
  119. package/dist/photon/map.d.ts +14 -0
  120. package/dist/photon/map.d.ts.map +1 -0
  121. package/dist/photon/map.js +311 -0
  122. package/dist/photon/map.js.map +1 -0
  123. package/dist/photon/order.d.ts +168 -0
  124. package/dist/photon/order.d.ts.map +1 -0
  125. package/dist/photon/order.js +558 -0
  126. package/dist/photon/order.js.map +1 -0
  127. package/dist/photon/orders.d.ts +5 -0
  128. package/dist/photon/orders.d.ts.map +1 -0
  129. package/dist/photon/orders.js +39 -0
  130. package/dist/photon/orders.js.map +1 -0
  131. package/dist/photon/patient.d.ts +80 -0
  132. package/dist/photon/patient.d.ts.map +1 -0
  133. package/dist/photon/patient.js +347 -0
  134. package/dist/photon/patient.js.map +1 -0
  135. package/dist/photon/photon.d.ts +188 -0
  136. package/dist/photon/photon.d.ts.map +1 -0
  137. package/dist/photon/photon.js +395 -0
  138. package/dist/photon/photon.js.map +1 -0
  139. package/dist/photon/prescription.d.ts +145 -0
  140. package/dist/photon/prescription.d.ts.map +1 -0
  141. package/dist/photon/prescription.js +418 -0
  142. package/dist/photon/prescription.js.map +1 -0
  143. package/dist/photon/session.d.ts +89 -0
  144. package/dist/photon/session.d.ts.map +1 -0
  145. package/dist/photon/session.js +352 -0
  146. package/dist/photon/session.js.map +1 -0
  147. package/dist/photon/types.d.ts +643 -0
  148. package/dist/photon/types.d.ts.map +1 -0
  149. package/dist/photon/types.js +7 -0
  150. package/dist/photon/types.js.map +1 -0
  151. package/dist/test-utils/msw.d.ts +23 -0
  152. package/dist/test-utils/msw.d.ts.map +1 -0
  153. package/dist/test-utils/msw.js +51 -0
  154. package/dist/test-utils/msw.js.map +1 -0
  155. package/dist/testing/fakeNetworkApiClient.d.ts +39 -0
  156. package/dist/testing/fakeNetworkApiClient.d.ts.map +1 -0
  157. package/dist/testing/fakeNetworkApiClient.js +56 -0
  158. package/dist/testing/fakeNetworkApiClient.js.map +1 -0
  159. package/dist/testing/fixtures.d.ts +1098 -0
  160. package/dist/testing/fixtures.d.ts.map +1 -0
  161. package/dist/testing/fixtures.js +200 -0
  162. package/dist/testing/fixtures.js.map +1 -0
  163. package/dist/testing.d.ts +11 -0
  164. package/dist/testing.d.ts.map +1 -0
  165. package/dist/testing.js +10 -0
  166. package/dist/testing.js.map +1 -0
  167. package/package.json +67 -4
  168. package/src/analytics/lifecycleEvents.test.ts +417 -0
  169. package/src/analytics/lifecycleEvents.ts +155 -0
  170. package/src/api/changes/applyOption.ts +103 -0
  171. package/src/api/changes/classifyChanges.ts +10 -0
  172. package/src/api/changes/index.ts +2 -0
  173. package/src/api/client.ts +149 -0
  174. package/src/api/health.ts +7 -0
  175. package/src/api/index.ts +24 -0
  176. package/src/api/me.ts +7 -0
  177. package/src/api/order.ts +64 -0
  178. package/src/api/orders.ts +8 -0
  179. package/src/api/patient.ts +67 -0
  180. package/src/api/prescription.ts +86 -0
  181. package/src/api/results.ts +45 -0
  182. package/src/gql/gql.ts +68 -0
  183. package/src/gql/graphql.ts +9027 -0
  184. package/src/gql/index.ts +2 -0
  185. package/src/index.ts +14 -0
  186. package/src/meta/version.test.ts +10 -0
  187. package/src/meta/version.ts +1 -0
  188. package/src/operations/fragments.graphql +497 -0
  189. package/src/operations/health.graphql +4 -0
  190. package/src/operations/me.graphql +38 -0
  191. package/src/operations/order.graphql +42 -0
  192. package/src/operations/orders.graphql +35 -0
  193. package/src/operations/patient.graphql +62 -0
  194. package/src/operations/prescription.graphql +90 -0
  195. package/src/photon/analytics.ts +129 -0
  196. package/src/photon/auth.ts +69 -0
  197. package/src/photon/choices.ts +79 -0
  198. package/src/photon/context.ts +30 -0
  199. package/src/photon/environments.ts +49 -0
  200. package/src/photon/errors.ts +56 -0
  201. package/src/photon/index.ts +49 -0
  202. package/src/photon/inputs.ts +24 -0
  203. package/src/photon/links.ts +197 -0
  204. package/src/photon/live.ts +135 -0
  205. package/src/photon/machine.ts +90 -0
  206. package/src/photon/map.ts +371 -0
  207. package/src/photon/order.test.ts +142 -0
  208. package/src/photon/order.ts +661 -0
  209. package/src/photon/orders.ts +42 -0
  210. package/src/photon/patient.ts +386 -0
  211. package/src/photon/photon.ts +646 -0
  212. package/src/photon/prescription.ts +506 -0
  213. package/src/photon/session.ts +454 -0
  214. package/src/photon/types.ts +583 -0
  215. package/src/test-utils/msw.ts +72 -0
  216. package/src/testing/fakeNetworkApiClient.ts +56 -0
  217. package/src/testing/fixtures.ts +233 -0
  218. package/src/testing.ts +25 -0
@@ -0,0 +1,2 @@
1
+ /* eslint-disable */
2
+ export * from "./gql.js";
package/src/index.ts ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @photonhealth/client — Photon Rx without a UI framework. Zero runtime dependencies; runs in browsers,
3
+ * Node, workers and agents.
4
+ *
5
+ * const ph = photon({ environment: "boson", auth: { getToken } });
6
+ * const { patient, candidates, changes } = await ph.patient({ demographic: { … } });
7
+ *
8
+ * network-api's three upsert mutations — patient, prescription, order — one call each, returning live
9
+ * objects (state you can subscribe to; methods that await the web calls) with the workflow rules
10
+ * inside. See the package README.
11
+ *
12
+ * This is the whole public surface. The GraphQL layer (api/, gql/) is internal.
13
+ */
14
+ export * from "./photon/index.ts";
@@ -0,0 +1,10 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { describe, expect, it } from "vitest";
3
+ import { clientVersion } from "../index.ts";
4
+
5
+ describe("clientVersion", () => {
6
+ it("is package.json's version: bump both together", () => {
7
+ const manifest = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
8
+ expect(clientVersion).toBe(manifest.version);
9
+ });
10
+ });
@@ -0,0 +1 @@
1
+ export const clientVersion: string = "0.14.5";
@@ -0,0 +1,497 @@
1
+ # Shared selection sets. Every operation in this folder composes these, so a
2
+ # component that renders a Patient/Prescription/Order/Change can rely on the
3
+ # same fields no matter which intent produced the payload.
4
+
5
+ # A drug as the catalog describes it: on a prescription, and on each drug option a lookup offers.
6
+ fragment TreatmentFields on Treatment {
7
+ id
8
+ name
9
+ rxNormId
10
+ ndc
11
+ upc
12
+ entityKind
13
+ prescribableName
14
+ brandName
15
+ genericName
16
+ form
17
+ route
18
+ strength
19
+ medicationType
20
+ schedule
21
+ }
22
+
23
+ fragment ChoiceFields on Choice {
24
+ __typename
25
+ displayName
26
+ reason
27
+ operation
28
+ argument
29
+ value
30
+ matchReasons {
31
+ type
32
+ label
33
+ confidence
34
+ value {
35
+ displayValue
36
+ value
37
+ unit
38
+ }
39
+ }
40
+ entity {
41
+ __typename
42
+ ... on Treatment {
43
+ ...TreatmentFields
44
+ templates {
45
+ ...PrescriptionTemplateFields
46
+ }
47
+ }
48
+ ... on Pharmacy {
49
+ ...PharmacyFields
50
+ }
51
+ }
52
+ }
53
+
54
+ fragment PharmacyOfferFields on PharmacyOffer {
55
+ source
56
+ prescriptionId
57
+ priceType
58
+ isPromoted
59
+ attributeTags {
60
+ kind
61
+ label
62
+ }
63
+ price {
64
+ amount
65
+ retailAmount
66
+ promotions {
67
+ type
68
+ baseAmount
69
+ amountSaved
70
+ }
71
+ }
72
+ deliveryEstimate {
73
+ deliveryPromise
74
+ deliveryPromiseRangeStart
75
+ deliveryPromiseRangeEnd
76
+ }
77
+ redemptionState
78
+ redemptionMethods {
79
+ ...RedemptionMethodFields
80
+ }
81
+ }
82
+
83
+ fragment RedemptionMethodFields on RedemptionMethod {
84
+ __typename
85
+ ... on PharmacyDiscountCard {
86
+ id
87
+ prescriptionId
88
+ bin
89
+ pcn
90
+ group
91
+ memberId
92
+ externalUrl
93
+ }
94
+ }
95
+
96
+ fragment ChangeFields on Change {
97
+ key
98
+ label
99
+ status
100
+ severity
101
+ reason
102
+ category
103
+ operation
104
+ options {
105
+ ...ChoiceFields
106
+ }
107
+ before {
108
+ ...ChoiceFields
109
+ }
110
+ after {
111
+ ...ChoiceFields
112
+ }
113
+ }
114
+
115
+ fragment ChangeSetFields on ChangeSet {
116
+ changes {
117
+ ...ChangeFields
118
+ }
119
+ }
120
+
121
+ fragment OperationErrorFields on OperationError {
122
+ __typename
123
+ type
124
+ code
125
+ message
126
+ requiredPermission
127
+ service
128
+ retryable
129
+ }
130
+
131
+ fragment PharmacyFields on Pharmacy {
132
+ id
133
+ name
134
+ logo
135
+ phone
136
+ hours {
137
+ openFrom
138
+ openUntil
139
+ dayOfWeek
140
+ is24Hr
141
+ timezone
142
+ }
143
+ isOpen
144
+ nextEvents {
145
+ open {
146
+ ...PharmacyEventFields
147
+ }
148
+ close {
149
+ ...PharmacyEventFields
150
+ }
151
+ }
152
+ address {
153
+ street1
154
+ street2
155
+ city
156
+ state
157
+ postalCode
158
+ }
159
+ latitude
160
+ longitude
161
+ fulfillmentType
162
+ offers {
163
+ ...PharmacyOfferFields
164
+ }
165
+ }
166
+
167
+ fragment PharmacyEventFields on PharmacyEvent {
168
+ __typename
169
+ ... on PharmacyOpenEvent {
170
+ type
171
+ datetime
172
+ }
173
+ ... on PharmacyCloseEvent {
174
+ type
175
+ datetime
176
+ }
177
+ ... on PharmacyOpen24HrEvent {
178
+ type
179
+ }
180
+ }
181
+
182
+ fragment OrganizationFields on Organization {
183
+ id
184
+ name
185
+ customer {
186
+ __typename
187
+ ... on Customer {
188
+ id
189
+ name
190
+ }
191
+ }
192
+ settings {
193
+ brandColor
194
+ brandLogo
195
+ priorAuthorizationExceptionMessage
196
+ patientUx {
197
+ enablePatientRerouting
198
+ enableAutomatedOps
199
+ }
200
+ }
201
+ }
202
+
203
+ fragment PatientDemographicFields on PatientDemographic {
204
+ name {
205
+ first
206
+ middle
207
+ last
208
+ }
209
+ dateOfBirth
210
+ sex
211
+ gender
212
+ }
213
+
214
+ fragment PatientContactFields on PatientContact {
215
+ email
216
+ phone
217
+ address {
218
+ street1
219
+ street2
220
+ city
221
+ state
222
+ postalCode
223
+ country
224
+ }
225
+ }
226
+
227
+ fragment PatientFields on Patient {
228
+ id
229
+ demographic {
230
+ ...PatientDemographicFields
231
+ }
232
+ contact {
233
+ ...PatientContactFields
234
+ }
235
+ benefits {
236
+ status
237
+ entries {
238
+ id
239
+ bin
240
+ pcn
241
+ groupId
242
+ memberId
243
+ }
244
+ }
245
+ preferredPharmacy {
246
+ ...PharmacyFields
247
+ }
248
+ clinical {
249
+ allergies {
250
+ status
251
+ entries {
252
+ id
253
+ name
254
+ rxNormId
255
+ }
256
+ }
257
+ medications {
258
+ status
259
+ entries {
260
+ id
261
+ name
262
+ rxNormId
263
+ status
264
+ }
265
+ }
266
+ diagnoses {
267
+ status
268
+ entries {
269
+ id
270
+ name
271
+ icd10Code
272
+ }
273
+ }
274
+ notes
275
+ }
276
+ }
277
+
278
+ fragment PatientRecordFields on PatientRecordResult {
279
+ __typename
280
+ ... on Patient {
281
+ ...PatientFields
282
+ }
283
+ ... on OperationError {
284
+ ...OperationErrorFields
285
+ }
286
+ }
287
+
288
+ fragment ScreeningAlertFields on ScreeningAlert {
289
+ severity
290
+ type
291
+ description
292
+ category
293
+ involvedEntities {
294
+ id
295
+ name
296
+ }
297
+ options {
298
+ ...ChoiceFields
299
+ }
300
+ }
301
+
302
+ fragment PrescriptionFields on Prescription {
303
+ id
304
+ prescriber {
305
+ id
306
+ name {
307
+ first
308
+ middle
309
+ last
310
+ }
311
+ }
312
+ fulfillment {
313
+ state
314
+ pharmacyEstimatedReadyAt
315
+ exceptions {
316
+ id
317
+ type
318
+ message
319
+ createdAt
320
+ }
321
+ }
322
+ templateId
323
+ patient {
324
+ id
325
+ }
326
+ treatment {
327
+ ...TreatmentFields
328
+ }
329
+ instructions
330
+ dispense {
331
+ quantity
332
+ unit
333
+ daysSupply
334
+ refillsAllowed
335
+ dispenseAsWritten
336
+ }
337
+ clinical {
338
+ diagnoses {
339
+ id
340
+ name
341
+ icd10Code
342
+ }
343
+ notes
344
+ }
345
+ screeningAlerts {
346
+ ...ScreeningAlertFields
347
+ }
348
+ signing {
349
+ state
350
+ contentHash
351
+ message
352
+ signedAt
353
+ }
354
+ }
355
+
356
+ fragment OrderFields on Order {
357
+ id
358
+ state
359
+ offers {
360
+ atPharmacy {
361
+ ...PharmacyOfferFields
362
+ }
363
+ }
364
+ organization {
365
+ __typename
366
+ ... on Organization {
367
+ ...OrganizationFields
368
+ }
369
+ }
370
+ patient {
371
+ ...PatientRecordFields
372
+ }
373
+ prescriptions {
374
+ ...PrescriptionFields
375
+ }
376
+ screeningAlerts {
377
+ ...ScreeningAlertFields
378
+ }
379
+ pharmacy {
380
+ ...PharmacyFields
381
+ }
382
+ fulfillment {
383
+ state
384
+ history {
385
+ pharmacy {
386
+ ...PharmacyFields
387
+ }
388
+ selector
389
+ reason
390
+ createdAt
391
+ }
392
+ routability {
393
+ allowed
394
+ reason
395
+ }
396
+ exceptions {
397
+ id
398
+ type
399
+ message
400
+ createdAt
401
+ }
402
+ }
403
+ }
404
+
405
+ fragment PrescriptionTemplateFields on PrescriptionTemplate {
406
+ id
407
+ source
408
+ name
409
+ instructions
410
+ dispense {
411
+ quantity
412
+ unit
413
+ daysSupply
414
+ refillsAllowed
415
+ dispenseAsWritten
416
+ }
417
+ }
418
+
419
+ # ---- Result selections: one per mutation, reused by every intent on it ----
420
+
421
+ fragment PatientResultFields on PatientResult {
422
+ __typename
423
+ ... on PatientPayload {
424
+ patient {
425
+ ...PatientRecordFields
426
+ }
427
+ ...ChangeSetFields
428
+ }
429
+ ... on AmbiguousPatientMatch {
430
+ reason
431
+ candidates {
432
+ id
433
+ firstName
434
+ lastName
435
+ dateOfBirth
436
+ }
437
+ }
438
+ ... on OperationError {
439
+ ...OperationErrorFields
440
+ }
441
+ }
442
+
443
+ fragment PrescriptionResultFields on PrescriptionResult {
444
+ __typename
445
+ ... on PrescriptionPayload {
446
+ prescription {
447
+ ...PrescriptionFields
448
+ }
449
+ ...ChangeSetFields
450
+ }
451
+ ... on AmbiguousPrescriptionMatch {
452
+ reason
453
+ candidates {
454
+ id
455
+ instructions
456
+ dispense {
457
+ quantity
458
+ unit
459
+ daysSupply
460
+ refillsAllowed
461
+ dispenseAsWritten
462
+ }
463
+ }
464
+ }
465
+ ... on OperationError {
466
+ ...OperationErrorFields
467
+ }
468
+ }
469
+
470
+ fragment OrderCandidateFields on OrderCandidate {
471
+ id
472
+ pharmacy {
473
+ ...PharmacyFields
474
+ }
475
+ prescriptions {
476
+ ...PrescriptionFields
477
+ }
478
+ }
479
+
480
+ fragment OrderResultFields on OrderResult {
481
+ __typename
482
+ ... on OrderPayload {
483
+ order {
484
+ ...OrderFields
485
+ }
486
+ ...ChangeSetFields
487
+ }
488
+ ... on AmbiguousOrderMatch {
489
+ reason
490
+ candidates {
491
+ ...OrderCandidateFields
492
+ }
493
+ }
494
+ ... on OperationError {
495
+ ...OperationErrorFields
496
+ }
497
+ }
@@ -0,0 +1,4 @@
1
+ # Health check. Not part of the Rx workflow — used to verify auth + CORS.
2
+ query Ping {
3
+ ping
4
+ }
@@ -0,0 +1,38 @@
1
+ query Me {
2
+ me {
3
+ __typename
4
+ ... on User {
5
+ id
6
+ name {
7
+ first
8
+ last
9
+ }
10
+ organization {
11
+ __typename
12
+ ... on Organization {
13
+ id
14
+ name
15
+ }
16
+ }
17
+ permissions
18
+ }
19
+ ... on Patient {
20
+ id
21
+ name {
22
+ first
23
+ last
24
+ }
25
+ }
26
+ ... on Machine {
27
+ organization {
28
+ __typename
29
+ ... on Organization {
30
+ id
31
+ name
32
+ }
33
+ }
34
+ permissions
35
+ }
36
+ ...OperationErrorFields
37
+ }
38
+ }
@@ -0,0 +1,42 @@
1
+ # Order: Get / Sync / Update — all on the one `order` upsert. An order is DRAFT (no downstream
2
+ # effects) until updated to SUBMITTED.
3
+ # Get id only: read it, with its patient, prescriptions and pharmacy; nothing changes.
4
+ # Sync whatever's known: continues the patient's DRAFT order or starts one (2+ drafts:
5
+ # AmbiguousOrderMatch), with the prescriptions to put on it.
6
+ # Update that one order (by id). Omit a variable to leave that field alone:
7
+ # prescriptions { add } / { remove } (remove disconnects, doesn't cancel)
8
+ # state SUBMITTED sends it; CANCELED only from SUBMITTED
9
+ # pharmacy one field: { pharmacy } routes it there; { none: true } unassigns it (the patient chooses)
10
+
11
+ mutation GetOrder($id: ID!, $metadata: RequestMetadata!) {
12
+ order(order: { id: $id }, metadata: $metadata) {
13
+ ...OrderResultFields
14
+ }
15
+ }
16
+
17
+ mutation SyncOrder(
18
+ $id: ID
19
+ $patient: PatientReferenceInput
20
+ $prescriptions: OrderPrescriptionsPatch
21
+ $pharmacy: OrderPharmacyInput
22
+ $metadata: RequestMetadata!
23
+ ) {
24
+ order(
25
+ order: { id: $id, patient: $patient, prescriptions: $prescriptions, pharmacy: $pharmacy }
26
+ metadata: $metadata
27
+ ) {
28
+ ...OrderResultFields
29
+ }
30
+ }
31
+
32
+ mutation UpdateOrder(
33
+ $id: ID!
34
+ $prescriptions: OrderPrescriptionsPatch
35
+ $state: OrderState
36
+ $pharmacy: OrderPharmacyInput
37
+ $metadata: RequestMetadata!
38
+ ) {
39
+ order(order: { id: $id, prescriptions: $prescriptions, state: $state, pharmacy: $pharmacy }, metadata: $metadata) {
40
+ ...OrderResultFields
41
+ }
42
+ }
@@ -0,0 +1,35 @@
1
+ # Read-only order snapshots and pharmacy choices. A sole match is still a choice;
2
+ # selecting it remains an explicit UpdateOrder mutation.
3
+ query Orders(
4
+ $filter: OrdersFilterInput
5
+ $limit: Int
6
+ $pharmacy: PharmacyReferenceInput
7
+ $page: PageInput
8
+ $includePharmacies: Boolean!
9
+ ) {
10
+ orders(filter: $filter, limit: $limit) {
11
+ __typename
12
+ ... on OrdersPayload {
13
+ orders {
14
+ ...OrderFields
15
+ routablePharmacies(pharmacy: $pharmacy, page: $page) @include(if: $includePharmacies) {
16
+ options {
17
+ ...ChoiceFields
18
+ }
19
+ totalCount
20
+ nextOffset
21
+ }
22
+ }
23
+ }
24
+ ... on AmbiguousPatientMatch {
25
+ reason
26
+ candidates {
27
+ id
28
+ firstName
29
+ lastName
30
+ dateOfBirth
31
+ }
32
+ }
33
+ ...OperationErrorFields
34
+ }
35
+ }
@@ -0,0 +1,62 @@
1
+ # Patient: Get / Sync / Update — all on the one `patient` upsert.
2
+ # Get id only: read it; nothing changes.
3
+ # Sync whatever's known — an id or not: the server finds the patient, lists candidates
4
+ # (AmbiguousPatientMatch — the prescriber picks), says what's missing, or creates one when
5
+ # nothing matches and it has enough (today: first, last, DOB, sex).
6
+ # Update that one patient (by id): only the fields sent change.
7
+
8
+ mutation GetPatient($id: ID!, $metadata: RequestMetadata!) {
9
+ patient(patient: { id: $id }, metadata: $metadata) {
10
+ ...PatientResultFields
11
+ }
12
+ }
13
+
14
+ mutation SyncPatient(
15
+ $id: ID
16
+ $demographic: PatientDemographicInput
17
+ $contact: PatientContactInput
18
+ $clinical: PatientClinicalInput
19
+ $benefits: BenefitsPatch
20
+ $preferredPharmacy: PharmacyReferenceInput
21
+ $metadata: RequestMetadata!
22
+ ) {
23
+ patient(
24
+ patient: {
25
+ id: $id
26
+ demographic: $demographic
27
+ contact: $contact
28
+ clinical: $clinical
29
+ benefits: $benefits
30
+ preferredPharmacy: $preferredPharmacy
31
+ }
32
+ metadata: $metadata
33
+ ) {
34
+ ...PatientResultFields
35
+ }
36
+ }
37
+
38
+ # Demographics, contact, benefits, preferred pharmacy and/or clinical patches (allergies — `none: true` for NKDA —
39
+ # medications, diagnoses, notes).
40
+ mutation UpdatePatient(
41
+ $id: ID!
42
+ $demographic: PatientDemographicInput
43
+ $contact: PatientContactInput
44
+ $clinical: PatientClinicalInput
45
+ $benefits: BenefitsPatch
46
+ $preferredPharmacy: PharmacyReferenceInput
47
+ $metadata: RequestMetadata!
48
+ ) {
49
+ patient(
50
+ patient: {
51
+ id: $id
52
+ demographic: $demographic
53
+ contact: $contact
54
+ clinical: $clinical
55
+ benefits: $benefits
56
+ preferredPharmacy: $preferredPharmacy
57
+ }
58
+ metadata: $metadata
59
+ ) {
60
+ ...PatientResultFields
61
+ }
62
+ }