@metriport/commonwell-sdk 4.3.11 → 4.3.13

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 (55) hide show
  1. package/lib/client/commonwell-api.d.ts +49 -49
  2. package/lib/client/commonwell-api.js +2 -2
  3. package/lib/client/commonwell.d.ts +425 -425
  4. package/lib/client/commonwell.js +739 -739
  5. package/lib/client/document.d.ts +7 -7
  6. package/lib/client/document.js +71 -71
  7. package/lib/common/commonwell-error.d.ts +12 -12
  8. package/lib/common/commonwell-error.js +34 -34
  9. package/lib/common/fileDownload.d.ts +11 -11
  10. package/lib/common/fileDownload.js +43 -43
  11. package/lib/common/make-jwt.d.ts +24 -24
  12. package/lib/common/make-jwt.js +90 -90
  13. package/lib/common/metriport-error.d.ts +4 -4
  14. package/lib/common/metriport-error.js +33 -33
  15. package/lib/common/util.d.ts +25 -25
  16. package/lib/common/util.js +70 -70
  17. package/lib/common/validate-npi.d.ts +9 -9
  18. package/lib/common/validate-npi.js +39 -39
  19. package/lib/index.d.ts +20 -20
  20. package/lib/index.js +54 -54
  21. package/lib/models/address.d.ts +50 -50
  22. package/lib/models/address.js +28 -28
  23. package/lib/models/certificates.d.ts +156 -156
  24. package/lib/models/certificates.js +26 -26
  25. package/lib/models/contact.d.ts +50 -50
  26. package/lib/models/contact.js +39 -39
  27. package/lib/models/demographics.d.ts +292 -292
  28. package/lib/models/demographics.js +34 -34
  29. package/lib/models/document.d.ts +4421 -4421
  30. package/lib/models/document.js +151 -151
  31. package/lib/models/enrollment-summary.d.ts +18 -18
  32. package/lib/models/enrollment-summary.js +14 -14
  33. package/lib/models/facility.d.ts +75 -75
  34. package/lib/models/facility.js +10 -10
  35. package/lib/models/human-name.d.ts +53 -53
  36. package/lib/models/human-name.js +37 -37
  37. package/lib/models/identifier.d.ts +79 -79
  38. package/lib/models/identifier.js +36 -36
  39. package/lib/models/iso-date.d.ts +3 -3
  40. package/lib/models/iso-date.js +6 -6
  41. package/lib/models/iso-datetime.d.ts +3 -3
  42. package/lib/models/iso-datetime.js +8 -8
  43. package/lib/models/link.d.ts +642 -642
  44. package/lib/models/link.js +50 -50
  45. package/lib/models/organization.d.ts +763 -763
  46. package/lib/models/organization.js +83 -83
  47. package/lib/models/patient.d.ts +3617 -3617
  48. package/lib/models/patient.js +49 -49
  49. package/lib/models/period.d.ts +12 -12
  50. package/lib/models/period.js +12 -12
  51. package/lib/models/person.d.ts +2440 -2440
  52. package/lib/models/person.js +39 -39
  53. package/lib/models/purpose-of-use.d.ts +29 -29
  54. package/lib/models/purpose-of-use.js +34 -34
  55. package/package.json +2 -2
@@ -1,425 +1,425 @@
1
- /// <reference types="node" />
2
- import { AxiosInstance } from "axios";
3
- import * as stream from "stream";
4
- import { CommonWellAPI } from "..";
5
- import { CertificateParam, CertificateResp } from "../models/certificates";
6
- import { DocumentQueryFullResponse, DocumentQueryResponse } from "../models/document";
7
- import { Identifier, StrongId } from "../models/identifier";
8
- import { NetworkLink, PatientLinkProxy } from "../models/link";
9
- import { Organization, OrganizationList } from "../models/organization";
10
- import { Patient, PatientLinkResp, PatientNetworkLinkResp, PatientSearchResp } from "../models/patient";
11
- import { PatientLink, PatientLinkSearchResp, Person, PersonSearchResp } from "../models/person";
12
- import { PurposeOfUse } from "../models/purpose-of-use";
13
- export declare enum APIMode {
14
- integration = "integration",
15
- production = "production"
16
- }
17
- export interface RequestMetadata {
18
- role: string;
19
- subjectId: string;
20
- purposeOfUse: PurposeOfUse;
21
- npi?: string;
22
- payloadHash?: string;
23
- }
24
- export declare class CommonWell implements CommonWellAPI {
25
- static integrationUrl: string;
26
- static productionUrl: string;
27
- static PERSON_ENDPOINT: string;
28
- static ORG_ENDPOINT: string;
29
- static PATIENT_ENDPOINT: string;
30
- static MEMBER_ENDPOINT: string;
31
- static DOCUMENT_QUERY_ENDPOINT: string;
32
- readonly api: AxiosInstance;
33
- private rsaPrivateKey;
34
- private orgName;
35
- private _oid;
36
- private httpsAgent;
37
- private _lastReferenceHeader;
38
- /**
39
- * Creates a new instance of the CommonWell API client pertaining to an
40
- * organization to make requests on behalf of.
41
- *
42
- * @param orgCert The certificate (public key) for the organization.
43
- * @param rsaPrivateKey An RSA key corresponding to the specified orgCert.
44
- * @param apiMode The mode the client will be running.
45
- * @param apiMode The mode the client will be running.
46
- * @param options Optional parameters
47
- * @param options.timeout Connection timeout in milliseconds, default 120 seconds.
48
- */
49
- constructor(orgCert: string, rsaPrivateKey: string, orgName: string, oid: string, apiMode: APIMode, options?: {
50
- timeout?: number;
51
- });
52
- get oid(): string;
53
- /**
54
- * Returns the `CW-Reference` header from the last request.
55
- */
56
- get lastReferenceHeader(): string | undefined;
57
- private postRequest;
58
- private axiosSuccessfulResponse;
59
- private axiosErrorResponse;
60
- /**
61
- * Create an org.
62
- * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#post-a-new-organization
63
- *
64
- * @param meta Metadata about the request.
65
- * @param organization The org to create.
66
- * @returns
67
- */
68
- createOrg(meta: RequestMetadata, organization: Organization): Promise<Organization>;
69
- /**
70
- * Update an org.
71
- * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#put-new-information-into-an-organization
72
- *
73
- * @param meta Metadata about the request.
74
- * @param organization The org to update.
75
- * @returns
76
- */
77
- updateOrg(meta: RequestMetadata, organization: Organization, id: string): Promise<Organization>;
78
- /**
79
- * Get list of orgs.
80
- * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#get-a-list-of-all-organizations
81
- *
82
- * @param meta Metadata about the request.
83
- * @param summary Returns only summary data
84
- * @param offset Sets an offset number from which recorded returns will begin
85
- * @param limit Limits the number of returned records
86
- * @param sort Specifies sort order
87
- * @returns
88
- */
89
- getAllOrgs(meta: RequestMetadata, summary?: boolean, offset?: number, limit?: number, sort?: string): Promise<OrganizationList>;
90
- /**
91
- * Get one org.
92
- * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#get-a-single-organization
93
- *
94
- * @param meta Metadata about the request.
95
- * @param id The org to be found
96
- * @returns
97
- */
98
- getOneOrg(meta: RequestMetadata, id: string): Promise<Organization | undefined>;
99
- /**
100
- * Add certificate to org.
101
- * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#post-new-certificates-to-organizations
102
- *
103
- * @param meta Metadata about the request.
104
- * @param certificate The certificate to add to the org
105
- * @param id The org to add a certificate too
106
- * @returns
107
- */
108
- addCertificateToOrg(meta: RequestMetadata, certificate: CertificateParam, id: string): Promise<CertificateResp>;
109
- /**
110
- * Replace certificate for org.
111
- * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#put-a-list-of-certificates-into-an-organization
112
- *
113
- * @param meta Metadata about the request.
114
- * @param certificate The certificate to replace for the org
115
- * @param id The org to replace a certificate for
116
- * @returns
117
- */
118
- replaceCertificateForOrg(meta: RequestMetadata, certificate: CertificateParam, id: string): Promise<CertificateResp>;
119
- /**
120
- * Delete certificate from org.
121
- * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#delete-certificates-by-thumbprint
122
- *
123
- * @param meta Metadata about the request.
124
- * @param id The org to delete a certificate from
125
- * @param thumbprint The thumbprint from the certificate
126
- * @param purpose The purpose from the certificate
127
- * @returns
128
- */
129
- deleteCertificateFromOrg(meta: RequestMetadata, id: string, thumbprint: string, purpose: string): Promise<void>;
130
- /**
131
- * Get certificate from org.
132
- * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#get-certificates-for-an-organization
133
- *
134
- * @param meta Metadata about the request.
135
- * @param certificate The certificate to add to the org
136
- * @param id The org to get a certificate from
137
- * @param thumbprint The thumbprint from the certificate
138
- * @param purpose The purpose from the certificate
139
- * @returns
140
- */
141
- getCertificatesFromOrg(meta: RequestMetadata, id: string, thumbprint?: string, purpose?: string): Promise<CertificateResp>;
142
- /**
143
- * Get certificate from org (by thumbprint).
144
- * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#get-certificates-by-thumbprint
145
- *
146
- * @param meta Metadata about the request.
147
- * @param certificate The certificate to add to the org
148
- * @param id The org to get a certificate from
149
- * @param thumbprint The thumbprint from the certificate
150
- * @param purpose The purpose from the certificate
151
- * @returns
152
- */
153
- getCertificatesFromOrgByThumbprint(meta: RequestMetadata, id: string, thumbprint: string, purpose?: string): Promise<CertificateResp>;
154
- /**
155
- * Get certificate from org (by thumbprint & purpose).
156
- * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#get-certificates-by-thumbprint-and-purpose
157
- *
158
- * @param meta Metadata about the request.
159
- * @param certificate The certificate to add to the org
160
- * @param id The org to get a certificate from
161
- * @param thumbprint The thumbprint from the certificate
162
- * @param purpose The purpose from the certificate
163
- * @returns
164
- */
165
- getCertificatesFromOrgByThumbprintAndPurpose(meta: RequestMetadata, id: string, thumbprint: string, purpose: string): Promise<CertificateResp>;
166
- /**
167
- * Enrolls a new person.
168
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8716-adding-a-new-person
169
- *
170
- * @param meta Metadata about the request.
171
- * @param person The person to enroll.
172
- * @returns
173
- */
174
- enrollPerson(meta: RequestMetadata, person: Person): Promise<Person>;
175
- /**
176
- * Searches for a person based on the specified strong ID.
177
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8711-search-for-a-person
178
- *
179
- * @param meta Metadata about the request.
180
- * @param key The ID's value, for example the driver's license ID.
181
- * @param system The ID's uri to specify type, for example "urn:oid:2.16.840.1.113883.4.3.6" is a CA DL.
182
- * @returns
183
- */
184
- searchPerson(meta: RequestMetadata, key: string, system: string): Promise<PersonSearchResp>;
185
- /**
186
- * Searches for a person based on patient demo.
187
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8713-find-persons-matching-patient-demographics
188
- *
189
- * @param meta Metadata about the request.
190
- * @param patientId The patient ID.
191
- * @returns
192
- */
193
- searchPersonByPatientDemo(meta: RequestMetadata, patientId: string): Promise<PersonSearchResp>;
194
- /**
195
- * Gets a person based on person id.
196
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8713-find-persons-matching-patient-demographics
197
- *
198
- * @param meta Metadata about the request.
199
- * @param personId The person ID.
200
- * @returns
201
- */
202
- getPersonById(meta: RequestMetadata, personId: string): Promise<Person>;
203
- /**
204
- * Updates a person.
205
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8741-updating-person-information
206
- *
207
- * @param meta Metadata about the request.
208
- * @param person The data to update.
209
- * @param id The person to be updated.
210
- * @returns
211
- */
212
- updatePerson(meta: RequestMetadata, person: Person, id: string): Promise<Person>;
213
- /**
214
- * Matches a person to a patient.
215
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8732-retrieve-patient-matches
216
- *
217
- * @param meta Metadata about the request.
218
- * @param id The person to be matched.
219
- * @returns
220
- */
221
- patientMatch(meta: RequestMetadata, id: string): Promise<PatientSearchResp>;
222
- /**
223
- * @deprecated use addPatientLink() instead
224
- */
225
- patientLink(meta: RequestMetadata, personId: string, patientUri: string, patientStrongId?: StrongId): Promise<PatientLink>;
226
- /**
227
- * Add patient link to person.
228
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8721
229
- *
230
- * @param meta Metadata about the request.
231
- * @param personId The person id to be link to a patient.
232
- * @param patientUri The patient uri to be link to a person.
233
- * @param [patientStrongId] The patient's strong ID, if available (optional).
234
- * @returns {PatientLink}
235
- */
236
- addPatientLink(meta: RequestMetadata, personId: string, patientUri: string, patientStrongId?: StrongId): Promise<PatientLink>;
237
- /**
238
- * Re-enrolls a person.
239
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#875-person-unenrollment
240
- *
241
- * @param meta Metadata about the request.
242
- * @param id The person to be re-enrolled.
243
- * @returns Person with enrollment information
244
- */
245
- reenrollPerson(meta: RequestMetadata, id: string): Promise<Person>;
246
- /**
247
- * Unenrolls a person.
248
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#875-person-unenrollment
249
- *
250
- * @param meta Metadata about the request.
251
- * @param id The person to be unenrolled.
252
- * @returns
253
- */
254
- unenrollPerson(meta: RequestMetadata, id: string): Promise<Person>;
255
- /**
256
- * Deletes a person.
257
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8742-deleting-a-person
258
- *
259
- * @param meta Metadata about the request.
260
- * @param id The person to be deleted.
261
- * @returns
262
- */
263
- deletePerson(meta: RequestMetadata, id: string): Promise<void>;
264
- /**
265
- * Register a new patient.
266
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8762-adding-a-local-patient-record
267
- *
268
- * @param meta Metadata about the request.
269
- * @param patient The patient to register.
270
- * @returns
271
- */
272
- registerPatient(meta: RequestMetadata, patient: Patient): Promise<Patient>;
273
- /**
274
- * Returns a patient based on its ID.
275
- *
276
- * @param meta Metadata about the request.
277
- * @param id Patient's ID.
278
- * @returns {Promise<Patient>}
279
- */
280
- getPatient(meta: RequestMetadata, id: string): Promise<Patient>;
281
- /**
282
- * Searches for a patient based on params.
283
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8761-search-for-a-patient
284
- *
285
- * @param meta Metadata about the request.
286
- * @param fname Patient's first name.
287
- * @param lname Patient's last name.
288
- * @param dob Patient's date of birth.
289
- * @param gender Patient's gender.
290
- * @param zip Patient's zip code.
291
- * @returns
292
- */
293
- searchPatient(meta: RequestMetadata, fname: string, lname: string, dob: string, gender?: string, zip?: string): Promise<PatientSearchResp>;
294
- /**
295
- * Updates a patient.
296
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8763-updating-a-local-patient-record
297
- *
298
- * @param meta Metadata about the request.
299
- * @param patient The data to update.
300
- * @param id The patient to be updated.
301
- * @returns
302
- */
303
- updatePatient(meta: RequestMetadata, patient: Patient, id: string): Promise<Patient>;
304
- /**
305
- * Merges patients.
306
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8765-merging-local-patient-records
307
- *
308
- * @param meta Metadata about the request.
309
- * @param nonSurvivingPatientId The local Patient Identifier of the non-surviving Patient Record (This patient gets replaced)
310
- * @param referencePatientLink The patient link for the patient that will replace the non surviving patient
311
- * @returns
312
- */
313
- mergePatients(meta: RequestMetadata, nonSurvivingPatientId: string, referencePatientLink: string): Promise<void>;
314
- /**
315
- * Get Patient's Network Links.
316
- * See: https://specification.commonwellalliance.org/services/record-locator-service/protocol-operations-record-locator-service#8771-retrieving-network-links
317
- *
318
- * @param meta Metadata about the request.
319
- * @param patientId Patient for which to get the network links.
320
- * @returns
321
- */
322
- getNetworkLinks(meta: RequestMetadata, patientId: string): Promise<PatientNetworkLinkResp>;
323
- /**
324
- * Deletes a patient.
325
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8764-deleting-a-local-patient-record
326
- *
327
- * @param meta Metadata about the request.
328
- * @param id The patient to be updated.
329
- * @returns
330
- */
331
- deletePatient(meta: RequestMetadata, id: string): Promise<void>;
332
- /**
333
- * Queries a patient's Documents.
334
- *
335
- * @param meta Metadata about the request.
336
- * @param patientId The patient's ID.
337
- * @returns {Promise<DocumentQueryResponse>}
338
- * @see {@link https://specification.commonwellalliance.org/services/data-broker/cha-broker-api-reference#104-document-query|Use case}
339
- * @see {@link https://specification.commonwellalliance.org/services/data-broker/protocol-operations-data-broker#8781-find-documents|API spec}
340
- */
341
- queryDocuments(meta: RequestMetadata, patientId: string): Promise<DocumentQueryResponse>;
342
- /**
343
- * Queries a patient's Documents - including other possible results.
344
- *
345
- * @param meta Metadata about the request.
346
- * @param patientId The patient's ID.
347
- * @returns The DocumentReferences of a patient's available documents and/or OperationOutcomes denoting problems with the query.
348
- * @see {@link https://specification.commonwellalliance.org/services/data-broker/cha-broker-api-reference#104-document-query|Use case}
349
- * @see {@link https://specification.commonwellalliance.org/services/data-broker/protocol-operations-data-broker#8781-find-documents|API spec}
350
- */
351
- queryDocumentsFull(meta: RequestMetadata, patientId: string): Promise<DocumentQueryFullResponse>;
352
- /**
353
- * Retrieve a Document and pipe its bytes into the outputStream.
354
- *
355
- * @param {string} inputUrl - The URL of the file to be downloaded.
356
- * @param {fs.WriteStream} outputStream - The stream to receive the downloaded file's bytes.
357
- * @returns {Promise<void>}
358
- * @see {@link https://specification.commonwellalliance.org/services/data-broker/cha-broker-api-reference#106-document-retrieval|Use case}
359
- * @see {@link https://specification.commonwellalliance.org/services/data-broker/protocol-operations-data-broker#8782-retrieve-document|API spec}
360
- */
361
- retrieveDocument(meta: RequestMetadata, inputUrl: string, outputStream: stream.Writable): Promise<void>;
362
- /**
363
- * Upgrade or downgrade network link.
364
- * See: https://specification.commonwellalliance.org/services/record-locator-service/protocol-operations-record-locator-service#8772-upgrading-a-network-link
365
- *
366
- * @param meta Metadata about the request.
367
- * @param href The href of network link to be upgraded or downgraded
368
- * @param proxy The proxy for the patient link action.
369
- * @returns
370
- */
371
- upgradeOrDowngradeNetworkLink(meta: RequestMetadata, href: string, proxy?: PatientLinkProxy): Promise<NetworkLink>;
372
- /**
373
- * Update a patient link.
374
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8722-updating-a-patient-link
375
- *
376
- * @param meta Metadata about the request.
377
- * @param patientLinkUri The uri of patient link to be updated
378
- * @param patientUri The uri of patient that belongs to this link
379
- * @param identifier Add identifier information to the patient link
380
- * @returns
381
- */
382
- updatePatientLink(meta: RequestMetadata, patientLinkUri: string, patientUri?: string, identifier?: Identifier): Promise<PatientLink>;
383
- /**
384
- * Get a person's links to patients.
385
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8721
386
- *
387
- * @param meta Metadata about the request.
388
- * @param personId The person id to be link to a patient.
389
- * @param [limitToOrg=true] Whether to limit the search to the current organization (optional).
390
- * @returns Response with list of links to Patients
391
- */
392
- getPatientLinks(meta: RequestMetadata, personId: string, limitToOrg?: boolean): Promise<PatientLinkSearchResp>;
393
- /**
394
- * Gets a patient link.
395
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8723-getting-a-patient-link
396
- *
397
- * @param meta Metadata about the request.
398
- * @param personId Person that is linked
399
- * @param patientId Patient that is linked
400
- * @returns
401
- */
402
- getPatientLink(meta: RequestMetadata, personId: string, patientId: string): Promise<PatientLinkResp>;
403
- /**
404
- * Deletes a patient link - the link will be moved to LOLA 0 and cannot be used again.
405
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8724-deleting-a-patient-link
406
- *
407
- * WARNING: This shouldn't be used except under the explicit request of a person.
408
- *
409
- * @param meta Metadata about the request.
410
- * @param patientLinkUri The uri of patient link to be deleted
411
- * @returns
412
- */
413
- deletePatientLink(meta: RequestMetadata, patientLinkUri: string): Promise<void>;
414
- /**
415
- * Resets a patient link - the link will be moved to LOLA 1 and can be relinked later.
416
- * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8725-resetting-a-patient-link
417
- *
418
- * @param meta Metadata about the request.
419
- * @param personId Person that is linked
420
- * @param patientId Patient that is linked
421
- * @returns
422
- */
423
- resetPatientLink(meta: RequestMetadata, personId: string, patientId: string): Promise<void>;
424
- private buildQueryHeaders;
425
- }
1
+ /// <reference types="node" />
2
+ import { AxiosInstance } from "axios";
3
+ import * as stream from "stream";
4
+ import { CommonWellAPI } from "..";
5
+ import { CertificateParam, CertificateResp } from "../models/certificates";
6
+ import { DocumentQueryFullResponse, DocumentQueryResponse } from "../models/document";
7
+ import { Identifier, StrongId } from "../models/identifier";
8
+ import { NetworkLink, PatientLinkProxy } from "../models/link";
9
+ import { Organization, OrganizationList } from "../models/organization";
10
+ import { Patient, PatientLinkResp, PatientNetworkLinkResp, PatientSearchResp } from "../models/patient";
11
+ import { PatientLink, PatientLinkSearchResp, Person, PersonSearchResp } from "../models/person";
12
+ import { PurposeOfUse } from "../models/purpose-of-use";
13
+ export declare enum APIMode {
14
+ integration = "integration",
15
+ production = "production"
16
+ }
17
+ export interface RequestMetadata {
18
+ role: string;
19
+ subjectId: string;
20
+ purposeOfUse: PurposeOfUse;
21
+ npi?: string;
22
+ payloadHash?: string;
23
+ }
24
+ export declare class CommonWell implements CommonWellAPI {
25
+ static integrationUrl: string;
26
+ static productionUrl: string;
27
+ static PERSON_ENDPOINT: string;
28
+ static ORG_ENDPOINT: string;
29
+ static PATIENT_ENDPOINT: string;
30
+ static MEMBER_ENDPOINT: string;
31
+ static DOCUMENT_QUERY_ENDPOINT: string;
32
+ readonly api: AxiosInstance;
33
+ private rsaPrivateKey;
34
+ private orgName;
35
+ private _oid;
36
+ private httpsAgent;
37
+ private _lastReferenceHeader;
38
+ /**
39
+ * Creates a new instance of the CommonWell API client pertaining to an
40
+ * organization to make requests on behalf of.
41
+ *
42
+ * @param orgCert The certificate (public key) for the organization.
43
+ * @param rsaPrivateKey An RSA key corresponding to the specified orgCert.
44
+ * @param apiMode The mode the client will be running.
45
+ * @param apiMode The mode the client will be running.
46
+ * @param options Optional parameters
47
+ * @param options.timeout Connection timeout in milliseconds, default 120 seconds.
48
+ */
49
+ constructor(orgCert: string, rsaPrivateKey: string, orgName: string, oid: string, apiMode: APIMode, options?: {
50
+ timeout?: number;
51
+ });
52
+ get oid(): string;
53
+ /**
54
+ * Returns the `CW-Reference` header from the last request.
55
+ */
56
+ get lastReferenceHeader(): string | undefined;
57
+ private postRequest;
58
+ private axiosSuccessfulResponse;
59
+ private axiosErrorResponse;
60
+ /**
61
+ * Create an org.
62
+ * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#post-a-new-organization
63
+ *
64
+ * @param meta Metadata about the request.
65
+ * @param organization The org to create.
66
+ * @returns
67
+ */
68
+ createOrg(meta: RequestMetadata, organization: Organization): Promise<Organization>;
69
+ /**
70
+ * Update an org.
71
+ * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#put-new-information-into-an-organization
72
+ *
73
+ * @param meta Metadata about the request.
74
+ * @param organization The org to update.
75
+ * @returns
76
+ */
77
+ updateOrg(meta: RequestMetadata, organization: Organization, id: string): Promise<Organization>;
78
+ /**
79
+ * Get list of orgs.
80
+ * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#get-a-list-of-all-organizations
81
+ *
82
+ * @param meta Metadata about the request.
83
+ * @param summary Returns only summary data
84
+ * @param offset Sets an offset number from which recorded returns will begin
85
+ * @param limit Limits the number of returned records
86
+ * @param sort Specifies sort order
87
+ * @returns
88
+ */
89
+ getAllOrgs(meta: RequestMetadata, summary?: boolean, offset?: number, limit?: number, sort?: string): Promise<OrganizationList>;
90
+ /**
91
+ * Get one org.
92
+ * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#get-a-single-organization
93
+ *
94
+ * @param meta Metadata about the request.
95
+ * @param id The org to be found
96
+ * @returns
97
+ */
98
+ getOneOrg(meta: RequestMetadata, id: string): Promise<Organization | undefined>;
99
+ /**
100
+ * Add certificate to org.
101
+ * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#post-new-certificates-to-organizations
102
+ *
103
+ * @param meta Metadata about the request.
104
+ * @param certificate The certificate to add to the org
105
+ * @param id The org to add a certificate too
106
+ * @returns
107
+ */
108
+ addCertificateToOrg(meta: RequestMetadata, certificate: CertificateParam, id: string): Promise<CertificateResp>;
109
+ /**
110
+ * Replace certificate for org.
111
+ * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#put-a-list-of-certificates-into-an-organization
112
+ *
113
+ * @param meta Metadata about the request.
114
+ * @param certificate The certificate to replace for the org
115
+ * @param id The org to replace a certificate for
116
+ * @returns
117
+ */
118
+ replaceCertificateForOrg(meta: RequestMetadata, certificate: CertificateParam, id: string): Promise<CertificateResp>;
119
+ /**
120
+ * Delete certificate from org.
121
+ * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#delete-certificates-by-thumbprint
122
+ *
123
+ * @param meta Metadata about the request.
124
+ * @param id The org to delete a certificate from
125
+ * @param thumbprint The thumbprint from the certificate
126
+ * @param purpose The purpose from the certificate
127
+ * @returns
128
+ */
129
+ deleteCertificateFromOrg(meta: RequestMetadata, id: string, thumbprint: string, purpose: string): Promise<void>;
130
+ /**
131
+ * Get certificate from org.
132
+ * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#get-certificates-for-an-organization
133
+ *
134
+ * @param meta Metadata about the request.
135
+ * @param certificate The certificate to add to the org
136
+ * @param id The org to get a certificate from
137
+ * @param thumbprint The thumbprint from the certificate
138
+ * @param purpose The purpose from the certificate
139
+ * @returns
140
+ */
141
+ getCertificatesFromOrg(meta: RequestMetadata, id: string, thumbprint?: string, purpose?: string): Promise<CertificateResp>;
142
+ /**
143
+ * Get certificate from org (by thumbprint).
144
+ * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#get-certificates-by-thumbprint
145
+ *
146
+ * @param meta Metadata about the request.
147
+ * @param certificate The certificate to add to the org
148
+ * @param id The org to get a certificate from
149
+ * @param thumbprint The thumbprint from the certificate
150
+ * @param purpose The purpose from the certificate
151
+ * @returns
152
+ */
153
+ getCertificatesFromOrgByThumbprint(meta: RequestMetadata, id: string, thumbprint: string, purpose?: string): Promise<CertificateResp>;
154
+ /**
155
+ * Get certificate from org (by thumbprint & purpose).
156
+ * See: https://commonwellalliance.sharepoint.com/sites/ServiceAdopter/SitePages/Organization-Management-API---Overview-and-Summary.aspx#get-certificates-by-thumbprint-and-purpose
157
+ *
158
+ * @param meta Metadata about the request.
159
+ * @param certificate The certificate to add to the org
160
+ * @param id The org to get a certificate from
161
+ * @param thumbprint The thumbprint from the certificate
162
+ * @param purpose The purpose from the certificate
163
+ * @returns
164
+ */
165
+ getCertificatesFromOrgByThumbprintAndPurpose(meta: RequestMetadata, id: string, thumbprint: string, purpose: string): Promise<CertificateResp>;
166
+ /**
167
+ * Enrolls a new person.
168
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8716-adding-a-new-person
169
+ *
170
+ * @param meta Metadata about the request.
171
+ * @param person The person to enroll.
172
+ * @returns
173
+ */
174
+ enrollPerson(meta: RequestMetadata, person: Person): Promise<Person>;
175
+ /**
176
+ * Searches for a person based on the specified strong ID.
177
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8711-search-for-a-person
178
+ *
179
+ * @param meta Metadata about the request.
180
+ * @param key The ID's value, for example the driver's license ID.
181
+ * @param system The ID's uri to specify type, for example "urn:oid:2.16.840.1.113883.4.3.6" is a CA DL.
182
+ * @returns
183
+ */
184
+ searchPerson(meta: RequestMetadata, key: string, system: string): Promise<PersonSearchResp>;
185
+ /**
186
+ * Searches for a person based on patient demo.
187
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8713-find-persons-matching-patient-demographics
188
+ *
189
+ * @param meta Metadata about the request.
190
+ * @param patientId The patient ID.
191
+ * @returns
192
+ */
193
+ searchPersonByPatientDemo(meta: RequestMetadata, patientId: string): Promise<PersonSearchResp>;
194
+ /**
195
+ * Gets a person based on person id.
196
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8713-find-persons-matching-patient-demographics
197
+ *
198
+ * @param meta Metadata about the request.
199
+ * @param personId The person ID.
200
+ * @returns
201
+ */
202
+ getPersonById(meta: RequestMetadata, personId: string): Promise<Person>;
203
+ /**
204
+ * Updates a person.
205
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8741-updating-person-information
206
+ *
207
+ * @param meta Metadata about the request.
208
+ * @param person The data to update.
209
+ * @param id The person to be updated.
210
+ * @returns
211
+ */
212
+ updatePerson(meta: RequestMetadata, person: Person, id: string): Promise<Person>;
213
+ /**
214
+ * Matches a person to a patient.
215
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8732-retrieve-patient-matches
216
+ *
217
+ * @param meta Metadata about the request.
218
+ * @param id The person to be matched.
219
+ * @returns
220
+ */
221
+ patientMatch(meta: RequestMetadata, id: string): Promise<PatientSearchResp>;
222
+ /**
223
+ * @deprecated use addPatientLink() instead
224
+ */
225
+ patientLink(meta: RequestMetadata, personId: string, patientUri: string, patientStrongId?: StrongId): Promise<PatientLink>;
226
+ /**
227
+ * Add patient link to person.
228
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8721
229
+ *
230
+ * @param meta Metadata about the request.
231
+ * @param personId The person id to be link to a patient.
232
+ * @param patientUri The patient uri to be link to a person.
233
+ * @param [patientStrongId] The patient's strong ID, if available (optional).
234
+ * @returns {PatientLink}
235
+ */
236
+ addPatientLink(meta: RequestMetadata, personId: string, patientUri: string, patientStrongId?: StrongId): Promise<PatientLink>;
237
+ /**
238
+ * Re-enrolls a person.
239
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#875-person-unenrollment
240
+ *
241
+ * @param meta Metadata about the request.
242
+ * @param id The person to be re-enrolled.
243
+ * @returns Person with enrollment information
244
+ */
245
+ reenrollPerson(meta: RequestMetadata, id: string): Promise<Person>;
246
+ /**
247
+ * Unenrolls a person.
248
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#875-person-unenrollment
249
+ *
250
+ * @param meta Metadata about the request.
251
+ * @param id The person to be unenrolled.
252
+ * @returns
253
+ */
254
+ unenrollPerson(meta: RequestMetadata, id: string): Promise<Person>;
255
+ /**
256
+ * Deletes a person.
257
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8742-deleting-a-person
258
+ *
259
+ * @param meta Metadata about the request.
260
+ * @param id The person to be deleted.
261
+ * @returns
262
+ */
263
+ deletePerson(meta: RequestMetadata, id: string): Promise<void>;
264
+ /**
265
+ * Register a new patient.
266
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8762-adding-a-local-patient-record
267
+ *
268
+ * @param meta Metadata about the request.
269
+ * @param patient The patient to register.
270
+ * @returns
271
+ */
272
+ registerPatient(meta: RequestMetadata, patient: Patient): Promise<Patient>;
273
+ /**
274
+ * Returns a patient based on its ID.
275
+ *
276
+ * @param meta Metadata about the request.
277
+ * @param id Patient's ID.
278
+ * @returns {Promise<Patient>}
279
+ */
280
+ getPatient(meta: RequestMetadata, id: string): Promise<Patient>;
281
+ /**
282
+ * Searches for a patient based on params.
283
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8761-search-for-a-patient
284
+ *
285
+ * @param meta Metadata about the request.
286
+ * @param fname Patient's first name.
287
+ * @param lname Patient's last name.
288
+ * @param dob Patient's date of birth.
289
+ * @param gender Patient's gender.
290
+ * @param zip Patient's zip code.
291
+ * @returns
292
+ */
293
+ searchPatient(meta: RequestMetadata, fname: string, lname: string, dob: string, gender?: string, zip?: string): Promise<PatientSearchResp>;
294
+ /**
295
+ * Updates a patient.
296
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8763-updating-a-local-patient-record
297
+ *
298
+ * @param meta Metadata about the request.
299
+ * @param patient The data to update.
300
+ * @param id The patient to be updated.
301
+ * @returns
302
+ */
303
+ updatePatient(meta: RequestMetadata, patient: Patient, id: string): Promise<Patient>;
304
+ /**
305
+ * Merges patients.
306
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8765-merging-local-patient-records
307
+ *
308
+ * @param meta Metadata about the request.
309
+ * @param nonSurvivingPatientId The local Patient Identifier of the non-surviving Patient Record (This patient gets replaced)
310
+ * @param referencePatientLink The patient link for the patient that will replace the non surviving patient
311
+ * @returns
312
+ */
313
+ mergePatients(meta: RequestMetadata, nonSurvivingPatientId: string, referencePatientLink: string): Promise<void>;
314
+ /**
315
+ * Get Patient's Network Links.
316
+ * See: https://specification.commonwellalliance.org/services/record-locator-service/protocol-operations-record-locator-service#8771-retrieving-network-links
317
+ *
318
+ * @param meta Metadata about the request.
319
+ * @param patientId Patient for which to get the network links.
320
+ * @returns
321
+ */
322
+ getNetworkLinks(meta: RequestMetadata, patientId: string): Promise<PatientNetworkLinkResp>;
323
+ /**
324
+ * Deletes a patient.
325
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8764-deleting-a-local-patient-record
326
+ *
327
+ * @param meta Metadata about the request.
328
+ * @param id The patient to be updated.
329
+ * @returns
330
+ */
331
+ deletePatient(meta: RequestMetadata, id: string): Promise<void>;
332
+ /**
333
+ * Queries a patient's Documents.
334
+ *
335
+ * @param meta Metadata about the request.
336
+ * @param patientId The patient's ID.
337
+ * @returns {Promise<DocumentQueryResponse>}
338
+ * @see {@link https://specification.commonwellalliance.org/services/data-broker/cha-broker-api-reference#104-document-query|Use case}
339
+ * @see {@link https://specification.commonwellalliance.org/services/data-broker/protocol-operations-data-broker#8781-find-documents|API spec}
340
+ */
341
+ queryDocuments(meta: RequestMetadata, patientId: string): Promise<DocumentQueryResponse>;
342
+ /**
343
+ * Queries a patient's Documents - including other possible results.
344
+ *
345
+ * @param meta Metadata about the request.
346
+ * @param patientId The patient's ID.
347
+ * @returns The DocumentReferences of a patient's available documents and/or OperationOutcomes denoting problems with the query.
348
+ * @see {@link https://specification.commonwellalliance.org/services/data-broker/cha-broker-api-reference#104-document-query|Use case}
349
+ * @see {@link https://specification.commonwellalliance.org/services/data-broker/protocol-operations-data-broker#8781-find-documents|API spec}
350
+ */
351
+ queryDocumentsFull(meta: RequestMetadata, patientId: string): Promise<DocumentQueryFullResponse>;
352
+ /**
353
+ * Retrieve a Document and pipe its bytes into the outputStream.
354
+ *
355
+ * @param {string} inputUrl - The URL of the file to be downloaded.
356
+ * @param {fs.WriteStream} outputStream - The stream to receive the downloaded file's bytes.
357
+ * @returns {Promise<void>}
358
+ * @see {@link https://specification.commonwellalliance.org/services/data-broker/cha-broker-api-reference#106-document-retrieval|Use case}
359
+ * @see {@link https://specification.commonwellalliance.org/services/data-broker/protocol-operations-data-broker#8782-retrieve-document|API spec}
360
+ */
361
+ retrieveDocument(meta: RequestMetadata, inputUrl: string, outputStream: stream.Writable): Promise<void>;
362
+ /**
363
+ * Upgrade or downgrade network link.
364
+ * See: https://specification.commonwellalliance.org/services/record-locator-service/protocol-operations-record-locator-service#8772-upgrading-a-network-link
365
+ *
366
+ * @param meta Metadata about the request.
367
+ * @param href The href of network link to be upgraded or downgraded
368
+ * @param proxy The proxy for the patient link action.
369
+ * @returns
370
+ */
371
+ upgradeOrDowngradeNetworkLink(meta: RequestMetadata, href: string, proxy?: PatientLinkProxy): Promise<NetworkLink>;
372
+ /**
373
+ * Update a patient link.
374
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8722-updating-a-patient-link
375
+ *
376
+ * @param meta Metadata about the request.
377
+ * @param patientLinkUri The uri of patient link to be updated
378
+ * @param patientUri The uri of patient that belongs to this link
379
+ * @param identifier Add identifier information to the patient link
380
+ * @returns
381
+ */
382
+ updatePatientLink(meta: RequestMetadata, patientLinkUri: string, patientUri?: string, identifier?: Identifier): Promise<PatientLink>;
383
+ /**
384
+ * Get a person's links to patients.
385
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8721
386
+ *
387
+ * @param meta Metadata about the request.
388
+ * @param personId The person id to be link to a patient.
389
+ * @param [limitToOrg=true] Whether to limit the search to the current organization (optional).
390
+ * @returns Response with list of links to Patients
391
+ */
392
+ getPatientLinks(meta: RequestMetadata, personId: string, limitToOrg?: boolean): Promise<PatientLinkSearchResp>;
393
+ /**
394
+ * Gets a patient link.
395
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8723-getting-a-patient-link
396
+ *
397
+ * @param meta Metadata about the request.
398
+ * @param personId Person that is linked
399
+ * @param patientId Patient that is linked
400
+ * @returns
401
+ */
402
+ getPatientLink(meta: RequestMetadata, personId: string, patientId: string): Promise<PatientLinkResp>;
403
+ /**
404
+ * Deletes a patient link - the link will be moved to LOLA 0 and cannot be used again.
405
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8724-deleting-a-patient-link
406
+ *
407
+ * WARNING: This shouldn't be used except under the explicit request of a person.
408
+ *
409
+ * @param meta Metadata about the request.
410
+ * @param patientLinkUri The uri of patient link to be deleted
411
+ * @returns
412
+ */
413
+ deletePatientLink(meta: RequestMetadata, patientLinkUri: string): Promise<void>;
414
+ /**
415
+ * Resets a patient link - the link will be moved to LOLA 1 and can be relinked later.
416
+ * See: https://specification.commonwellalliance.org/services/patient-identity-and-linking/protocol-operations#8725-resetting-a-patient-link
417
+ *
418
+ * @param meta Metadata about the request.
419
+ * @param personId Person that is linked
420
+ * @param patientId Patient that is linked
421
+ * @returns
422
+ */
423
+ resetPatientLink(meta: RequestMetadata, personId: string, patientId: string): Promise<void>;
424
+ private buildQueryHeaders;
425
+ }