@metriport/api-sdk 9.0.1 → 9.0.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 (25) hide show
  1. package/dist/api-sdk/src/index.d.ts +26 -0
  2. package/dist/api-sdk/src/index.d.ts.map +1 -0
  3. package/dist/api-sdk/src/index.js +64 -0
  4. package/dist/api-sdk/src/index.js.map +1 -0
  5. package/dist/api-sdk/src/medical/client/metriport.d.ts +350 -0
  6. package/dist/api-sdk/src/medical/client/metriport.d.ts.map +1 -0
  7. package/dist/api-sdk/src/medical/client/metriport.js +596 -0
  8. package/dist/api-sdk/src/medical/client/metriport.js.map +1 -0
  9. package/dist/api-sdk/src/medical/models/patientDTO.d.ts +52 -0
  10. package/dist/api-sdk/src/medical/models/patientDTO.d.ts.map +1 -0
  11. package/dist/api-sdk/src/medical/models/patientDTO.js +3 -0
  12. package/dist/api-sdk/src/medical/models/patientDTO.js.map +1 -0
  13. package/dist/medical/models/webhook-status-response.d.ts +7 -0
  14. package/dist/medical/models/webhook-status-response.d.ts.map +1 -0
  15. package/dist/medical/models/webhook-status-response.js +3 -0
  16. package/dist/medical/models/webhook-status-response.js.map +1 -0
  17. package/dist/shared/src/medical/webhook/webhook-request.d.ts +376 -0
  18. package/dist/shared/src/medical/webhook/webhook-request.d.ts.map +1 -0
  19. package/dist/shared/src/medical/webhook/webhook-request.js +109 -0
  20. package/dist/shared/src/medical/webhook/webhook-request.js.map +1 -0
  21. package/dist/shared/src/medical/webhook/webhook-status-response.d.ts +7 -0
  22. package/dist/shared/src/medical/webhook/webhook-status-response.d.ts.map +1 -0
  23. package/dist/shared/src/medical/webhook/webhook-status-response.js +3 -0
  24. package/dist/shared/src/medical/webhook/webhook-status-response.js.map +1 -0
  25. package/package.json +5 -5
@@ -0,0 +1,596 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MetriportMedicalApi = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const crypto_1 = __importDefault(require("crypto"));
9
+ const http_status_1 = __importDefault(require("http-status"));
10
+ const shared_1 = require("../../shared");
11
+ const base_update_1 = require("../models/common/base-update");
12
+ const document_1 = require("../models/document");
13
+ const facility_1 = require("../models/facility");
14
+ const organization_1 = require("../models/organization");
15
+ const webhook_request_1 = require("@metriport/shared/src/medical/webhook/webhook-request");
16
+ const NO_DATA_MESSAGE = "No data returned from API";
17
+ const BASE_PATH = "/medical/v1";
18
+ const ORGANIZATION_URL = `/organization`;
19
+ const FACILITY_URL = `/facility`;
20
+ const PATIENT_URL = `/patient`;
21
+ const DOCUMENT_URL = `/document`;
22
+ class MetriportMedicalApi {
23
+ // TODO this should be private
24
+ api;
25
+ optionsForSettingsEndpoints = {
26
+ baseURL: "/",
27
+ };
28
+ static headers = {
29
+ clientApp: "x-metriport-client",
30
+ };
31
+ /**
32
+ * Creates a new instance of the Metriport Medical API client.
33
+ *
34
+ * @param apiKey Your Metriport API key.
35
+ * @param options - Optional parameters
36
+ * @param options.additionalHeaders - HTTP headers to be used in all requests.
37
+ * @param options.axios - Axios instance, default, useful when the dependency is not being imported
38
+ * properly by NPM.
39
+ * @param options.sandbox - Indicates whether to connect to the sandbox, default false.
40
+ * @param options.timeout - Connection timeout in milliseconds, default 20 seconds.
41
+ */
42
+ constructor(apiKey, options = {}) {
43
+ const headers = { [shared_1.API_KEY_HEADER]: apiKey, ...options.additionalHeaders };
44
+ const { sandbox, timeout } = options;
45
+ const baseHostAndProtocol = options.baseAddress ?? (sandbox ? shared_1.BASE_ADDRESS_SANDBOX : shared_1.BASE_ADDRESS);
46
+ const baseURL = baseHostAndProtocol + BASE_PATH;
47
+ const axiosConfig = {
48
+ timeout: timeout ?? shared_1.DEFAULT_AXIOS_TIMEOUT_MILLIS,
49
+ baseURL,
50
+ headers,
51
+ };
52
+ this.optionsForSettingsEndpoints.baseURL = baseHostAndProtocol;
53
+ if (axios_1.default) {
54
+ this.api = axios_1.default.create(axiosConfig);
55
+ }
56
+ else if (options.axios) {
57
+ this.api = options.axios.create(axiosConfig);
58
+ }
59
+ else {
60
+ throw new Error(`Failed to initialize Axios`);
61
+ }
62
+ }
63
+ /**
64
+ * Gets the settings for your account.
65
+ *
66
+ * @returns Your account settings.
67
+ */
68
+ async getSettings() {
69
+ const resp = await this.api.get("/settings", {
70
+ ...this.optionsForSettingsEndpoints,
71
+ });
72
+ return resp.data;
73
+ }
74
+ /**
75
+ * Update the settings for your account.
76
+ *
77
+ * @returns Your updated account settings.
78
+ */
79
+ async updateSettings(webhookUrl) {
80
+ const resp = await this.api.post("/settings", { webhookUrl }, { ...this.optionsForSettingsEndpoints });
81
+ return resp.data;
82
+ }
83
+ /**
84
+ * Gets the status of communication with your app's webhook.
85
+ *
86
+ * @returns The status of communication with your app's webhook.
87
+ */
88
+ async getWebhookStatus() {
89
+ const resp = await this.api.get("/settings/webhook", {
90
+ ...this.optionsForSettingsEndpoints,
91
+ });
92
+ return resp.data;
93
+ }
94
+ /**
95
+ * Retries failed webhook requests.
96
+ *
97
+ * @returns void
98
+ */
99
+ async retryWebhookRequests() {
100
+ await this.api.post("/settings/webhook/retry", {
101
+ ...this.optionsForSettingsEndpoints,
102
+ });
103
+ }
104
+ /**
105
+ * Creates a new organization if one does not already exist.
106
+ *
107
+ * @param data The data to be used to create a new organization.
108
+ * @throws Error (400) if an organization already exists for the customer.
109
+ * @returns The created organization.
110
+ */
111
+ async createOrganization(data) {
112
+ const resp = await this.api.post(ORGANIZATION_URL, data);
113
+ if (!resp.data)
114
+ throw new Error(NO_DATA_MESSAGE);
115
+ return organization_1.organizationSchema.parse(resp.data);
116
+ }
117
+ /**
118
+ * Updates an organization.
119
+ *
120
+ * @param organization The organization data to be updated.
121
+ * @return The updated organization.
122
+ */
123
+ async updateOrganization(organization) {
124
+ const payload = {
125
+ ...organization,
126
+ id: undefined,
127
+ };
128
+ const resp = await this.api.put(`${ORGANIZATION_URL}/${organization.id}`, payload, {
129
+ headers: { ...(0, base_update_1.getETagHeader)(organization) },
130
+ });
131
+ if (!resp.data)
132
+ throw new Error(NO_DATA_MESSAGE);
133
+ return organization_1.organizationSchema.parse(resp.data);
134
+ }
135
+ /**
136
+ * Retrieve an organization representing this account.
137
+ *
138
+ * @returns The organization, or undefined if no organization has been created.
139
+ */
140
+ async getOrganization() {
141
+ const resp = await this.api.get(ORGANIZATION_URL);
142
+ if (!resp.data)
143
+ return undefined;
144
+ return organization_1.organizationSchema.parse(resp.data);
145
+ }
146
+ /**
147
+ * Creates a new facility.
148
+ *
149
+ * @param data The data to be used to create a new facility.
150
+ * @return The newly created facility.
151
+ */
152
+ async createFacility(data) {
153
+ const resp = await this.api.post(`${FACILITY_URL}`, data);
154
+ if (!resp.data)
155
+ throw new Error(NO_DATA_MESSAGE);
156
+ return facility_1.facilitySchema.parse(resp.data);
157
+ }
158
+ /**
159
+ * Returns a facility.
160
+ *
161
+ * @param id The ID of the facility to be returned.
162
+ * @return The facilities.
163
+ */
164
+ async getFacility(id) {
165
+ const resp = await this.api.get(`${FACILITY_URL}/${id}`);
166
+ if (!resp.data)
167
+ throw new Error(NO_DATA_MESSAGE);
168
+ return facility_1.facilitySchema.parse(resp.data);
169
+ }
170
+ /**
171
+ * Updates a facility.
172
+ *
173
+ * @param facility The facility data to be updated.
174
+ * @return The updated facility.
175
+ */
176
+ async updateFacility(facility) {
177
+ const payload = {
178
+ ...facility,
179
+ id: undefined,
180
+ };
181
+ const resp = await this.api.put(`${FACILITY_URL}/${facility.id}`, payload, {
182
+ headers: { ...(0, base_update_1.getETagHeader)(facility) },
183
+ });
184
+ if (!resp.data)
185
+ throw new Error(NO_DATA_MESSAGE);
186
+ return facility_1.facilitySchema.parse(resp.data);
187
+ }
188
+ /**
189
+ * Returns the facilities associated with this account.
190
+ *
191
+ * @return The list of facilities.
192
+ */
193
+ async listFacilities() {
194
+ const resp = await this.api.get(`${FACILITY_URL}`);
195
+ if (!resp.data)
196
+ return [];
197
+ return facility_1.facilityListSchema.parse(resp.data).facilities;
198
+ }
199
+ /**
200
+ * Deletes a facility. It will fail if the facility has patients associated with it.
201
+ *
202
+ * @param facilityId The ID of facility to be deleted.
203
+ */
204
+ async deleteFacility(facilityId, eTag) {
205
+ await this.api.delete(`${FACILITY_URL}/${facilityId}`, {
206
+ headers: { ...(0, base_update_1.getETagHeader)({ eTag }) },
207
+ });
208
+ }
209
+ /**
210
+ * Creates a new patient at Metriport and HIEs.
211
+ *
212
+ * @param data The data to be used to create a new patient.
213
+ * @param facilityId The facility providing the NPI to support this operation.
214
+ * @return The newly created patient.
215
+ */
216
+ async createPatient(data, facilityId) {
217
+ const resp = await this.api.post(`${PATIENT_URL}`, data, {
218
+ params: { facilityId },
219
+ });
220
+ if (!resp.data)
221
+ throw new Error(NO_DATA_MESSAGE);
222
+ return resp.data;
223
+ }
224
+ /**
225
+ * Returns a patient.
226
+ *
227
+ * @param id The ID of the patient to be returned.
228
+ * @return The patient.
229
+ */
230
+ async getPatient(id) {
231
+ const resp = await this.api.get(`${PATIENT_URL}/${id}`);
232
+ if (!resp.data)
233
+ throw new Error(NO_DATA_MESSAGE);
234
+ return resp.data;
235
+ }
236
+ /**
237
+ * Searches for a patient previously created at Metriport, based on demographics.
238
+ *
239
+ * @return The patient if found.
240
+ */
241
+ async matchPatient(data) {
242
+ try {
243
+ const resp = await this.api.post(`${PATIENT_URL}/match`, data);
244
+ if (!resp.data)
245
+ throw new Error(NO_DATA_MESSAGE);
246
+ return resp.data;
247
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
248
+ }
249
+ catch (err) {
250
+ if (err.response?.status !== http_status_1.default.NOT_FOUND)
251
+ throw err;
252
+ return undefined;
253
+ }
254
+ }
255
+ /**
256
+ * Updates a patient at Metriport and at HIEs the patient is linked to.
257
+ *
258
+ * @param patient The patient data to be updated.
259
+ * @param facilityId Optional. The facility providing the NPI to support this operation. If not provided and the patient has only one facility, that one will be used. If not provided and the patient has multiple facilities, an error will be thrown.
260
+ * @return The updated patient.
261
+ */
262
+ async updatePatient(patient, facilityId) {
263
+ const payload = {
264
+ ...patient,
265
+ id: undefined,
266
+ };
267
+ const resp = await this.api.put(`${PATIENT_URL}/${patient.id}`, payload, {
268
+ params: { facilityId },
269
+ headers: { ...(0, base_update_1.getETagHeader)(patient) },
270
+ });
271
+ if (!resp.data)
272
+ throw new Error(NO_DATA_MESSAGE);
273
+ return resp.data;
274
+ }
275
+ // TODO #870 remove this
276
+ /** ---------------------------------------------------------------------------
277
+ * Returns a patient's consolidated data.
278
+ * @deprecated Use startConsolidatedQuery() and getConsolidatedQueryStatus() instead.
279
+ *
280
+ * Note if only patientId is provided the endpoint may take long to respond as its
281
+ * fetching all the resources for the patient.
282
+ *
283
+ * @param patientId The ID of the patient whose data is to be returned.
284
+ * @param resources Optional array of resources to be returned.
285
+ * @param dateFrom Optional start date that resources will be filtered by (inclusive). Format is YYYY-MM-DD.
286
+ * @param dateTo Optional end date that resources will be filtered by (inclusive). Format is YYYY-MM-DD.
287
+ * @return Patient's consolidated data.
288
+ */
289
+ async getPatientConsolidated(patientId, resources, dateFrom, dateTo) {
290
+ const resp = await this.api.get(`${PATIENT_URL}/${patientId}/consolidated`, {
291
+ params: { resources: resources && resources.join(","), dateFrom, dateTo },
292
+ });
293
+ return resp.data;
294
+ }
295
+ /** ---------------------------------------------------------------------------
296
+ * Start a query for the patient's consolidated data (FHIR resources).
297
+ * The results are sent through Webhook (see https://docs.metriport.com/medical-api/more-info/webhooks).
298
+ * Only one query per given patient can be executed at a time.
299
+ *
300
+ * @param patientId The ID of the patient whose data is to be returned.
301
+ * @param resources Optional array of resources to be returned (defaults to all resource types).
302
+ * @param dateFrom Optional start date that resources will be filtered by (inclusive). Format is YYYY-MM-DD.
303
+ * @param dateTo Optional end date that resources will be filtered by (inclusive). Format is YYYY-MM-DD.
304
+ * @param conversionType Optional to indicate how the medical record should be rendered - one of:
305
+ * "pdf", "html", or "json" (defaults to "json"). If "html" or "pdf", the Webhook payload
306
+ * will contain a signed URL to download the file, which is active for 3 minutes.
307
+ * If not provided, will send json payload in the webhook.
308
+ * @param metadata Optional metadata to be sent along the webhook request as response of this query.
309
+ * @return The consolidated data query status.
310
+ */
311
+ async startConsolidatedQuery(patientId, resources, dateFrom, dateTo, conversionType, metadata) {
312
+ const whMetadata = { metadata: metadata };
313
+ const resp = await this.api.post(`${PATIENT_URL}/${patientId}/consolidated/query`, whMetadata, {
314
+ params: { resources: resources && resources.join(","), dateFrom, dateTo, conversionType },
315
+ });
316
+ return resp.data;
317
+ }
318
+ /** ---------------------------------------------------------------------------
319
+ * Get the consolidated data query status for a given patient.
320
+ * The results to the query are sent through Webhook (see
321
+ * startConsolidatedQuery() and https://docs.metriport.com/medical-api/more-info/webhooks).
322
+ *
323
+ * @param patientId The ID of the patient whose data is to be returned.
324
+ * @return The consolidated data query status.
325
+ */
326
+ async getConsolidatedQueryStatus(patientId) {
327
+ const resp = await this.api.get(`${PATIENT_URL}/${patientId}/consolidated/query`);
328
+ return resp.data;
329
+ }
330
+ /** ---------------------------------------------------------------------------
331
+ * Add patient data as FHIR resources. Those can later be queried with startConsolidatedQuery(),
332
+ * and will be made available to HIEs.
333
+ *
334
+ * Note: each call to this function is limited to 50 resources and 1Mb of data. You can make multiple
335
+ * calls to this function to add more data.
336
+ *
337
+ * @param patientId The ID of the patient to associate resources to.
338
+ * @param payload The FHIR Bundle to create resources.
339
+ * @return FHIR Bundle with operation outcome.
340
+ */
341
+ async createPatientConsolidated(patientId, payload) {
342
+ const resp = await this.api.put(`${PATIENT_URL}/${patientId}/consolidated`, payload);
343
+ return resp.data;
344
+ }
345
+ /** ---------------------------------------------------------------------------
346
+ * Returns the amount of resources available for a given patient, per resource type.
347
+ *
348
+ * @param patientId The ID of the patient whose data is to be returned.
349
+ * @param resources Optional array of resources to be considered.
350
+ * @param dateFrom Optional start date that resources will be filtered by (inclusive). Format is YYYY-MM-DD.
351
+ * @param dateTo Optional end date that resources will be filtered by (inclusive). Format is YYYY-MM-DD.
352
+ * @return the amount of resources available per resource type for the given Patient.
353
+ */
354
+ async countPatientConsolidated(patientId, resources, dateFrom, dateTo) {
355
+ const resp = await this.api.get(`${PATIENT_URL}/${patientId}/consolidated/count`, {
356
+ params: { resources: resources && resources.join(","), dateFrom, dateTo },
357
+ });
358
+ return resp.data;
359
+ }
360
+ /**
361
+ * Removes a patient at Metriport and at HIEs the patient is linked to.
362
+ *
363
+ * @param patientId The ID of the patient to be deleted.
364
+ * @param facilityId The facility providing the NPI to support this operation.
365
+ */
366
+ async deletePatient(patientId, facilityId, eTag) {
367
+ await this.api.delete(`${PATIENT_URL}/${patientId}`, {
368
+ params: { facilityId },
369
+ headers: { ...(0, base_update_1.getETagHeader)({ eTag }) },
370
+ });
371
+ }
372
+ /**
373
+ * Returns the patients associated with given facility.
374
+ *
375
+ * @param facilityId The ID of the facility.
376
+ * @return The list of patients.
377
+ */
378
+ async listPatients(facilityId) {
379
+ const resp = await this.api.get(`${PATIENT_URL}`, {
380
+ params: { facilityId },
381
+ });
382
+ if (!resp.data)
383
+ return [];
384
+ return resp.data.patients;
385
+ }
386
+ /**
387
+ * Returns document references for the given patient across HIEs.
388
+ *
389
+ * @param patientId Patient ID for which to retrieve document metadata.
390
+ * @param filters.dateFrom Optional start date that docs will be filtered by (inclusive).
391
+ * If the type is Date, its assumed UTC. If the type is string, its assumed to be ISO 8601 (Date only).
392
+ * @param filters.dateTo Optional end date that docs will be filtered by (inclusive).
393
+ * If the type is Date, its assumed UTC. If the type is string, its assumed to be ISO 8601 (Date only).
394
+ * @param filters.content Optional value to search on the document reference
395
+ * (partial match and case insentitive, minimum 3 chars).
396
+ * @return The list of document references.
397
+ */
398
+ async listDocuments(patientId, { dateFrom, dateTo, content } = {}) {
399
+ const parsedDateFrom = (0, shared_1.optionalDateToISOString)(dateFrom);
400
+ const parsedDateTo = (0, shared_1.optionalDateToISOString)(dateTo);
401
+ const resp = await this.api.get(`${DOCUMENT_URL}`, {
402
+ params: {
403
+ patientId,
404
+ dateFrom: parsedDateFrom,
405
+ dateTo: parsedDateTo,
406
+ content,
407
+ },
408
+ });
409
+ if (!resp.data)
410
+ return { documents: [] };
411
+ return resp.data;
412
+ }
413
+ /**
414
+ * @deprecated Use listDocuments() instead.
415
+ *
416
+ * Returns document references for the given patient across HIEs, in the DTO format.
417
+ *
418
+ * @param patientId Patient ID for which to retrieve document metadata.
419
+ * @param filters.dateFrom Optional start date that docs will be filtered by (inclusive).
420
+ * If the type is Date, its assumed UTC. If the type is string, its assumed to be ISO 8601 (Date only).
421
+ * @param filters.dateTo Optional end date that docs will be filtered by (inclusive).
422
+ * If the type is Date, its assumed UTC. If the type is string, its assumed to be ISO 8601 (Date only).
423
+ * @param filters.content Optional value to search on the document reference
424
+ * (partial match and case insentitive, minimum 3 chars).
425
+ * @return The list of document references.
426
+ */
427
+ async listDocumentsAsDTO(patientId, { dateFrom, dateTo, content } = {}) {
428
+ const parsedDateFrom = (0, shared_1.optionalDateToISOString)(dateFrom);
429
+ const parsedDateTo = (0, shared_1.optionalDateToISOString)(dateTo);
430
+ const resp = await this.api.get(`${DOCUMENT_URL}`, {
431
+ params: {
432
+ patientId,
433
+ dateFrom: parsedDateFrom,
434
+ dateTo: parsedDateTo,
435
+ content,
436
+ output: "dto",
437
+ },
438
+ });
439
+ if (!resp.data)
440
+ return [];
441
+ return document_1.documentListSchema.parse(resp.data).documents;
442
+ }
443
+ /**
444
+ * Start a document query for the given patient across HIEs.
445
+ *
446
+ * @param patientId Patient ID for which to retrieve document metadata.
447
+ * @param facilityId The facility providing the NPI to support this operation (optional).
448
+ * If not provided and the patient has only one facility, that one will be used.
449
+ * If not provided and the patient has multiple facilities, an error will be thrown.
450
+ * @param metadata Optional metadata to be sent along the webhook request as response of this query.
451
+ * @return The document query request ID, progress & status indicating whether its being executed or not.
452
+ */
453
+ async startDocumentQuery(patientId, facilityId, metadata) {
454
+ const whMetadata = { metadata: metadata };
455
+ const resp = await this.api.post(`${DOCUMENT_URL}/query`, whMetadata, {
456
+ params: {
457
+ patientId,
458
+ facilityId,
459
+ },
460
+ });
461
+ if (!resp.data)
462
+ throw new Error(NO_DATA_MESSAGE);
463
+ return document_1.documentQuerySchema.parse(resp.data);
464
+ }
465
+ /**
466
+ * Start a bulk document download for a given patient, with the payload returned to the webhook.
467
+ *
468
+ * @param patientId Patient ID for which to retrieve document URLs.
469
+ * @param metadata Optional metadata to be sent along the webhook request as response of this query.
470
+ * @return The document query request ID, progress, and status indicating whether it's being executed or not.
471
+ */
472
+ async startBulkGetDocumentUrl(patientId, metadata) {
473
+ const whMetadata = { metadata: metadata };
474
+ const resp = await this.api.post(`${DOCUMENT_URL}/download-url/bulk`, whMetadata, {
475
+ params: {
476
+ patientId,
477
+ },
478
+ });
479
+ if (!resp.data)
480
+ throw new Error(NO_DATA_MESSAGE);
481
+ return document_1.bulkGetDocumentUrlQuerySchema.parse(resp.data);
482
+ }
483
+ /**
484
+ * Returns the document query status for the specified patient.
485
+ *
486
+ * @param patientId Patient ID for which to retrieve document query status.
487
+ * @return The document query request ID, progress & status indicating whether its being executed or not.
488
+ */
489
+ async getDocumentQueryStatus(patientId) {
490
+ const resp = await this.api.get(`${DOCUMENT_URL}/query`, {
491
+ params: { patientId },
492
+ });
493
+ if (!resp.data)
494
+ throw new Error(NO_DATA_MESSAGE);
495
+ return document_1.documentQuerySchema.parse(resp.data);
496
+ }
497
+ /**
498
+ * Returns a URL that can be used to download the document.
499
+ *
500
+ * @param req.query.fileName The file name of the document in s3.
501
+ * @param req.query.conversionType The doc type to convert to. Valid values are "html" and "pdf".
502
+ * @return presigned url
503
+ */
504
+ //eslint-disable-next-line @typescript-eslint/no-explicit-any
505
+ async getDocumentUrl(fileName, conversionType) {
506
+ const resp = await this.api.get(`${DOCUMENT_URL}/download-url`, {
507
+ params: {
508
+ fileName,
509
+ conversionType,
510
+ },
511
+ });
512
+ return resp.data;
513
+ }
514
+ /**
515
+ * @deprecated - Use createDocumentReference() instead.
516
+ * Returns a URL to upload a file to Metriport and make the document available to other HIEs.
517
+ * To upload your file contents, execute a PUT request using this URL with the file contents as the request body.
518
+ * Refer to Metriport documentation for more details:
519
+ * https://docs.metriport.com/medical-api/api-reference/document/post-upload-url
520
+ *
521
+ * @param patientId - the ID of the patient.
522
+ * @param docRef - a FHIR Document Reference for this file upload. Mandatory fields include DocumentReference.description, DocumentReference.type, and DocumentReference.context. Besides that, try to include as much metadata on the document as possible. Note that you DO NOT need to fill in the Organization or Patient fields under the author or contained fields - Metriport will fill this in and overwrite whatever you put in.
523
+ * Refer to Metriport's documentation for more details: https://docs.metriport.com/medical-api/fhir/resources/documentreference.
524
+ *
525
+ * @returns A URL string to be used for subsequent file upload.
526
+ */
527
+ async getDocumentUploadUrl(patientId, docRef) {
528
+ const url = `${DOCUMENT_URL}/upload-url/?patientId=${patientId}`;
529
+ const resp = await this.api.post(url, docRef);
530
+ return resp.data;
531
+ }
532
+ /**
533
+ * Creates a DocumentReference and returns its ID along with a URL to upload the respective Document file to Metriport and make this document available to other HIEs.
534
+ * To upload your file contents, execute a PUT request using the returned uploadUrl with the file contents as the request body.
535
+ * Refer to Metriport Documentation for more details:
536
+ * https://docs.metriport.com/medical-api/api-reference/document/post-upload-url
537
+ *
538
+ * @param patientId - the ID of the patient.
539
+ * @param docRef - a FHIR Document Reference for this file upload. Mandatory fields include DocumentReference.description, DocumentReference.type, and DocumentReference.context. Besides that, try to include as much metadata on the document as possible. Note that you DO NOT need to fill in the Organization or Patient fields under the author or contained fields - Metriport will fill this in and overwrite whatever you put in.
540
+ * Refer to Metriport's documentation for more details: https://docs.metriport.com/medical-api/fhir/resources/documentreference.
541
+ *
542
+ * @returns The DocumentReference ID, and the URL to be used for subsequent file upload.
543
+ */
544
+ async createDocumentReference(patientId, docRef) {
545
+ const url = `${DOCUMENT_URL}/upload/?patientId=${patientId}`;
546
+ const resp = await this.api.post(url, docRef);
547
+ return resp.data;
548
+ }
549
+ /**
550
+ * Verifies the signature of a webhook request.
551
+ * Refer to Metriport's documentation for more details: https://docs.metriport.com/medical-api/more-info/webhooks.
552
+ *
553
+ * @param wh_key - your webhook key.
554
+ * @param req.body - the body of the webhook request.
555
+ * @param signature - the signature obtained from the webhook request header.
556
+ *
557
+ * @returns True if the signature is verified, false otherwise.
558
+ */
559
+ verifyWebhookSignature(wh_key, reqBody, signature) {
560
+ return MetriportMedicalApi.verifyWebhookSignature(wh_key, reqBody, signature);
561
+ }
562
+ /**
563
+ * Verifies the signature of a webhook request.
564
+ * Refer to Metriport's documentation for more details: https://docs.metriport.com/medical-api/more-info/webhooks.
565
+ *
566
+ * @param wh_key - your webhook key.
567
+ * @param req.body - the body of the webhook request.
568
+ * @param signature - the signature obtained from the webhook request header.
569
+ *
570
+ * @returns True if the signature is verified, false otherwise.
571
+ */
572
+ static verifyWebhookSignature(wh_key, reqBody, signature) {
573
+ const signatureAsString = String(signature);
574
+ const receivedHash = crypto_1.default
575
+ .createHmac("sha256", wh_key)
576
+ .update(JSON.stringify(reqBody))
577
+ .digest("hex");
578
+ return receivedHash === signatureAsString;
579
+ }
580
+ static parseWebhookResponse(reqBody, throwOnError = true) {
581
+ if (throwOnError) {
582
+ try {
583
+ return webhook_request_1.webhookRequestSchema.parse(reqBody);
584
+ }
585
+ catch (error) {
586
+ throw new Error(`Failed to parse webhook request`, { cause: error });
587
+ }
588
+ }
589
+ const parse = webhook_request_1.webhookRequestSchema.safeParse(reqBody);
590
+ if (parse.success)
591
+ return parse.data;
592
+ return new webhook_request_1.WebhookRequestParsingError(parse.error, parse.error.format());
593
+ }
594
+ }
595
+ exports.MetriportMedicalApi = MetriportMedicalApi;
596
+ //# sourceMappingURL=metriport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metriport.js","sourceRoot":"","sources":["../../../../../src/medical/client/metriport.ts"],"names":[],"mappings":";;;;;;AACA,kDAA+E;AAC/E,oDAA4B;AAC5B,8DAAiC;AACjC,yCAMsB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entifier } from "./demographics";
3
+ export type PatientDTO = {
4
+ id: string;
5
+ eTag?: string;
6
+ firstName: string;
7
+ lastName: string;
8
+ dob: string;
9
+ genderAtBirth: "M" | "F";
10
+ personalIdentifiers?: PersonalIdentifier[];
11
+ facilityIds: string[];
12
+ externalId?: string;
13
+ dateCreated?: Date;
14
+ address: Address | Address[];
15
+ contact?: Contact | Contact[];
16
+ };
17
+ type Coordinates = {
18
+ lat: number;
19
+ lon: number;
20
+ };
21
+ type Address = {
22
+ addressLine1: string;
23
+ addressLine2?: string;
24
+ city: string;
25
+ state: string;
26
+ zip: string;
27
+ country: string;
28
+ coordinates?: Coordinates;
29
+ };
30
+ export type BaseIdentifier = {
31
+ value: string;
32
+ period?: {
33
+ start: string;
34
+ end?: string;
35
+ } | {
36
+ start?: string;
37
+ end: string;
38
+ };
39
+ assigner?: string;
40
+ };
41
+ export type PersonalIdentifier = BaseIdentifier & ({
42
+ type: GeneralPersonalIdentifiers;
43
+ } | {
44
+ type: DriversLicensePersonalIdentifier;
45
+ state: USState;
46
+ });
47
+ type Contact = {
48
+ phone?: string | undefined;
49
+ email?: string | undefined;
50
+ };
51
+ export {};
52
+ //# sourceMappingURL=patientDTO.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patientDTO.d.ts","sourceRoot":"","sources":["../../../../../src/medical/models/patientDTO.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAC;AAE9F,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,GAAG,GAAG,GAAG,CAAC;IACzB,mBAAmB,CAAC,EAAE,kBAAkB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