@medplum/core 5.0.14 → 5.1.0

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.
@@ -34,6 +34,7 @@ import type { ObservationDefinition } from '@medplum/fhirtypes';
34
34
  import type { ObservationDefinitionQualifiedInterval } from '@medplum/fhirtypes';
35
35
  import type { OperationOutcome } from '@medplum/fhirtypes';
36
36
  import type { OperationOutcomeIssue } from '@medplum/fhirtypes';
37
+ import type { Organization } from '@medplum/fhirtypes';
37
38
  import type { Patient } from '@medplum/fhirtypes';
38
39
  import type { Period } from '@medplum/fhirtypes';
39
40
  import type { Practitioner } from '@medplum/fhirtypes';
@@ -111,6 +112,38 @@ export declare const AckCode: {
111
112
 
112
113
  export declare type AckCode = keyof typeof AckCode;
113
114
 
115
+ /**
116
+ * Parameters for adding a pharmacy to a patient's favorites.
117
+ */
118
+ export declare interface AddFavoriteParams {
119
+ patientId: string;
120
+ pharmacy: Organization;
121
+ setAsPrimary: boolean;
122
+ }
123
+
124
+ /**
125
+ * Response from adding a pharmacy to a patient's favorites.
126
+ */
127
+ export declare interface AddPharmacyResponse {
128
+ success: boolean;
129
+ message: string;
130
+ organization?: Organization;
131
+ }
132
+
133
+ /**
134
+ * Adds or updates a preferred pharmacy extension on a Patient.
135
+ * If the pharmacy already exists, updates its type. Otherwise, adds a new extension.
136
+ * If isPrimary is true, other pharmacies are set to 'preferred'.
137
+ *
138
+ * @param patient - The Patient resource to modify (will be mutated).
139
+ * @param orgRef - Reference to the Organization resource.
140
+ * @param isPrimary - Whether to set this as the primary pharmacy.
141
+ * @param preferenceTypeSystem - Optional coding system URL for pharmacy preference type.
142
+ * Defaults to {@link PHARMACY_PREFERENCE_TYPE_SYSTEM}.
143
+ * @returns The modified Patient resource.
144
+ */
145
+ export declare function addPreferredPharmacyToPatient(patient: Patient, orgRef: Reference<Organization>, isPrimary: boolean, preferenceTypeSystem?: string): Patient;
146
+
114
147
  /**
115
148
  * Adds the supplied profileUrl to the resource.meta.profile if it is not already
116
149
  * specified
@@ -932,6 +965,17 @@ export declare interface CreatePdfOptions extends Omit<CreateBinaryOptions, 'dat
932
965
  readonly fonts?: TFontDictionary;
933
966
  }
934
967
 
968
+ /**
969
+ * Creates a preferredPharmacy extension object.
970
+ *
971
+ * @param orgRef - Reference to the Organization resource.
972
+ * @param isPrimary - Whether this is the primary pharmacy.
973
+ * @param preferenceTypeSystem - Optional coding system URL for pharmacy preference type.
974
+ * Defaults to {@link PHARMACY_PREFERENCE_TYPE_SYSTEM}.
975
+ * @returns The extension object to add to a Patient.
976
+ */
977
+ export declare function createPreferredPharmacyExtension(orgRef: Reference<Organization>, isPrimary: boolean, preferenceTypeSystem?: string): Extension;
978
+
935
979
  export declare function createProcessingIssue(expression: string, message: string, err: Error, data?: Record<string, any>): OperationOutcomeIssue;
936
980
 
937
981
  /**
@@ -2092,6 +2136,18 @@ export declare function getPathDifference(parentPath: string, path: string): str
2092
2136
  */
2093
2137
  export declare function getPathDisplayName(path: string): string;
2094
2138
 
2139
+ /**
2140
+ * Extracts preferred pharmacies from a Patient resource's extensions.
2141
+ *
2142
+ * @param patient - The Patient resource.
2143
+ * @param preferenceTypeSystem - Optional coding system URL to filter by. When provided, only
2144
+ * codings with this system are considered when determining primary status. When omitted, any
2145
+ * coding with a `primary` code is matched regardless of system — this allows reading pharmacy
2146
+ * preferences written by any vendor.
2147
+ * @returns An array of PreferredPharmacy objects.
2148
+ */
2149
+ export declare function getPreferredPharmaciesFromPatient(patient: Patient, preferenceTypeSystem?: string): PreferredPharmacy[];
2150
+
2095
2151
  /**
2096
2152
  * Returns a human friendly display name for a FHIR element property or slice name
2097
2153
  * @param propertyName - The FHIR element property or slice name
@@ -2725,6 +2781,13 @@ export declare interface IReconnectingWebSocketCtor {
2725
2781
 
2726
2782
  export declare function isAccepted(outcome: OperationOutcome): boolean;
2727
2783
 
2784
+ /**
2785
+ * Type guard to validate an add pharmacy bot response.
2786
+ * @param value - The value to check.
2787
+ * @returns True if the value is a valid AddPharmacyResponse.
2788
+ */
2789
+ export declare function isAddPharmacyResponse(value: unknown): value is AddPharmacyResponse;
2790
+
2728
2791
  export declare class IsAtom extends BooleanInfixOperatorAtom {
2729
2792
  constructor(left: Atom, right: Atom);
2730
2793
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
@@ -2863,6 +2926,13 @@ export declare function isOk(outcome: OperationOutcome): boolean;
2863
2926
 
2864
2927
  export declare function isOperationOutcome(value: unknown): value is OperationOutcome;
2865
2928
 
2929
+ /**
2930
+ * Type guard to validate that a value is an array of Organization resources.
2931
+ * @param value - The value to check.
2932
+ * @returns True if the value is an array of Organization resources.
2933
+ */
2934
+ export declare function isOrganizationArray(value: unknown): value is Organization[];
2935
+
2866
2936
  /**
2867
2937
  * Determines if the input is a Period object.
2868
2938
  * This is heuristic based, as we do not have strong typing at runtime.
@@ -5352,6 +5422,7 @@ export declare interface MedplumInfraConfig {
5352
5422
  rdsSecretsArn?: string;
5353
5423
  rdsReaderInstanceType?: string;
5354
5424
  rdsProxyEnabled?: boolean;
5425
+ rdsForceRetain?: boolean;
5355
5426
  cacheNodeType?: string;
5356
5427
  cacheSecurityGroupId?: string;
5357
5428
  desiredServerCount: number;
@@ -5507,6 +5578,7 @@ export declare interface MedplumSourceInfraConfig {
5507
5578
  rdsReaderInstanceType?: ValueOrExternalSecret<string>;
5508
5579
  rdsProxyEnabled?: ValueOrExternalSecret<boolean>;
5509
5580
  rdsClusterParameters?: StringMap;
5581
+ rdsForceRetain?: ValueOrExternalSecret<boolean>;
5510
5582
  rdsAutoMinorVersionUpgrade?: ValueOrExternalSecret<boolean>;
5511
5583
  cacheNodeType?: ValueOrExternalSecret<string>;
5512
5584
  cacheSecurityGroupId?: ValueOrExternalSecret<string>;
@@ -6032,8 +6104,33 @@ export declare class ParserBuilder {
6032
6104
  */
6033
6105
  export declare function pathToJSONPointer(path: string): string;
6034
6106
 
6107
+ export declare const PATIENT_PREFERRED_PHARMACY_URL = "http://hl7.org/fhir/StructureDefinition/patient-preferredPharmacy";
6108
+
6035
6109
  export declare type PendingSubscriptionRequest = Omit<SubscriptionRequest, 'endpoint'>;
6036
6110
 
6111
+ /**
6112
+ * Default pharmacy preference type system URL.
6113
+ * Vendors may define their own system URL and pass it to the pharmacy functions.
6114
+ */
6115
+ export declare const PHARMACY_PREFERENCE_TYPE_SYSTEM = "https://medplum.com/fhir/CodeSystem/pharmacy-preference-type";
6116
+
6117
+ export declare const PHARMACY_TYPE_PREFERRED = "preferred";
6118
+
6119
+ export declare const PHARMACY_TYPE_PRIMARY = "primary";
6120
+
6121
+ /**
6122
+ * Parameters for searching pharmacies.
6123
+ */
6124
+ export declare interface PharmacySearchParams {
6125
+ name?: string;
6126
+ city?: string;
6127
+ state?: string;
6128
+ zip?: string;
6129
+ address?: string;
6130
+ phoneOrFax?: string;
6131
+ ncpdpID?: string;
6132
+ }
6133
+
6037
6134
  /**
6038
6135
  * Returns true if the two numbers are equal to the given precision.
6039
6136
  * @param a - The first number.
@@ -6089,6 +6186,11 @@ export declare class ParserBuilder {
6089
6186
 
6090
6187
  export declare const preconditionFailed: OperationOutcome;
6091
6188
 
6189
+ export declare interface PreferredPharmacy {
6190
+ organizationRef: Reference<Organization>;
6191
+ isPrimary: boolean;
6192
+ }
6193
+
6092
6194
  export declare abstract class PrefixOperatorAtom implements Atom {
6093
6195
  readonly operator: string;
6094
6196
  readonly child: Atom;
@@ -6415,6 +6517,15 @@ export declare class ParserBuilder {
6415
6517
  */
6416
6518
  export declare function removeDuplicates(arr: TypedValue[]): TypedValue[];
6417
6519
 
6520
+ /**
6521
+ * Removes a preferred pharmacy extension from a Patient.
6522
+ *
6523
+ * @param patient - The Patient resource to modify (will be mutated).
6524
+ * @param orgRef - Reference to the Organization resource to remove.
6525
+ * @returns The modified Patient resource.
6526
+ */
6527
+ export declare function removePreferredPharmacyFromPatient(patient: Patient, orgRef: Reference<Organization>): Patient;
6528
+
6418
6529
  /**
6419
6530
  * Removes the supplied profileUrl from the resource.meta.profile if it is present
6420
6531
  * @param resource - A FHIR resource
@@ -6846,6 +6957,7 @@ export declare class ParserBuilder {
6846
6957
  private readonly criteriaEntriesBySubscriptionId;
6847
6958
  private wsClosed;
6848
6959
  private pingTimer;
6960
+ private tokenRefreshTimer;
6849
6961
  private readonly pingIntervalMs;
6850
6962
  private waitingForPong;
6851
6963
  private currentProfile;
@@ -6860,6 +6972,9 @@ export declare class ParserBuilder {
6860
6972
  private removeCriteriaEntry;
6861
6973
  private subscribeToCriteria;
6862
6974
  private refreshAllSubscriptions;
6975
+ private isReconnecting;
6976
+ private rebindCriteriaEntry;
6977
+ private checkTokenExpirations;
6863
6978
  addCriteria(criteria: string, subscriptionProps?: Partial<Subscription>): SubscriptionEmitter;
6864
6979
  removeCriteria(criteria: string, subscriptionProps?: Partial<Subscription>): void;
6865
6980
  getWebSocket(): IReconnectingWebSocket;
@@ -34,6 +34,7 @@ import type { ObservationDefinition } from '@medplum/fhirtypes';
34
34
  import type { ObservationDefinitionQualifiedInterval } from '@medplum/fhirtypes';
35
35
  import type { OperationOutcome } from '@medplum/fhirtypes';
36
36
  import type { OperationOutcomeIssue } from '@medplum/fhirtypes';
37
+ import type { Organization } from '@medplum/fhirtypes';
37
38
  import type { Patient } from '@medplum/fhirtypes';
38
39
  import type { Period } from '@medplum/fhirtypes';
39
40
  import type { Practitioner } from '@medplum/fhirtypes';
@@ -111,6 +112,38 @@ export declare const AckCode: {
111
112
 
112
113
  export declare type AckCode = keyof typeof AckCode;
113
114
 
115
+ /**
116
+ * Parameters for adding a pharmacy to a patient's favorites.
117
+ */
118
+ export declare interface AddFavoriteParams {
119
+ patientId: string;
120
+ pharmacy: Organization;
121
+ setAsPrimary: boolean;
122
+ }
123
+
124
+ /**
125
+ * Response from adding a pharmacy to a patient's favorites.
126
+ */
127
+ export declare interface AddPharmacyResponse {
128
+ success: boolean;
129
+ message: string;
130
+ organization?: Organization;
131
+ }
132
+
133
+ /**
134
+ * Adds or updates a preferred pharmacy extension on a Patient.
135
+ * If the pharmacy already exists, updates its type. Otherwise, adds a new extension.
136
+ * If isPrimary is true, other pharmacies are set to 'preferred'.
137
+ *
138
+ * @param patient - The Patient resource to modify (will be mutated).
139
+ * @param orgRef - Reference to the Organization resource.
140
+ * @param isPrimary - Whether to set this as the primary pharmacy.
141
+ * @param preferenceTypeSystem - Optional coding system URL for pharmacy preference type.
142
+ * Defaults to {@link PHARMACY_PREFERENCE_TYPE_SYSTEM}.
143
+ * @returns The modified Patient resource.
144
+ */
145
+ export declare function addPreferredPharmacyToPatient(patient: Patient, orgRef: Reference<Organization>, isPrimary: boolean, preferenceTypeSystem?: string): Patient;
146
+
114
147
  /**
115
148
  * Adds the supplied profileUrl to the resource.meta.profile if it is not already
116
149
  * specified
@@ -932,6 +965,17 @@ export declare interface CreatePdfOptions extends Omit<CreateBinaryOptions, 'dat
932
965
  readonly fonts?: TFontDictionary;
933
966
  }
934
967
 
968
+ /**
969
+ * Creates a preferredPharmacy extension object.
970
+ *
971
+ * @param orgRef - Reference to the Organization resource.
972
+ * @param isPrimary - Whether this is the primary pharmacy.
973
+ * @param preferenceTypeSystem - Optional coding system URL for pharmacy preference type.
974
+ * Defaults to {@link PHARMACY_PREFERENCE_TYPE_SYSTEM}.
975
+ * @returns The extension object to add to a Patient.
976
+ */
977
+ export declare function createPreferredPharmacyExtension(orgRef: Reference<Organization>, isPrimary: boolean, preferenceTypeSystem?: string): Extension;
978
+
935
979
  export declare function createProcessingIssue(expression: string, message: string, err: Error, data?: Record<string, any>): OperationOutcomeIssue;
936
980
 
937
981
  /**
@@ -2092,6 +2136,18 @@ export declare function getPathDifference(parentPath: string, path: string): str
2092
2136
  */
2093
2137
  export declare function getPathDisplayName(path: string): string;
2094
2138
 
2139
+ /**
2140
+ * Extracts preferred pharmacies from a Patient resource's extensions.
2141
+ *
2142
+ * @param patient - The Patient resource.
2143
+ * @param preferenceTypeSystem - Optional coding system URL to filter by. When provided, only
2144
+ * codings with this system are considered when determining primary status. When omitted, any
2145
+ * coding with a `primary` code is matched regardless of system — this allows reading pharmacy
2146
+ * preferences written by any vendor.
2147
+ * @returns An array of PreferredPharmacy objects.
2148
+ */
2149
+ export declare function getPreferredPharmaciesFromPatient(patient: Patient, preferenceTypeSystem?: string): PreferredPharmacy[];
2150
+
2095
2151
  /**
2096
2152
  * Returns a human friendly display name for a FHIR element property or slice name
2097
2153
  * @param propertyName - The FHIR element property or slice name
@@ -2725,6 +2781,13 @@ export declare interface IReconnectingWebSocketCtor {
2725
2781
 
2726
2782
  export declare function isAccepted(outcome: OperationOutcome): boolean;
2727
2783
 
2784
+ /**
2785
+ * Type guard to validate an add pharmacy bot response.
2786
+ * @param value - The value to check.
2787
+ * @returns True if the value is a valid AddPharmacyResponse.
2788
+ */
2789
+ export declare function isAddPharmacyResponse(value: unknown): value is AddPharmacyResponse;
2790
+
2728
2791
  export declare class IsAtom extends BooleanInfixOperatorAtom {
2729
2792
  constructor(left: Atom, right: Atom);
2730
2793
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
@@ -2863,6 +2926,13 @@ export declare function isOk(outcome: OperationOutcome): boolean;
2863
2926
 
2864
2927
  export declare function isOperationOutcome(value: unknown): value is OperationOutcome;
2865
2928
 
2929
+ /**
2930
+ * Type guard to validate that a value is an array of Organization resources.
2931
+ * @param value - The value to check.
2932
+ * @returns True if the value is an array of Organization resources.
2933
+ */
2934
+ export declare function isOrganizationArray(value: unknown): value is Organization[];
2935
+
2866
2936
  /**
2867
2937
  * Determines if the input is a Period object.
2868
2938
  * This is heuristic based, as we do not have strong typing at runtime.
@@ -5352,6 +5422,7 @@ export declare interface MedplumInfraConfig {
5352
5422
  rdsSecretsArn?: string;
5353
5423
  rdsReaderInstanceType?: string;
5354
5424
  rdsProxyEnabled?: boolean;
5425
+ rdsForceRetain?: boolean;
5355
5426
  cacheNodeType?: string;
5356
5427
  cacheSecurityGroupId?: string;
5357
5428
  desiredServerCount: number;
@@ -5507,6 +5578,7 @@ export declare interface MedplumSourceInfraConfig {
5507
5578
  rdsReaderInstanceType?: ValueOrExternalSecret<string>;
5508
5579
  rdsProxyEnabled?: ValueOrExternalSecret<boolean>;
5509
5580
  rdsClusterParameters?: StringMap;
5581
+ rdsForceRetain?: ValueOrExternalSecret<boolean>;
5510
5582
  rdsAutoMinorVersionUpgrade?: ValueOrExternalSecret<boolean>;
5511
5583
  cacheNodeType?: ValueOrExternalSecret<string>;
5512
5584
  cacheSecurityGroupId?: ValueOrExternalSecret<string>;
@@ -6032,8 +6104,33 @@ export declare class ParserBuilder {
6032
6104
  */
6033
6105
  export declare function pathToJSONPointer(path: string): string;
6034
6106
 
6107
+ export declare const PATIENT_PREFERRED_PHARMACY_URL = "http://hl7.org/fhir/StructureDefinition/patient-preferredPharmacy";
6108
+
6035
6109
  export declare type PendingSubscriptionRequest = Omit<SubscriptionRequest, 'endpoint'>;
6036
6110
 
6111
+ /**
6112
+ * Default pharmacy preference type system URL.
6113
+ * Vendors may define their own system URL and pass it to the pharmacy functions.
6114
+ */
6115
+ export declare const PHARMACY_PREFERENCE_TYPE_SYSTEM = "https://medplum.com/fhir/CodeSystem/pharmacy-preference-type";
6116
+
6117
+ export declare const PHARMACY_TYPE_PREFERRED = "preferred";
6118
+
6119
+ export declare const PHARMACY_TYPE_PRIMARY = "primary";
6120
+
6121
+ /**
6122
+ * Parameters for searching pharmacies.
6123
+ */
6124
+ export declare interface PharmacySearchParams {
6125
+ name?: string;
6126
+ city?: string;
6127
+ state?: string;
6128
+ zip?: string;
6129
+ address?: string;
6130
+ phoneOrFax?: string;
6131
+ ncpdpID?: string;
6132
+ }
6133
+
6037
6134
  /**
6038
6135
  * Returns true if the two numbers are equal to the given precision.
6039
6136
  * @param a - The first number.
@@ -6089,6 +6186,11 @@ export declare class ParserBuilder {
6089
6186
 
6090
6187
  export declare const preconditionFailed: OperationOutcome;
6091
6188
 
6189
+ export declare interface PreferredPharmacy {
6190
+ organizationRef: Reference<Organization>;
6191
+ isPrimary: boolean;
6192
+ }
6193
+
6092
6194
  export declare abstract class PrefixOperatorAtom implements Atom {
6093
6195
  readonly operator: string;
6094
6196
  readonly child: Atom;
@@ -6415,6 +6517,15 @@ export declare class ParserBuilder {
6415
6517
  */
6416
6518
  export declare function removeDuplicates(arr: TypedValue[]): TypedValue[];
6417
6519
 
6520
+ /**
6521
+ * Removes a preferred pharmacy extension from a Patient.
6522
+ *
6523
+ * @param patient - The Patient resource to modify (will be mutated).
6524
+ * @param orgRef - Reference to the Organization resource to remove.
6525
+ * @returns The modified Patient resource.
6526
+ */
6527
+ export declare function removePreferredPharmacyFromPatient(patient: Patient, orgRef: Reference<Organization>): Patient;
6528
+
6418
6529
  /**
6419
6530
  * Removes the supplied profileUrl from the resource.meta.profile if it is present
6420
6531
  * @param resource - A FHIR resource
@@ -6846,6 +6957,7 @@ export declare class ParserBuilder {
6846
6957
  private readonly criteriaEntriesBySubscriptionId;
6847
6958
  private wsClosed;
6848
6959
  private pingTimer;
6960
+ private tokenRefreshTimer;
6849
6961
  private readonly pingIntervalMs;
6850
6962
  private waitingForPong;
6851
6963
  private currentProfile;
@@ -6860,6 +6972,9 @@ export declare class ParserBuilder {
6860
6972
  private removeCriteriaEntry;
6861
6973
  private subscribeToCriteria;
6862
6974
  private refreshAllSubscriptions;
6975
+ private isReconnecting;
6976
+ private rebindCriteriaEntry;
6977
+ private checkTokenExpirations;
6863
6978
  addCriteria(criteria: string, subscriptionProps?: Partial<Subscription>): SubscriptionEmitter;
6864
6979
  removeCriteria(criteria: string, subscriptionProps?: Partial<Subscription>): void;
6865
6980
  getWebSocket(): IReconnectingWebSocket;