@awell-health/awell-extensions 2.1.151 → 2.1.153
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.
- package/dist/extensions/markdown.json +1 -1
- package/dist/extensions/metriport/actions/index.d.ts +86 -2
- package/dist/extensions/metriport/actions/patient/fields.d.ts +2 -2
- package/dist/extensions/metriport/actions/patient/fields.js +2 -2
- package/dist/extensions/metriport/actions/patient/fields.js.map +1 -1
- package/dist/extensions/metriport/actions/patient/validation.d.ts +14 -4
- package/dist/extensions/metriport/actions/patient/validation.js +7 -1
- package/dist/extensions/metriport/actions/patient/validation.js.map +1 -1
- package/dist/extensions/metriport/settings.d.ts +12 -0
- package/dist/extensions/metriport/settings.js +61 -1
- package/dist/extensions/metriport/settings.js.map +1 -1
- package/dist/extensions/metriport/validation/settings.zod.d.ts +3 -0
- package/dist/extensions/metriport/validation/settings.zod.js +2 -0
- package/dist/extensions/metriport/validation/settings.zod.js.map +1 -1
- package/dist/extensions/metriport/webhooks/enrollment.js +30 -2
- package/dist/extensions/metriport/webhooks/enrollment.js.map +1 -1
- package/dist/extensions/metriport/webhooks/index.d.ts +7 -0
- package/package.json +1 -1
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
},
|
|
162
162
|
"metriport": {
|
|
163
163
|
"readme": "---\ntitle: Metriport\ndescription: Metriport is Plaid for healthcare data.\n---\n# Metriport\n\nMetriport is Plaid for healthcare data. We help digital health companies access and manage patient health and medical data, through an open-source and universal API.\n\nThrough a single integration, our API enables modern health companies to get the comprehensive patient data they need from both HIEs and EHRs, as well as popular wearable devices.\n\nAs a developer-first interoperability solution, Metriport is powering the next wave of innovative companies, accelerating a revolution in digital health.\n\nTo learn more visit [https://www.metriport.com/](https://www.metriport.com/)\n# Extension settings\n\nIn order to set up this extension, **you will need to provide a Metriport API key**. You can obtain an API key via the Metriport dashboard by selecting the `Developers tab`. To learn more on how to get started with Metriport visit our [quick start docs](https://docs.metriport.com/medical-api/getting-started/quickstart) for our Medical API. Also, to better understand how our API keys work check out the [API Keys section](https://docs.metriport.com/home/api-info/api-keys) of our docs as well.\n\n# Custom Actions\n\n**GENERAL NOTE: Make sure to create Organizations and Facilities in Metriport before using this extension. A Patient must be associated with a Facility by providing the facilityId when stated in the actions.**\n\n## Create Patient\n\nCreates a Patient in Metriport for the specified Facility where the Patient is receiving care.\n\nOptionally, providing a **Cohort** ID enrolls the Patient in real-time monitoring by adding them to that cohort. Note that enrolling a Patient in real-time monitoring has downstream consequences: once you start receiving updates about the Patient, you are expected to contribute data back to Metriport.\n\nVisit [endpoint docs](https://docs.metriport.com/medical-api/api-reference/patient/create-patient) for more info.\n\n## Update Patient\n\nUpdates the specified Patient.\n\nVisit [endpoint docs](https://docs.metriport.com/medical-api/api-reference/patient/update-patient) for more info.\n\n## Get Patient\n\nRetrieves the specified Patient.\n\nVisit [endpoint docs](https://docs.metriport.com/medical-api/api-reference/patient/get-patient) for more info.\n\n## Remove Patient\n\nRemoves a Patient at Metriport and at HIEs the Patient is linked to.\n\nVisit [endpoint docs](https://docs.metriport.com/medical-api/api-reference/patient/delete-patient) for more info.\n\n## List Documents\n\nLists all Documents that can be retrieved for a Patient.\n\nVisit [endpoint docs](https://docs.metriport.com/medical-api/api-reference/document/list-documents) for more info.\n\n**NOTE: It also returns the status of querying Document references across HIEs, indicating whether there is an asynchronous query in progress (status processing) or not (status completed). If the query is in progress, you will also receive the total number of Documents to be queried as well as the ones that have already been completed.**\n\n## Query Documents\n\nTriggers a Document query for the specified Patient across HIEs.\n\nVisit [endpoint docs](https://docs.metriport.com/medical-api/api-reference/document/start-document-query) for more info.\n\n**NOTE: When executed, this endpoint triggers an asynchronous Document query with HIEs and immediately returns the status of Document query, processing .**\n\n## Get Document Url\n\nGets a presigned URL for downloading the specified Document.\n\nVisit [endpoint docs](https://docs.metriport.com/medical-api/api-reference/document/get-document) for more info.\n\n**NOTE: This endpoint returns a URL which you can use to download the specified Document using the file name provided from the List Documents endpoint.**\n\n## Remove Patient from Cohort\n\nRemoves the specified Patient from a cohort.\n\nVisit [endpoint docs](https://docs.metriport.com/medical-api/api-reference/cohort/remove-patients-from-cohort) for more info.\n\n## Get Webhook Bundle\n\nFetches the FHIR bundle from a Metriport webhook payload URL — e.g. the [Encounter Bundle](https://docs.metriport.com/medical-api/handling-data/patient-encounter-bundle) from an ADT notification, or a discharge summary. Pass the `bundleUrl` data point emitted by the **Enrollment** webhook; the action downloads the bundle and returns it on the `bundle` data point.\n\nWhen the payload is a Patient Encounter Bundle, the action also rewrites it into an executable FHIR transaction and returns that on the `transactionBundle` data point, ready to hand to the Medplum **Find or create resource** action.\n\n**NOTE: Metriport pre-signed URLs are only valid for 10 minutes, so this action should run early in the care flow, shortly after the enrollment webhook fires.**\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `url` | string | The pre-signed payload URL to fetch (the webhook's `bundleUrl` data point). |\n| `eventType` | string (optional) | The Metriport notification type — wire this from the enrollment webhook's `eventType` data point. Recorded on the import Provenance so admit, transfer and discharge can be told apart. |\n| `provenanceReason` | text (optional) | Free-text reason recorded on the import Provenance, describing why the data was imported. |\n\n| Data point | Type | Description |\n| --- | --- | --- |\n| `bundle` | json | The FHIR bundle fetched from the URL, exactly as Metriport sent it. |\n| `transactionBundle` | json | The same data rewritten as an executable FHIR transaction. Omitted when the payload is not a Patient Encounter Bundle. |\n\n### Building the transaction bundle\n\nMetriport delivers a bundle of `type: 'collection'`, which is **not executable**. Handing it straight to Medplum does nothing useful: no entry carries `request` metadata saying what to do with it, and every internal reference points at a Metriport UUID that means nothing in Medplum. The action therefore builds a second, executable bundle rather than passing the original through.\n\nThe transformation is a pure function with no Medplum access of its own — this extension holds Metriport credentials only. That rules out reading Medplum to reconcile against what is already there, so every lookup is expressed declaratively and resolved by the server when the transaction executes.\n\n**The Patient is never written.** Awell/Medplum is the source of truth for patient demographics, so the Patient entry is dropped entirely and every reference to it becomes a conditional reference:\n\n```\nPatient?identifier=https://awellhealth.com/patients|<awell patient id>\n```\n\nOmitting the entry guarantees structurally that a Metriport ADT feed can never overwrite the patient record.\n\n**Everything else is written idempotently.** Each Metriport resource is stamped with an identifier derived from its Metriport id and written with a conditional update:\n\n```\nidentifier: { system: 'https://metriport.com/fhir/encounter', value: '<metriport id>' }\nrequest: PUT Encounter?identifier=https://metriport.com/fhir/encounter|<metriport id>\n```\n\nA conditional update creates on zero matches and updates on one, so a redelivered notification updates in place instead of duplicating Conditions, Observations, Practitioners and Locations — and the admit and discharge notifications for one visit converge on a single Encounter. Existing identifiers are kept, so the Encounter keeps its HL7 `VN` visit number alongside ours.\n\n**References are rewritten to Metriport's own `fullUrl`s.** Metriport resolves its relationships correctly, but emits them in a form FHIR cannot match: entries carry `urn:uuid:` fullUrls while references to them are relative.\n\n```\nfullUrl: urn:uuid:3ca5e8d2-7c84-45ab-91e7-834f8becde12\nreference: Location/3ca5e8d2-7c84-45ab-91e7-834f8becde12\n```\n\nA transaction resolves an internal reference by matching it against `fullUrl` verbatim, and a relative reference does not match a `urn:uuid:` one — Medplum would read it as a reference to a *Medplum* Location with that id, which does not exist. Rewriting the reference to the entry's `fullUrl` closes the gap while keeping Metriport's identity. This is also why the result is a `transaction` and not a `batch`: `urn:uuid` resolution is a transaction feature.\n\n**`meta` is stripped from every resource.** Medplum's `meta.accounts` is inherited from the compartment of the Patient a resource references, but specifying `meta` at all on a create or update replaces those inherited accounts instead of adding to them. Metriport's Encounter arrives with a `meta`, so it is removed. `resource.id` is dropped too, for a separate reason: Medplum assigns identity, and the entry's `fullUrl` already carries the local identity the transaction needs.\n\n**Two entries are synthesised.** An `Organization` named *Metriport Realtime Monitoring*, created with `ifNoneExist` so an existing one is reused rather than overwritten; and a `Provenance` recording the import — what it created, when, which Metriport bundle it came from, and which ADT event triggered it (`patient.admit` → `A01`, `patient.transfer` → `A02`, `patient.discharge` → `A03`).\n\n`extensions/metriport/actions/webhookBundle/bundle/transform.test.ts` asserts the complete output for a real `patient.admit` bundle, if you want to see the whole before/after in one place.\n\n### Wiring it into a care flow\n\n1. **Enrollment** webhook fires and emits `bundleUrl` and `eventType`.\n2. **Get Webhook Bundle** — pass `bundleUrl` to `url` and `eventType` to `eventType`. Run this early; the URL expires after 10 minutes.\n3. Medplum **Find or create resource** — pass the `transactionBundle` data point to its `resourceJson` field. No changes to that action are needed; it detects a Bundle and executes it.\n\n**PREREQUISITE: for imported resources to be tagged with the Metriport organization, the Medplum Patient must already carry it in `meta.accounts` before the notification arrives.** Resources created without a `meta` inherit their accounts from the compartment of the Patient they reference, so tagging the Patient once causes every subsequent import to inherit it automatically. Note that this only covers resources *in* the patient compartment — `Location` and `Practitioner` are shared directory resources and are intentionally created untagged, since scoping a hospital or a physician to one patient's tenant would be wrong.\n\n**NOTE: the conditional Patient reference only resolves if your Medplum Patients carry an identifier under the `https://awellhealth.com/patients` system with the Awell patient id as its value. A conditional reference that matches no Patient fails the whole transaction.**\n\n### When the transaction bundle is omitted\n\n`Get Webhook Bundle` serves several Metriport webhook types and only ADT notifications carry encounter bundles. For any payload that is not a `collection` bundle, `transactionBundle` is simply omitted and `bundle` is emitted on its own — the action still succeeds.\n\nA `collection` bundle that is missing its Patient or Encounter entry is treated differently: that is an encounter bundle which does not describe an encounter, so the action **fails** rather than silently emitting a partial result.\n\n# Webhooks\n\n## Enrollment\n\nAn enrollment trigger that starts a care flow when Metriport sends a [real-time patient notification](https://docs.metriport.com/medical-api/handling-data/realtime-patient-notifications).\n\nMetriport POSTs every notification type to the same endpoint, so this webhook discriminates on the notification `type` and only enrolls on two events. The `eventType` data point carries the raw Metriport webhook type:\n\n- `patient.admit` (HL7 ADT^A01) → `eventType` = `patient.admit`. The payload carries a pre-signed URL to the [FHIR Encounter Bundle](https://docs.metriport.com/medical-api/handling-data/patient-encounter-bundle).\n- `medical.discharge-summary` → `eventType` = `medical.discharge-summary`. This event is currently undocumented by Metriport and is modelled on the published `medical.*` webhook family (a `patients` array).\n\nThe webhook validates the request, emits the data points (including the pre-signed bundle URL on `bundleUrl`), and replies immediately — it does **not** download the bundle. Fetch the bundle later in the care flow with the **Get Webhook Bundle** action, using the `bundleUrl` data point. Because the URL expires after 10 minutes, run that action early.\n\nUse the `eventType` data point in your care flow to branch on admit vs discharge. Every other notification type (`patient.discharge`, `patient.transfer`, ...) is acknowledged with a `200` but does not enroll a patient. Metriport [verification `ping` messages](https://docs.metriport.com/medical-api/getting-started/webhooks#the-ping-message) are answered with a `200` that echoes the ping value back as `pong: <value>`.\n\n### Data points\n\n| Data point | Type | Description |\n| --- | --- | --- |\n| `eventType` | string | The Metriport webhook type: `patient.admit` or `medical.discharge-summary` |\n| `metriportPatientId` | string | The Metriport patient ID (also used as the patient identifier for enrollment) |\n| `externalId` | string | Your external patient ID, if provided to Metriport |\n| `admitTimestamp` | date | When the patient was admitted (admit events only) |\n| `whenSourceSent` | date | When the source sent the notification, if available (admit events) |\n| `messageId` | string | The Metriport message ID for the notification |\n| `bundleUrl` | string | Pre-signed URL to the FHIR bundle; fetch it with the **Get Webhook Bundle** action (valid for 10 minutes) |\n\n### Verifying incoming requests\n\nOptionally set the **Webhook Key** setting to the webhook key from the Metriport dashboard (Settings/Developers tab). Metriport [authenticates each webhook](https://docs.metriport.com/medical-api/getting-started/webhooks#authentication) with an HMAC-SHA256 signature of the raw request body, keyed with your webhook key and sent in the `x-metriport-signature` header. When the setting is populated, the webhook recomputes the HMAC over the raw body and rejects any request whose signature is missing or does not match (`401`). When left empty, requests are not verified.\n\n## More Info\n\nFor more information on how to integrate with Metriport please visit our [Medical API docs](https://docs.metriport.com/medical-api/getting-started/quickstart)\n",
|
|
164
|
-
"changelog": "# Metriport changelog\n\n## July 2026\n\n- Add `enrollment` webhook: an enrollment trigger for Metriport real-time patient notifications. The `eventType` data point carries the Metriport webhook type (`patient.admit` or `medical.discharge-summary`) so care flows can distinguish on it. The webhook validates and replies immediately, emitting the pre-signed FHIR bundle URL on the `bundleUrl` data point rather than downloading the bundle inline.\n- Add `Get Webhook Bundle` action: fetches the FHIR bundle from a Metriport webhook payload URL (the webhook's `bundleUrl`), for use later in the care flow.\n- Add optional `Webhook Key` setting used to verify incoming webhook requests via Metriport's HMAC-SHA256 signature (`x-metriport-signature` header), computed over the raw request body."
|
|
164
|
+
"changelog": "# Metriport changelog\n\n## August 2026\n\n- `Date of Birth` on the `Create Patient` and `Update Patient` actions is now a date field rather than a free-text string, so care flows can map a date onto it directly instead of hand-formatting `YYYY-MM-DD`. The value is normalised to the date-only string Metriport expects, so care flows already passing `YYYY-MM-DD` are unaffected.\n\n## July 2026\n\n- Add `enrollment` webhook: an enrollment trigger for Metriport real-time patient notifications. The `eventType` data point carries the Metriport webhook type (`patient.admit` or `medical.discharge-summary`) so care flows can distinguish on it. The webhook validates and replies immediately, emitting the pre-signed FHIR bundle URL on the `bundleUrl` data point rather than downloading the bundle inline.\n- Add `Get Webhook Bundle` action: fetches the FHIR bundle from a Metriport webhook payload URL (the webhook's `bundleUrl`), for use later in the care flow.\n- Add optional `Webhook Key` setting used to verify incoming webhook requests via Metriport's HMAC-SHA256 signature (`x-metriport-signature` header), computed over the raw request body."
|
|
165
165
|
},
|
|
166
166
|
"nexuzhealth": {
|
|
167
167
|
"readme": "---\ntitle: nexuzhealth\ndescription: Demo extension for nexuzhealth\n---\n\nThis is an extension that can only be used for demo purposes.",
|
|
@@ -29,6 +29,13 @@ export declare const actions: {
|
|
|
29
29
|
description: string;
|
|
30
30
|
required: false;
|
|
31
31
|
};
|
|
32
|
+
rateLimitDuration: {
|
|
33
|
+
key: string;
|
|
34
|
+
label: string;
|
|
35
|
+
obfuscated: false;
|
|
36
|
+
description: string;
|
|
37
|
+
required: false;
|
|
38
|
+
};
|
|
32
39
|
}, "firstName" | "lastName" | "email" | "dob" | "phone" | "city" | "country" | "state" | "zip" | "addressLine1" | "addressLine2" | "genderAtBirth" | "driversLicenseValue" | "driversLicenseState">;
|
|
33
40
|
createPatient: import("@awell-health/extensions-core").Action<{
|
|
34
41
|
phone: {
|
|
@@ -115,7 +122,7 @@ export declare const actions: {
|
|
|
115
122
|
id: string;
|
|
116
123
|
label: string;
|
|
117
124
|
description: string;
|
|
118
|
-
type: import("@awell-health/extensions-core").FieldType.
|
|
125
|
+
type: import("@awell-health/extensions-core").FieldType.DATE;
|
|
119
126
|
required: true;
|
|
120
127
|
};
|
|
121
128
|
genderAtBirth: {
|
|
@@ -159,6 +166,13 @@ export declare const actions: {
|
|
|
159
166
|
description: string;
|
|
160
167
|
required: false;
|
|
161
168
|
};
|
|
169
|
+
rateLimitDuration: {
|
|
170
|
+
key: string;
|
|
171
|
+
label: string;
|
|
172
|
+
obfuscated: false;
|
|
173
|
+
description: string;
|
|
174
|
+
required: false;
|
|
175
|
+
};
|
|
162
176
|
}, "patientId">;
|
|
163
177
|
updatePatient: import("@awell-health/extensions-core").Action<{
|
|
164
178
|
phone: {
|
|
@@ -245,7 +259,7 @@ export declare const actions: {
|
|
|
245
259
|
id: string;
|
|
246
260
|
label: string;
|
|
247
261
|
description: string;
|
|
248
|
-
type: import("@awell-health/extensions-core").FieldType.
|
|
262
|
+
type: import("@awell-health/extensions-core").FieldType.DATE;
|
|
249
263
|
required: true;
|
|
250
264
|
};
|
|
251
265
|
genderAtBirth: {
|
|
@@ -296,6 +310,13 @@ export declare const actions: {
|
|
|
296
310
|
description: string;
|
|
297
311
|
required: false;
|
|
298
312
|
};
|
|
313
|
+
rateLimitDuration: {
|
|
314
|
+
key: string;
|
|
315
|
+
label: string;
|
|
316
|
+
obfuscated: false;
|
|
317
|
+
description: string;
|
|
318
|
+
required: false;
|
|
319
|
+
};
|
|
299
320
|
}, string>;
|
|
300
321
|
deletePatient: import("@awell-health/extensions-core").Action<{
|
|
301
322
|
facilityId: {
|
|
@@ -334,6 +355,13 @@ export declare const actions: {
|
|
|
334
355
|
description: string;
|
|
335
356
|
required: false;
|
|
336
357
|
};
|
|
358
|
+
rateLimitDuration: {
|
|
359
|
+
key: string;
|
|
360
|
+
label: string;
|
|
361
|
+
obfuscated: false;
|
|
362
|
+
description: string;
|
|
363
|
+
required: false;
|
|
364
|
+
};
|
|
337
365
|
}, string>;
|
|
338
366
|
listDocuments: import("@awell-health/extensions-core").Action<{
|
|
339
367
|
patientId: {
|
|
@@ -365,6 +393,13 @@ export declare const actions: {
|
|
|
365
393
|
description: string;
|
|
366
394
|
required: false;
|
|
367
395
|
};
|
|
396
|
+
rateLimitDuration: {
|
|
397
|
+
key: string;
|
|
398
|
+
label: string;
|
|
399
|
+
obfuscated: false;
|
|
400
|
+
description: string;
|
|
401
|
+
required: false;
|
|
402
|
+
};
|
|
368
403
|
}, "documents">;
|
|
369
404
|
queryDocs: import("@awell-health/extensions-core").Action<{
|
|
370
405
|
patientId: {
|
|
@@ -402,6 +437,13 @@ export declare const actions: {
|
|
|
402
437
|
description: string;
|
|
403
438
|
required: false;
|
|
404
439
|
};
|
|
440
|
+
rateLimitDuration: {
|
|
441
|
+
key: string;
|
|
442
|
+
label: string;
|
|
443
|
+
obfuscated: false;
|
|
444
|
+
description: string;
|
|
445
|
+
required: false;
|
|
446
|
+
};
|
|
405
447
|
}, "downloadStatus" | "downloadTotal" | "downloadSuccessful" | "requestId">;
|
|
406
448
|
getUrl: import("@awell-health/extensions-core").Action<{
|
|
407
449
|
fileName: {
|
|
@@ -433,6 +475,13 @@ export declare const actions: {
|
|
|
433
475
|
description: string;
|
|
434
476
|
required: false;
|
|
435
477
|
};
|
|
478
|
+
rateLimitDuration: {
|
|
479
|
+
key: string;
|
|
480
|
+
label: string;
|
|
481
|
+
obfuscated: false;
|
|
482
|
+
description: string;
|
|
483
|
+
required: false;
|
|
484
|
+
};
|
|
436
485
|
}, "url">;
|
|
437
486
|
startNetworkQuery: import("@awell-health/extensions-core").Action<{
|
|
438
487
|
patientId: {
|
|
@@ -464,6 +513,13 @@ export declare const actions: {
|
|
|
464
513
|
description: string;
|
|
465
514
|
required: false;
|
|
466
515
|
};
|
|
516
|
+
rateLimitDuration: {
|
|
517
|
+
key: string;
|
|
518
|
+
label: string;
|
|
519
|
+
obfuscated: false;
|
|
520
|
+
description: string;
|
|
521
|
+
required: false;
|
|
522
|
+
};
|
|
467
523
|
}, "status" | "requestId">;
|
|
468
524
|
startConsolidatedQuery: import("@awell-health/extensions-core").Action<{
|
|
469
525
|
patientId: {
|
|
@@ -519,6 +575,13 @@ export declare const actions: {
|
|
|
519
575
|
description: string;
|
|
520
576
|
required: false;
|
|
521
577
|
};
|
|
578
|
+
rateLimitDuration: {
|
|
579
|
+
key: string;
|
|
580
|
+
label: string;
|
|
581
|
+
obfuscated: false;
|
|
582
|
+
description: string;
|
|
583
|
+
required: false;
|
|
584
|
+
};
|
|
522
585
|
}, "status" | "requestId">;
|
|
523
586
|
getConsolidatedQueryStatus: import("@awell-health/extensions-core").Action<{
|
|
524
587
|
patientId: {
|
|
@@ -550,6 +613,13 @@ export declare const actions: {
|
|
|
550
613
|
description: string;
|
|
551
614
|
required: false;
|
|
552
615
|
};
|
|
616
|
+
rateLimitDuration: {
|
|
617
|
+
key: string;
|
|
618
|
+
label: string;
|
|
619
|
+
obfuscated: false;
|
|
620
|
+
description: string;
|
|
621
|
+
required: false;
|
|
622
|
+
};
|
|
553
623
|
}, "status" | "queries">;
|
|
554
624
|
getWebhookBundle: import("@awell-health/extensions-core").Action<{
|
|
555
625
|
url: {
|
|
@@ -601,6 +671,13 @@ export declare const actions: {
|
|
|
601
671
|
description: string;
|
|
602
672
|
required: false;
|
|
603
673
|
};
|
|
674
|
+
rateLimitDuration: {
|
|
675
|
+
key: string;
|
|
676
|
+
label: string;
|
|
677
|
+
obfuscated: false;
|
|
678
|
+
description: string;
|
|
679
|
+
required: false;
|
|
680
|
+
};
|
|
604
681
|
}, "bundle" | "transactionBundle">;
|
|
605
682
|
removePatientFromCohort: import("@awell-health/extensions-core").Action<{
|
|
606
683
|
cohortId: {
|
|
@@ -639,5 +716,12 @@ export declare const actions: {
|
|
|
639
716
|
description: string;
|
|
640
717
|
required: false;
|
|
641
718
|
};
|
|
719
|
+
rateLimitDuration: {
|
|
720
|
+
key: string;
|
|
721
|
+
label: string;
|
|
722
|
+
obfuscated: false;
|
|
723
|
+
description: string;
|
|
724
|
+
required: false;
|
|
725
|
+
};
|
|
642
726
|
}, "message" | "cohort">;
|
|
643
727
|
};
|
|
@@ -84,7 +84,7 @@ export declare const createFields: {
|
|
|
84
84
|
id: string;
|
|
85
85
|
label: string;
|
|
86
86
|
description: string;
|
|
87
|
-
type: FieldType.
|
|
87
|
+
type: FieldType.DATE;
|
|
88
88
|
required: true;
|
|
89
89
|
};
|
|
90
90
|
genderAtBirth: {
|
|
@@ -192,7 +192,7 @@ export declare const updateFields: {
|
|
|
192
192
|
id: string;
|
|
193
193
|
label: string;
|
|
194
194
|
description: string;
|
|
195
|
-
type: FieldType.
|
|
195
|
+
type: FieldType.DATE;
|
|
196
196
|
required: true;
|
|
197
197
|
};
|
|
198
198
|
genderAtBirth: {
|
|
@@ -28,8 +28,8 @@ exports.createFields = {
|
|
|
28
28
|
dob: {
|
|
29
29
|
id: 'dob',
|
|
30
30
|
label: 'Date of Birth',
|
|
31
|
-
description: `The Patient's date of birth (DOB)
|
|
32
|
-
type: extensions_core_1.FieldType.
|
|
31
|
+
description: `The Patient's date of birth (DOB)`,
|
|
32
|
+
type: extensions_core_1.FieldType.DATE,
|
|
33
33
|
required: true,
|
|
34
34
|
},
|
|
35
35
|
genderAtBirth: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../extensions/metriport/actions/patient/fields.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,gDAA6C;AAEhC,QAAA,YAAY,GAAG;IAC1B,UAAU,EAAE;QACV,EAAE,EAAE,YAAY;QAChB,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,iDAAiD;QAC9D,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,SAAS,EAAE;QACT,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,0BAA0B;QACvC,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,QAAQ,EAAE;QACR,EAAE,EAAE,UAAU;QACd,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,yBAAyB;QACtC,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,GAAG,EAAE;QACH,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../extensions/metriport/actions/patient/fields.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,gDAA6C;AAEhC,QAAA,YAAY,GAAG;IAC1B,UAAU,EAAE;QACV,EAAE,EAAE,YAAY;QAChB,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,iDAAiD;QAC9D,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,SAAS,EAAE;QACT,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,0BAA0B;QACvC,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,QAAQ,EAAE;QACR,EAAE,EAAE,UAAU;QACd,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,yBAAyB;QACtC,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,GAAG,EAAE;QACH,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,mCAAmC;QAChD,IAAI,EAAE,2BAAS,CAAC,IAAI;QACpB,QAAQ,EAAE,IAAI;KACf;IACD,aAAa,EAAE;QACb,EAAE,EAAE,eAAe;QACnB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,+FAA+F;QAC5G,IAAI,EAAE,2BAAS,CAAC,MAAM;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E,EAAE,YAAY;QAChB,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,iBAAiB;QAC9B,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;CACF,CAAA"}
|
|
@@ -3,7 +3,12 @@ export declare const genderAtBirthTransformSchema: z.ZodEffects<z.ZodEnum<["F",
|
|
|
3
3
|
export declare const patientCreateSchema: z.ZodObject<{
|
|
4
4
|
firstName: z.ZodString;
|
|
5
5
|
lastName: z.ZodString;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Metriport expects a date-only string (YYYY-MM-DD). `DateOnlySchema`
|
|
8
|
+
* normalises whatever the DATE field hands over — a plain `1940-08-29` or a
|
|
9
|
+
* full ISO timestamp — down to the date part.
|
|
10
|
+
*/
|
|
11
|
+
dob: z.ZodEffects<z.ZodDate, string, Date>;
|
|
7
12
|
genderAtBirth: z.ZodEffects<z.ZodEnum<["F", "M", "O", "U"]>, "M" | "F" | "O" | "U", unknown>;
|
|
8
13
|
addressLine1: z.ZodString;
|
|
9
14
|
addressLine2: z.ZodOptional<z.ZodString>;
|
|
@@ -87,7 +92,7 @@ export declare const patientCreateSchema: z.ZodObject<{
|
|
|
87
92
|
}, {
|
|
88
93
|
firstName: string;
|
|
89
94
|
lastName: string;
|
|
90
|
-
dob:
|
|
95
|
+
dob: Date;
|
|
91
96
|
city: string;
|
|
92
97
|
zip: string;
|
|
93
98
|
addressLine1: string;
|
|
@@ -107,7 +112,12 @@ export declare const patientUpdateSchema: z.ZodObject<{
|
|
|
107
112
|
} & {
|
|
108
113
|
firstName: z.ZodString;
|
|
109
114
|
lastName: z.ZodString;
|
|
110
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Metriport expects a date-only string (YYYY-MM-DD). `DateOnlySchema`
|
|
117
|
+
* normalises whatever the DATE field hands over — a plain `1940-08-29` or a
|
|
118
|
+
* full ISO timestamp — down to the date part.
|
|
119
|
+
*/
|
|
120
|
+
dob: z.ZodEffects<z.ZodDate, string, Date>;
|
|
111
121
|
genderAtBirth: z.ZodEffects<z.ZodEnum<["F", "M", "O", "U"]>, "M" | "F" | "O" | "U", unknown>;
|
|
112
122
|
addressLine1: z.ZodString;
|
|
113
123
|
addressLine2: z.ZodOptional<z.ZodString>;
|
|
@@ -192,7 +202,7 @@ export declare const patientUpdateSchema: z.ZodObject<{
|
|
|
192
202
|
}, {
|
|
193
203
|
firstName: string;
|
|
194
204
|
lastName: string;
|
|
195
|
-
dob:
|
|
205
|
+
dob: Date;
|
|
196
206
|
id: string;
|
|
197
207
|
city: string;
|
|
198
208
|
zip: string;
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.patientUpdateSchema = exports.patientCreateSchema = exports.genderAtBirthTransformSchema = void 0;
|
|
37
37
|
const z = __importStar(require("zod"));
|
|
38
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
|
38
39
|
const emailValidation_1 = require("../../../../src/utils/emailValidation");
|
|
39
40
|
const api_sdk_1 = require("@metriport/api-sdk");
|
|
40
41
|
/**
|
|
@@ -64,7 +65,12 @@ exports.genderAtBirthTransformSchema = z.preprocess((value) => {
|
|
|
64
65
|
exports.patientCreateSchema = z.object({
|
|
65
66
|
firstName: z.string().min(1),
|
|
66
67
|
lastName: z.string().min(1),
|
|
67
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Metriport expects a date-only string (YYYY-MM-DD). `DateOnlySchema`
|
|
70
|
+
* normalises whatever the DATE field hands over — a plain `1940-08-29` or a
|
|
71
|
+
* full ISO timestamp — down to the date part.
|
|
72
|
+
*/
|
|
73
|
+
dob: extensions_core_1.DateOnlySchema,
|
|
68
74
|
genderAtBirth: exports.genderAtBirthTransformSchema,
|
|
69
75
|
addressLine1: z.string().min(1),
|
|
70
76
|
addressLine2: z.string().optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../../extensions/metriport/actions/patient/validation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2EAA2E;AAC3E,gDAG2B;AAE3B;;;;;;GAMG;AACH,MAAM,oBAAoB,GAGtB;IACF,CAAC,EAAE,GAAG;IACN,IAAI,EAAE,GAAG;IACT,CAAC,EAAE,GAAG;IACN,MAAM,EAAE,GAAG;IACX,CAAC,EAAE,GAAG;IACN,KAAK,EAAE,GAAG;IACV,CAAC,EAAE,GAAG;IACN,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,GAAG;CACf,CAAA;AAEY,QAAA,4BAA4B,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE;;IACjE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAE3C,OAAO,MAAA,oBAAoB,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,mCAAI,KAAK,CAAA;AAClE,CAAC,EAAE,6BAAmB,CAAC,CAAA;AAEV,QAAA,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../../extensions/metriport/actions/patient/validation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,mEAA8D;AAC9D,2EAA2E;AAC3E,gDAG2B;AAE3B;;;;;;GAMG;AACH,MAAM,oBAAoB,GAGtB;IACF,CAAC,EAAE,GAAG;IACN,IAAI,EAAE,GAAG;IACT,CAAC,EAAE,GAAG;IACN,MAAM,EAA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AM,EAAE,CAAC,QAAQ,EAAE;IAC5B,KAAK,EAAE,qCAAmB;IAC1B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAA;AAIW,QAAA,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACtB,CAAC;KACD,KAAK,CAAC,2BAAmB,CAAC,CAAA"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { RateLimitConfig } from '@awell-health/extensions-core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const DEFAULT_DEDUPE_DURATION = "7 d";
|
|
1
4
|
export declare const settings: {
|
|
2
5
|
apiKey: {
|
|
3
6
|
key: string;
|
|
@@ -20,4 +23,13 @@ export declare const settings: {
|
|
|
20
23
|
description: string;
|
|
21
24
|
required: false;
|
|
22
25
|
};
|
|
26
|
+
rateLimitDuration: {
|
|
27
|
+
key: string;
|
|
28
|
+
label: string;
|
|
29
|
+
obfuscated: false;
|
|
30
|
+
description: string;
|
|
31
|
+
required: false;
|
|
32
|
+
};
|
|
23
33
|
};
|
|
34
|
+
export declare const rateLimitDurationSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
35
|
+
export declare const transformRateLimitDuration: (val: string) => RateLimitConfig["duration"];
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = void 0;
|
|
3
|
+
exports.transformRateLimitDuration = exports.rateLimitDurationSchema = exports.settings = exports.DEFAULT_DEDUPE_DURATION = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
exports.DEFAULT_DEDUPE_DURATION = '7 d';
|
|
4
7
|
exports.settings = {
|
|
5
8
|
apiKey: {
|
|
6
9
|
key: 'apiKey',
|
|
@@ -23,5 +26,62 @@ exports.settings = {
|
|
|
23
26
|
description: 'The Metriport webhook key used to verify incoming webhook requests. Metriport signs each request with an HMAC-SHA256 of the raw body using this key, sent in the `x-metriport-signature` header. Found in the Settings/Developers tab of the Metriport dashboard. When left empty, incoming webhook requests are not verified.',
|
|
24
27
|
required: false,
|
|
25
28
|
},
|
|
29
|
+
rateLimitDuration: {
|
|
30
|
+
key: 'rateLimitDuration',
|
|
31
|
+
label: 'Rate Limit Duration',
|
|
32
|
+
obfuscated: false,
|
|
33
|
+
description: "Rate limit Metriport enrollment webhooks at a certain duration (e.g. only enroll once for a given webhook message every '30 s', '1 m', '12 h', '30 d'). Prevents duplicate deliveries of the same message from re-enrolling a patient. Value should be {number} {unit}. Defaults to seven days as '7 d'",
|
|
34
|
+
required: false,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
exports.rateLimitDurationSchema = zod_1.z.string().refine((val) => {
|
|
38
|
+
if ((0, lodash_1.isNil)(val) || (0, lodash_1.isEmpty)(val)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const [number, unit] = val.split(' ');
|
|
43
|
+
const parsedUnit = parseDurationUnit(unit);
|
|
44
|
+
return (0, lodash_1.isFinite)(Number(number)) && !(0, lodash_1.isNil)(parsedUnit);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
message: 'Duration must be in format {number} {unit} where unit is seconds, minutes, hours or days',
|
|
51
|
+
});
|
|
52
|
+
const parseDurationUnit = (unit) => {
|
|
53
|
+
if ((0, lodash_1.isNil)(unit) || (0, lodash_1.isEmpty)(unit))
|
|
54
|
+
throw new Error('Duration unit is required');
|
|
55
|
+
const normalized = unit.toLowerCase().trim();
|
|
56
|
+
switch (normalized) {
|
|
57
|
+
case 's':
|
|
58
|
+
case 'second':
|
|
59
|
+
case 'seconds':
|
|
60
|
+
return 'seconds';
|
|
61
|
+
case 'm':
|
|
62
|
+
case 'min':
|
|
63
|
+
case 'minute':
|
|
64
|
+
case 'minutes':
|
|
65
|
+
return 'minutes';
|
|
66
|
+
case 'h':
|
|
67
|
+
case 'hour':
|
|
68
|
+
case 'hours':
|
|
69
|
+
return 'hours';
|
|
70
|
+
case 'd':
|
|
71
|
+
case 'day':
|
|
72
|
+
case 'days':
|
|
73
|
+
return 'days';
|
|
74
|
+
default:
|
|
75
|
+
throw new Error(`Invalid duration unit: ${unit}. Valid units are: s, m, h, d`);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const transformRateLimitDuration = (val) => {
|
|
79
|
+
const [number, unit] = val.split(' ');
|
|
80
|
+
const parsedUnit = parseDurationUnit(unit);
|
|
81
|
+
return {
|
|
82
|
+
value: Number(number),
|
|
83
|
+
unit: parsedUnit,
|
|
84
|
+
};
|
|
26
85
|
};
|
|
86
|
+
exports.transformRateLimitDuration = transformRateLimitDuration;
|
|
27
87
|
//# sourceMappingURL=settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../extensions/metriport/settings.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../extensions/metriport/settings.ts"],"names":[],"mappings":";;;AACA,mCAAiD;AACjD,6BAAuB;AAEV,QAAA,uBAAuB,GAAG,KAAK,CAAA;AAE/B,QAAA,QAAQ,GAAG;IACtB,MAAM,EAAE;QACN,GAAG,EAAE,QAAQ;QACb,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,4CAA4C;QACzD,QAAQ,EAAE,IAAI;KACf;IACD,OAAO,EAAE;QACP,GAAG,EAAE,SAAS;QACd,KAAK,EAAE,UAAU;QACjB,UAAU,EAAE,KAAK;QACjB,WAAW,EAAE,4CAA4C;QACzD,QAAQ,EAAE,KAAK;KAChB;IACD,UAAU,EAAE;QACV,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ACT,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACZ,OAAO,SAAS,CAAA;QAElB,KAAK,GAAG,CAAC;QACT,KAAK,KAAK,CAAC;QACX,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACZ,OAAO,SAAS,CAAA;QAElB,KAAK,GAAG,CAAC;QACT,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO;YACV,OAAO,OAAO,CAAA;QAEhB,KAAK,GAAG,CAAC;QACT,KAAK,KAAK,CAAC;QACX,KAAK,MAAM;YACT,OAAO,MAAM,CAAA;QAEf;YACE,MAAM,IAAI,KAAK,CACb,0BAA0B,IAAI,+BAA+B,CAC9D,CAAA;IACL,CAAC;AACH,CAAC,CAAA;AAEM,MAAM,0BAA0B,GAAG,CACxC,GAAW,EACkB,EAAE;IAC/B,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACrC,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAC1C,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,IAAI,EAAE,UAAU;KACjB,CAAA;AACH,CAAC,CAAA;AATY,QAAA,0BAA0B,8BAStC"}
|
|
@@ -2,10 +2,13 @@ import { z } from 'zod';
|
|
|
2
2
|
export declare const settingsSchema: z.ZodObject<{
|
|
3
3
|
baseUrl: z.ZodOptional<z.ZodString>;
|
|
4
4
|
apiKey: z.ZodString;
|
|
5
|
+
rateLimitDuration: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>>;
|
|
5
6
|
}, "strip", z.ZodTypeAny, {
|
|
6
7
|
apiKey: string;
|
|
8
|
+
rateLimitDuration: string;
|
|
7
9
|
baseUrl?: string | undefined;
|
|
8
10
|
}, {
|
|
9
11
|
apiKey: string;
|
|
10
12
|
baseUrl?: string | undefined;
|
|
13
|
+
rateLimitDuration?: string | undefined;
|
|
11
14
|
}>;
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.settingsSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const settings_1 = require("../settings");
|
|
5
6
|
exports.settingsSchema = zod_1.z.object({
|
|
6
7
|
baseUrl: zod_1.z
|
|
7
8
|
.string({ errorMap: () => ({ message: 'Missing baseUrl' }) })
|
|
8
9
|
.optional(),
|
|
9
10
|
apiKey: zod_1.z.string({ errorMap: () => ({ message: 'Missing apiKey' }) }).min(1),
|
|
11
|
+
rateLimitDuration: settings_1.rateLimitDurationSchema.optional().default(settings_1.DEFAULT_DEDUPE_DURATION),
|
|
10
12
|
});
|
|
11
13
|
//# sourceMappingURL=settings.zod.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.zod.js","sourceRoot":"","sources":["../../../../extensions/metriport/validation/settings.zod.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;
|
|
1
|
+
{"version":3,"file":"settings.zod.js","sourceRoot":"","sources":["../../../../extensions/metriport/validation/settings.zod.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,0CAA8E;AAEjE,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,OAAO,EAAE,OAAC;SACP,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,EAAE,CAAC;SAC5D,QAAQ,EAAE;IACb,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5E,iBAAiB,EAAE,kCAAuB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,kCAAuB,CAAC;CACvF,CAAC,CAAA"}
|
|
@@ -4,6 +4,7 @@ exports.enrollment = exports.METRIPORT_PATIENT_IDENTIFIER_SYSTEM = void 0;
|
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const zod_validation_error_1 = require("zod-validation-error");
|
|
7
|
+
const settings_1 = require("../settings");
|
|
7
8
|
const verifyWebhookSignature_1 = require("../shared/verifyWebhookSignature");
|
|
8
9
|
const types_1 = require("./types");
|
|
9
10
|
const validation_zod_1 = require("./validation.zod");
|
|
@@ -48,8 +49,8 @@ exports.enrollment = {
|
|
|
48
49
|
key: 'enrollment',
|
|
49
50
|
description: 'Enrolls a patient when Metriport sends a real-time notification. The `eventType` data point carries the Metriport webhook type (`patient.admit` or `medical.discharge-summary`) so it can be distinguished on. The FHIR bundle is not fetched here — the pre-signed URL is passed on the `bundleUrl` data point and can be retrieved later with the "Get Webhook Bundle" action.',
|
|
50
51
|
dataPoints,
|
|
51
|
-
onEvent: async ({ payload: { payload, rawBody, headers, settings }, onSuccess, onError, }) => {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
52
|
+
onEvent: async ({ payload: { payload, rawBody, headers, settings, endpoint }, onSuccess, onError, helpers: { rateLimiter }, }) => {
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
53
54
|
try {
|
|
54
55
|
// Verify the Metriport webhook signature (HMAC-SHA256 over the raw body)
|
|
55
56
|
// when a webhook key is configured. See `verifyWebhookSignature.ts`.
|
|
@@ -138,6 +139,33 @@ exports.enrollment = {
|
|
|
138
139
|
});
|
|
139
140
|
return;
|
|
140
141
|
}
|
|
142
|
+
// rate limiting
|
|
143
|
+
//
|
|
144
|
+
// Keyed on the guaranteed-unique `meta.messageId`. Metriport reuses the
|
|
145
|
+
// same messageId on retries, so this acts as an idempotency/dedup guard:
|
|
146
|
+
// a duplicate delivery of the same message within the configured window is
|
|
147
|
+
// acknowledged with 200 OK (so Metriport stops retrying) but does not
|
|
148
|
+
// re-enroll the patient. Distinct messages always pass.
|
|
149
|
+
const { success, data: durationString } = settings_1.rateLimitDurationSchema.safeParse(settings.rateLimitDuration);
|
|
150
|
+
if (success && !(0, lodash_1.isNil)(durationString)) {
|
|
151
|
+
const duration = (0, settings_1.transformRateLimitDuration)(durationString);
|
|
152
|
+
const limiterName = `metriport-enrollment-${webhook.meta.type}-${(_p = endpoint === null || endpoint === void 0 ? void 0 : endpoint.id) !== null && _p !== void 0 ? _p : 'global'}`;
|
|
153
|
+
const limiter = rateLimiter(limiterName, {
|
|
154
|
+
requests: 1,
|
|
155
|
+
duration,
|
|
156
|
+
});
|
|
157
|
+
const key = webhook.meta.messageId;
|
|
158
|
+
const { success } = await limiter.limit(key);
|
|
159
|
+
if (!success) {
|
|
160
|
+
await onError({
|
|
161
|
+
response: {
|
|
162
|
+
statusCode: 200,
|
|
163
|
+
message: `Rate limit exceeded on limiter ${limiterName} for messageId ${key}. 200 OK response sent to Metriport to prevent re-enrolling patient ${patientId} for a duplicate delivery of this message on endpoint ${(_q = endpoint === null || endpoint === void 0 ? void 0 : endpoint.url) !== null && _q !== void 0 ? _q : 'global'}.`,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
141
169
|
await onSuccess({
|
|
142
170
|
data_points,
|
|
143
171
|
patient_identifier: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enrollment.js","sourceRoot":"","sources":["../../../../extensions/metriport/webhooks/enrollment.ts"],"names":[],"mappings":";;;AAAA,mCAA8B;AAC9B,6BAA8B;AAC9B,+DAAmD;
|
|
1
|
+
{"version":3,"file":"enrollment.js","sourceRoot":"","sources":["../../../../extensions/metriport/webhooks/enrollment.ts"],"names":[],"mappings":";;;AAAA,mCAA8B;AAC9B,6BAA8B;AAC9B,+DAAmD;AAKnD,0CAIoB;AACpB,6EAA6E;AAC7E,mCAGgB;AAChB,q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AE,SAAS;iBACjB;aACF,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GACX,KAAK,YAAY,cAAQ;gBACvB,CAAC,CAAC,IAAA,mCAAY,EAAC,KAAK,CAAC,CAAC,OAAO;gBAC7B,CAAC,CAAE,KAAe,CAAC,OAAO,CAAA;YAC9B,MAAM,OAAO,CAAC;gBACZ,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;wBAC9B,IAAI,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE;wBACrB,KAAK,EAAE;4BACL,QAAQ,EACN,KAAK,YAAY,cAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc;4BAC5D,OAAO;yBACR;qBACF;iBACF;aACF,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF,CAAA"}
|
|
@@ -21,4 +21,11 @@ export declare const webhooks: import("@awell-health/extensions-core").Webhook<"
|
|
|
21
21
|
description: string;
|
|
22
22
|
required: false;
|
|
23
23
|
};
|
|
24
|
+
rateLimitDuration: {
|
|
25
|
+
key: string;
|
|
26
|
+
label: string;
|
|
27
|
+
obfuscated: false;
|
|
28
|
+
description: string;
|
|
29
|
+
required: false;
|
|
30
|
+
};
|
|
24
31
|
}>[];
|