@photonhealth/client 2.0.0-rc.3 → 2.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- export const clientVersion: string = "0.14.9";
1
+ export const clientVersion: string = "0.15.0";
@@ -91,6 +91,9 @@ fragment RedemptionMethodFields on RedemptionMethod {
91
91
  memberId
92
92
  externalUrl
93
93
  }
94
+ ... on ProgramEnrollmentLink {
95
+ url
96
+ }
94
97
  }
95
98
 
96
99
  fragment ChangeFields on Change {
package/src/photon/map.ts CHANGED
@@ -38,17 +38,20 @@ import type {
38
38
  * so a schema change stops here (and typecheck says where).
39
39
  */
40
40
 
41
- /** The union has one member today, tagged by `type` so a second one doesn't change how callers switch. */
42
- const redemptionMethod = (m: RedemptionMethodFieldsFragment): RedemptionMethod => ({
43
- type: "discountCard",
44
- id: m.id,
45
- prescriptionId: m.prescriptionId,
46
- bin: m.bin,
47
- pcn: m.pcn,
48
- group: m.group,
49
- memberId: m.memberId,
50
- externalUrl: m.externalUrl,
51
- });
41
+ /** Tagged by `type`, so a new member of the union doesn't change how callers switch. */
42
+ const redemptionMethod = (m: RedemptionMethodFieldsFragment): RedemptionMethod =>
43
+ m.__typename === "ProgramEnrollmentLink"
44
+ ? { type: "enrollmentLink", url: m.url }
45
+ : {
46
+ type: "discountCard",
47
+ id: m.id,
48
+ prescriptionId: m.prescriptionId,
49
+ bin: m.bin,
50
+ pcn: m.pcn,
51
+ group: m.group,
52
+ memberId: m.memberId,
53
+ externalUrl: m.externalUrl,
54
+ };
52
55
 
53
56
  const offer = (o: PharmacyOfferFieldsFragment): PharmacyOffer => ({
54
57
  source: o.source,
@@ -119,8 +119,11 @@ export interface OfferDeliveryEstimate {
119
119
  */
120
120
  export type RedemptionState = "SETTLED" | "PENDING" | "SKIPPED";
121
121
 
122
- /** One member today — a PharmacyBenefitCard for the patient's own insurance is the expected second. */
123
- export type RedemptionMethod = PharmacyDiscountCard;
122
+ /**
123
+ * What the patient presents or follows to redeem an offer, tagged by `type`. A PharmacyBenefitCard for the
124
+ * patient's own insurance is the expected next member.
125
+ */
126
+ export type RedemptionMethod = PharmacyDiscountCard | ProgramEnrollmentLink;
124
127
 
125
128
  /** A cash discount card — a GoodRx or RxSense coupon, read out at the counter or claimed on `externalUrl`. */
126
129
  export interface PharmacyDiscountCard {
@@ -138,6 +141,12 @@ export interface PharmacyDiscountCard {
138
141
  externalUrl: string | null;
139
142
  }
140
143
 
144
+ /** A link where the patient enrolls in a partner program to get the program's offer. */
145
+ export interface ProgramEnrollmentLink {
146
+ type: "enrollmentLink";
147
+ url: string;
148
+ }
149
+
141
150
  /** An order's offers, split by whether they depend on the pharmacy it's routed to. */
142
151
  export interface OrderOffers {
143
152
  /** null until a pharmacy is chosen; `[]` when one is chosen but no offer applies. */
@@ -70,6 +70,18 @@ export const discountCard = (overrides: Partial<PharmacyDiscountCard> = {}): Pha
70
70
  ...overrides,
71
71
  });
72
72
 
73
+ type ProgramEnrollmentLink = Extract<
74
+ PharmacyOffer["redemptionMethods"][number],
75
+ { __typename: "ProgramEnrollmentLink" }
76
+ >;
77
+
78
+ /** A partner program's enrollment link, as an offer's redemption method. Pair it with `redemptionState: "SETTLED"`. */
79
+ export const enrollmentLink = (overrides: Partial<ProgramEnrollmentLink> = {}): ProgramEnrollmentLink => ({
80
+ __typename: "ProgramEnrollmentLink",
81
+ url: "https://example.test/enroll",
82
+ ...overrides,
83
+ });
84
+
73
85
  export const pharmacy = (overrides: Partial<Pharmacy> = {}): Pharmacy => ({
74
86
  __typename: "Pharmacy",
75
87
  id: "phr_1",
package/src/testing.ts CHANGED
@@ -20,6 +20,7 @@ export {
20
20
  pharmacy,
21
21
  pharmacyOffer,
22
22
  discountCard,
23
+ enrollmentLink,
23
24
  noMatch,
24
25
  ambiguous,
25
26
  } from "./testing/fixtures.ts";