@metriport/commonwell-sdk 0.30.0-alpha.1
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/LICENSE +21 -0
- package/README.md +64 -0
- package/dist/__tests__/env-setup.d.ts +2 -0
- package/dist/__tests__/env-setup.d.ts.map +1 -0
- package/dist/__tests__/env-setup.js +35 -0
- package/dist/__tests__/env-setup.js.map +1 -0
- package/dist/client/common.d.ts +39 -0
- package/dist/client/common.d.ts.map +1 -0
- package/dist/client/common.js +15 -0
- package/dist/client/common.js.map +1 -0
- package/dist/client/commonwell-api.d.ts +103 -0
- package/dist/client/commonwell-api.d.ts.map +1 -0
- package/dist/client/commonwell-api.js +3 -0
- package/dist/client/commonwell-api.js.map +1 -0
- package/dist/client/commonwell-base.d.ts +47 -0
- package/dist/client/commonwell-base.d.ts.map +1 -0
- package/dist/client/commonwell-base.js +105 -0
- package/dist/client/commonwell-base.js.map +1 -0
- package/dist/client/commonwell-member-api.d.ts +29 -0
- package/dist/client/commonwell-member-api.d.ts.map +1 -0
- package/dist/client/commonwell-member-api.js +3 -0
- package/dist/client/commonwell-member-api.js.map +1 -0
- package/dist/client/commonwell-member.d.ts +168 -0
- package/dist/client/commonwell-member.d.ts.map +1 -0
- package/dist/client/commonwell-member.js +349 -0
- package/dist/client/commonwell-member.js.map +1 -0
- package/dist/client/commonwell.d.ts +245 -0
- package/dist/client/commonwell.d.ts.map +1 -0
- package/dist/client/commonwell.js +502 -0
- package/dist/client/commonwell.js.map +1 -0
- package/dist/common/__tests__/util.test.d.ts +2 -0
- package/dist/common/__tests__/util.test.d.ts.map +1 -0
- package/dist/common/__tests__/util.test.js +51 -0
- package/dist/common/__tests__/util.test.js.map +1 -0
- package/dist/common/__tests__/validate-npi.test.d.ts +2 -0
- package/dist/common/__tests__/validate-npi.test.d.ts.map +1 -0
- package/dist/common/__tests__/validate-npi.test.js +44 -0
- package/dist/common/__tests__/validate-npi.test.js.map +1 -0
- package/dist/common/certificate.d.ts +3 -0
- package/dist/common/certificate.d.ts.map +1 -0
- package/dist/common/certificate.js +11 -0
- package/dist/common/certificate.js.map +1 -0
- package/dist/common/commonwell-error.d.ts +23 -0
- package/dist/common/commonwell-error.d.ts.map +1 -0
- package/dist/common/commonwell-error.js +33 -0
- package/dist/common/commonwell-error.js.map +1 -0
- package/dist/common/fileDownload.d.ts +37 -0
- package/dist/common/fileDownload.d.ts.map +1 -0
- package/dist/common/fileDownload.js +53 -0
- package/dist/common/fileDownload.js.map +1 -0
- package/dist/common/make-jwt.d.ts +60 -0
- package/dist/common/make-jwt.d.ts.map +1 -0
- package/dist/common/make-jwt.js +124 -0
- package/dist/common/make-jwt.js.map +1 -0
- package/dist/common/util.d.ts +78 -0
- package/dist/common/util.d.ts.map +1 -0
- package/dist/common/util.js +104 -0
- package/dist/common/util.js.map +1 -0
- package/dist/common/validate-npi.d.ts +2 -0
- package/dist/common/validate-npi.d.ts.map +1 -0
- package/dist/common/validate-npi.js +6 -0
- package/dist/common/validate-npi.js.map +1 -0
- package/dist/common/zod.d.ts +13 -0
- package/dist/common/zod.d.ts.map +1 -0
- package/dist/common/zod.js +38 -0
- package/dist/common/zod.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/models/__tests__/address.test.d.ts +2 -0
- package/dist/models/__tests__/address.test.d.ts.map +1 -0
- package/dist/models/__tests__/address.test.js +348 -0
- package/dist/models/__tests__/address.test.js.map +1 -0
- package/dist/models/__tests__/demographics.test.d.ts +2 -0
- package/dist/models/__tests__/demographics.test.d.ts.map +1 -0
- package/dist/models/__tests__/demographics.test.js +96 -0
- package/dist/models/__tests__/demographics.test.js.map +1 -0
- package/dist/models/address.d.ts +177 -0
- package/dist/models/address.d.ts.map +1 -0
- package/dist/models/address.js +94 -0
- package/dist/models/address.js.map +1 -0
- package/dist/models/certificates.d.ts +77 -0
- package/dist/models/certificates.d.ts.map +1 -0
- package/dist/models/certificates.js +27 -0
- package/dist/models/certificates.js.map +1 -0
- package/dist/models/contact.d.ts +47 -0
- package/dist/models/contact.d.ts.map +1 -0
- package/dist/models/contact.js +30 -0
- package/dist/models/contact.js.map +1 -0
- package/dist/models/date.d.ts +4 -0
- package/dist/models/date.d.ts.map +1 -0
- package/dist/models/date.js +10 -0
- package/dist/models/date.js.map +1 -0
- package/dist/models/demographics.d.ts +290 -0
- package/dist/models/demographics.d.ts.map +1 -0
- package/dist/models/demographics.js +57 -0
- package/dist/models/demographics.js.map +1 -0
- package/dist/models/document.d.ts +7823 -0
- package/dist/models/document.d.ts.map +1 -0
- package/dist/models/document.js +106 -0
- package/dist/models/document.js.map +1 -0
- package/dist/models/facility.d.ts +82 -0
- package/dist/models/facility.d.ts.map +1 -0
- package/dist/models/facility.js +11 -0
- package/dist/models/facility.js.map +1 -0
- package/dist/models/human-name.d.ts +56 -0
- package/dist/models/human-name.d.ts.map +1 -0
- package/dist/models/human-name.js +39 -0
- package/dist/models/human-name.js.map +1 -0
- package/dist/models/identifier.d.ts +110 -0
- package/dist/models/identifier.d.ts.map +1 -0
- package/dist/models/identifier.js +37 -0
- package/dist/models/identifier.js.map +1 -0
- package/dist/models/organization.d.ts +2390 -0
- package/dist/models/organization.d.ts.map +1 -0
- package/dist/models/organization.js +139 -0
- package/dist/models/organization.js.map +1 -0
- package/dist/models/patient-organization.d.ts +36 -0
- package/dist/models/patient-organization.d.ts.map +1 -0
- package/dist/models/patient-organization.js +10 -0
- package/dist/models/patient-organization.js.map +1 -0
- package/dist/models/patient.d.ts +5350 -0
- package/dist/models/patient.d.ts.map +1 -0
- package/dist/models/patient.js +94 -0
- package/dist/models/patient.js.map +1 -0
- package/dist/models/period.d.ts +13 -0
- package/dist/models/period.d.ts.map +1 -0
- package/dist/models/period.js +13 -0
- package/dist/models/period.js.map +1 -0
- package/dist/models/reference.d.ts +109 -0
- package/dist/models/reference.d.ts.map +1 -0
- package/dist/models/reference.js +12 -0
- package/dist/models/reference.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,502 @@
|
|
|
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.CommonWell = void 0;
|
|
7
|
+
const shared_1 = require("@metriport/shared");
|
|
8
|
+
const axios_1 = require("axios");
|
|
9
|
+
const http_status_1 = __importDefault(require("http-status"));
|
|
10
|
+
const commonwell_error_1 = require("../common/commonwell-error");
|
|
11
|
+
const fileDownload_1 = require("../common/fileDownload");
|
|
12
|
+
const make_jwt_1 = require("../common/make-jwt");
|
|
13
|
+
const util_1 = require("../common/util");
|
|
14
|
+
const date_1 = require("../models/date");
|
|
15
|
+
const document_1 = require("../models/document");
|
|
16
|
+
const patient_1 = require("../models/patient");
|
|
17
|
+
const commonwell_base_1 = require("./commonwell-base");
|
|
18
|
+
/**
|
|
19
|
+
* Implementation of the CommonWell API, v4.
|
|
20
|
+
* @see https://www.commonwellalliance.org/specification/
|
|
21
|
+
*/
|
|
22
|
+
class CommonWell extends commonwell_base_1.CommonWellBase {
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new instance of the CommonWell API client pertaining to an
|
|
25
|
+
* organization to make requests on behalf of.
|
|
26
|
+
*/
|
|
27
|
+
constructor({ orgCert, rsaPrivateKey, orgName, oid, npi, homeCommunityId, apiMode, authGrantorReferenceOid: authGrantorReference, options = {}, }) {
|
|
28
|
+
super({
|
|
29
|
+
orgCert,
|
|
30
|
+
rsaPrivateKey,
|
|
31
|
+
apiMode,
|
|
32
|
+
options,
|
|
33
|
+
});
|
|
34
|
+
this._orgName = orgName;
|
|
35
|
+
this._oid = oid;
|
|
36
|
+
this._npi = npi;
|
|
37
|
+
this._homeCommunityId = homeCommunityId;
|
|
38
|
+
this._authGrantorReferenceOid = authGrantorReference;
|
|
39
|
+
}
|
|
40
|
+
get oid() {
|
|
41
|
+
return this._oid;
|
|
42
|
+
}
|
|
43
|
+
get npi() {
|
|
44
|
+
return this._npi;
|
|
45
|
+
}
|
|
46
|
+
get orgName() {
|
|
47
|
+
return this._orgName;
|
|
48
|
+
}
|
|
49
|
+
get homeCommunityId() {
|
|
50
|
+
return this._homeCommunityId;
|
|
51
|
+
}
|
|
52
|
+
//--------------------------------------------------------------------------------------------
|
|
53
|
+
// Patient Management
|
|
54
|
+
//--------------------------------------------------------------------------------------------
|
|
55
|
+
/**
|
|
56
|
+
* Register a new patient.
|
|
57
|
+
*
|
|
58
|
+
* @param patient The patient to register.
|
|
59
|
+
* @param options Optional parameters.
|
|
60
|
+
* @param options.meta Metadata about the request. Defaults to the data used to initialize the client.
|
|
61
|
+
* @returns The patient collection containing the patient in the first position.
|
|
62
|
+
*/
|
|
63
|
+
async createOrUpdatePatient(patient, options) {
|
|
64
|
+
const headers = this.buildQueryHeaders(options?.meta);
|
|
65
|
+
const url = buildPatientEndpoint(this.oid);
|
|
66
|
+
const normalizedPatient = normalizePatient(patient);
|
|
67
|
+
const resp = await this.executeWithRetriesOn500IfEnabled(() => this.api.post(url, normalizedPatient, { headers }), true);
|
|
68
|
+
const parsed = patient_1.patientResponseSchema.parse(resp.data);
|
|
69
|
+
const links = parsed.Patients[0].Links;
|
|
70
|
+
return {
|
|
71
|
+
Links: links,
|
|
72
|
+
status: parsed.status ?? undefined,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async getPatient(idOrParams, options) {
|
|
76
|
+
let patientId;
|
|
77
|
+
if (typeof idOrParams !== "string") {
|
|
78
|
+
patientId = idOrParams.id;
|
|
79
|
+
const { assignAuthority, assignAuthorityType } = idOrParams;
|
|
80
|
+
patientId = (0, util_1.encodeCwPatientId)({
|
|
81
|
+
patientId,
|
|
82
|
+
assignAuthority,
|
|
83
|
+
assignAuthorityType,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
if (!idOrParams) {
|
|
88
|
+
throw new Error("Programming error: 'id' is required when providing separate parameters");
|
|
89
|
+
}
|
|
90
|
+
patientId = idOrParams;
|
|
91
|
+
}
|
|
92
|
+
const headers = this.buildQueryHeaders(options?.meta);
|
|
93
|
+
const url = buildPatientEndpoint(this.oid, patientId);
|
|
94
|
+
const resp = await this.executeWithRetriesOn500IfEnabled(() => this.api.get(url, { headers }));
|
|
95
|
+
const parsed = patient_1.patientResponseSchema.parse(resp.data);
|
|
96
|
+
if (parsed.Patients.length > 1) {
|
|
97
|
+
throw new shared_1.MetriportError("Multiple patients found for the given ID", undefined, {
|
|
98
|
+
patientId,
|
|
99
|
+
count: parsed.Patients.length,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return parsed.Patients[0];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Deletes a patient.
|
|
106
|
+
*
|
|
107
|
+
* @param patientId The patient to be deleted.
|
|
108
|
+
* @param options Optional parameters.
|
|
109
|
+
* @param options.meta Metadata about the request. Defaults to the data used to initialize the client.
|
|
110
|
+
*/
|
|
111
|
+
async deletePatient(patientId, options) {
|
|
112
|
+
const headers = this.buildQueryHeaders(options?.meta);
|
|
113
|
+
const url = buildPatientEndpoint(this.oid, patientId);
|
|
114
|
+
await this.executeWithRetriesOn500IfEnabled(() => this.api.delete(url, { headers }));
|
|
115
|
+
}
|
|
116
|
+
//--------------------------------------------------------------------------------------------
|
|
117
|
+
// Link Management
|
|
118
|
+
//--------------------------------------------------------------------------------------------
|
|
119
|
+
/**
|
|
120
|
+
* Merges two patients into one.
|
|
121
|
+
*
|
|
122
|
+
* @param nonSurvivingPatientId The local Patient ID of the non-surviving Patient Record (This patient gets replaced).
|
|
123
|
+
* @param survivingPatientId The patient ID of the patient that will replace the non surviving patient
|
|
124
|
+
* @param options Optional parameters.
|
|
125
|
+
* @param options.meta Metadata about the request. Defaults to the data used to initialize the client.
|
|
126
|
+
* @returns The patient merge response.
|
|
127
|
+
*/
|
|
128
|
+
async mergePatients({ nonSurvivingPatientId, survivingPatientId, }, options) {
|
|
129
|
+
const headers = this.buildQueryHeaders(options?.meta);
|
|
130
|
+
const url = buildPatientMergeEndpoint(this.oid, nonSurvivingPatientId);
|
|
131
|
+
const resp = await this.executeWithRetriesOn500IfEnabled(() => this.api.put(url, {
|
|
132
|
+
link: {
|
|
133
|
+
other: {
|
|
134
|
+
reference: `Patient/${survivingPatientId}`,
|
|
135
|
+
},
|
|
136
|
+
type: "replaced-by",
|
|
137
|
+
},
|
|
138
|
+
}, {
|
|
139
|
+
headers,
|
|
140
|
+
}));
|
|
141
|
+
return patient_1.statusResponseSchema.parse(resp.data);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Returns the links the patient has with other patients.
|
|
145
|
+
*
|
|
146
|
+
* An Edge System can search and request Patient Links by a local patient identifier. The result of the query will
|
|
147
|
+
* include local and remote patient's links that are autolinked by the rules engine or manually linked.
|
|
148
|
+
*
|
|
149
|
+
* The links returned are confirmed links of LOLA 2 or higher.
|
|
150
|
+
*
|
|
151
|
+
* Note, there is no retry logic included for this method, since it's best used with custom logic.
|
|
152
|
+
*
|
|
153
|
+
* @param meta Metadata about the request.
|
|
154
|
+
* @param patientId The person id to be link to a patient.
|
|
155
|
+
* @returns Response with list of links to Patients
|
|
156
|
+
*/
|
|
157
|
+
async getPatientLinksByPatientId(patientId, options) {
|
|
158
|
+
const headers = this.buildQueryHeaders(options?.meta);
|
|
159
|
+
const url = buildPatientLinkEndpoint(this.oid, patientId);
|
|
160
|
+
try {
|
|
161
|
+
const resp = await this.api.get(url, { headers });
|
|
162
|
+
return patient_1.patientExistingLinksSchema.parse(resp.data);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
throw this.getDescriptiveError(error, "Failed to get patient links by patient id");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Returns the potential links the patient has. Those are links the CommonWell MPI was not
|
|
170
|
+
* confident enough to confirm (LOLA2+), but could potentially be a match in case some of
|
|
171
|
+
* the patient's demographics have changed.
|
|
172
|
+
*
|
|
173
|
+
* An Edge System can request probable patient links by a local patient identifier. MPI will identify probable
|
|
174
|
+
* patients based on MPI match scores that are within a certain threshold range but are not auto matched.
|
|
175
|
+
* Probable matches are determined by probabilistic algorithms. This will enable Edge Systems to confirm
|
|
176
|
+
* additional patient matches across other organizations. On confirmation, the patient will be matched to a
|
|
177
|
+
* person. Probable links need to be manually linked to the local patient before documents can be requested.
|
|
178
|
+
*
|
|
179
|
+
* The links returned are LOLA 1.
|
|
180
|
+
*
|
|
181
|
+
* Note, there is no retry logic included for this method, since it's best used with custom logic.
|
|
182
|
+
*
|
|
183
|
+
* @param patientId The ID of the patient to get probable links for.
|
|
184
|
+
* @returns Response with list of probable (LOLA1) links to other Patients
|
|
185
|
+
*/
|
|
186
|
+
async getProbableLinksById(patientId, options) {
|
|
187
|
+
const headers = this.buildQueryHeaders(options?.meta);
|
|
188
|
+
const url = buildProbableLinkEndpoint(this.oid, patientId);
|
|
189
|
+
try {
|
|
190
|
+
const resp = await this.api.get(url, { headers });
|
|
191
|
+
return patient_1.patientProbableLinksRespSchema.parse(resp.data);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
throw this.getDescriptiveError(error, "Failed to get probable links by patient id");
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Returns the potential links for a patient with the provided demographics.
|
|
199
|
+
*
|
|
200
|
+
* An Edge System can request probable patient links by a local patient identifier. MPI will identify probable
|
|
201
|
+
* patients based on MPI match scores that are within a certain threshold range but are not auto matched.
|
|
202
|
+
* Probable matches are determined by probabilistic algorithms. This will enable Edge Systems to confirm
|
|
203
|
+
* additional patient matches across other organizations. On confirmation, the patient will be matched to a
|
|
204
|
+
* person. Probable links need to be manually linked to the local patient before documents can be requested.
|
|
205
|
+
*
|
|
206
|
+
* The links returned are LOLA 1.
|
|
207
|
+
*
|
|
208
|
+
* @param firstName The first name of the patient.
|
|
209
|
+
* @param lastName The last name of the patient.
|
|
210
|
+
* @param dob The date of birth of the patient.
|
|
211
|
+
* @param gender The gender of the patient.
|
|
212
|
+
* @param zip The zip code of the patient.
|
|
213
|
+
* @param options Optional parameters.
|
|
214
|
+
* @param options.meta Metadata about the request. Defaults to the data used to initialize the client.
|
|
215
|
+
* @returns Response with list of probable (LOLA1) links to existing Patients
|
|
216
|
+
*/
|
|
217
|
+
async getProbableLinksByDemographics({ firstName, lastName, dob, gender, zip, }, options) {
|
|
218
|
+
const headers = this.buildQueryHeaders(options?.meta);
|
|
219
|
+
const params = new URLSearchParams();
|
|
220
|
+
params.append("fname", firstName);
|
|
221
|
+
params.append("lname", lastName);
|
|
222
|
+
params.append("dob", dob);
|
|
223
|
+
params.append("gender", gender);
|
|
224
|
+
params.append("zip", zip);
|
|
225
|
+
const url = buildProbableLinkEndpoint(this.oid);
|
|
226
|
+
const resp = await this.executeWithRetriesOn500IfEnabled(() => this.api.get(url + `?${params.toString()}`, { headers }));
|
|
227
|
+
return patient_1.patientProbableLinksRespSchema.parse(resp.data);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* An Edge System reviews the probable matches. An Edge System can link remote patient(s) if these patients are
|
|
231
|
+
* the same as local patient.
|
|
232
|
+
*
|
|
233
|
+
* Use getPatientLinksByPatientId to get the Link URL.
|
|
234
|
+
*
|
|
235
|
+
* Remote patients will be linked with the local patient and now considered as a manual confirmed LOLA 2 link.
|
|
236
|
+
*
|
|
237
|
+
* @param urlToLinkPatients The URL to link the patients.
|
|
238
|
+
* @param options Optional parameters.
|
|
239
|
+
* @param options.meta Metadata about the request. Defaults to the data used to initialize the client.
|
|
240
|
+
*/
|
|
241
|
+
async linkPatients(urlToLinkPatients, options) {
|
|
242
|
+
const headers = this.buildQueryHeaders(options?.meta);
|
|
243
|
+
const resp = await this.executeWithRetriesOn500IfEnabled(() => this.api.put(urlToLinkPatients, {}, { headers }));
|
|
244
|
+
return patient_1.statusResponseSchema.parse(resp.data);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* After reviewing remote patient links for their local patient, an Edge System can unlink a remote patient that
|
|
248
|
+
* does not belong in the Patient collection and remove the existing LOLA2 network link.
|
|
249
|
+
*
|
|
250
|
+
* Use getPatientLinksByPatientId to get the Unlink URL.
|
|
251
|
+
*
|
|
252
|
+
* Patient Links that are manually unlinked will no longer be autolinked to the same patient in the future by the
|
|
253
|
+
* matching algorithm.
|
|
254
|
+
*
|
|
255
|
+
* @param urlToUnlinkPatients The URL to unlink the patients.
|
|
256
|
+
* @param options Optional parameters.
|
|
257
|
+
* @param options.meta Metadata about the request. Defaults to the data used to initialize the client.
|
|
258
|
+
*/
|
|
259
|
+
async unlinkPatients(urlToUnlinkPatients, options) {
|
|
260
|
+
const headers = this.buildQueryHeaders(options?.meta);
|
|
261
|
+
const resp = await this.executeWithRetriesOn500IfEnabled(() => this.api.put(urlToUnlinkPatients, {}, { headers }));
|
|
262
|
+
return patient_1.statusResponseSchema.parse(resp.data);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Edge Systems can perform a “reset” to a Patient which will detach all LOLA 2 links to the specified Patient. This
|
|
266
|
+
* patient may be linked to the same collection of Patients (Person) again in the future.
|
|
267
|
+
*
|
|
268
|
+
* Use getPatientLinksByPatientId to get the ResetLink URL.
|
|
269
|
+
*
|
|
270
|
+
* @param urlToResetPatientLinks The URL to reset the patient links.
|
|
271
|
+
* @param options Optional parameters.
|
|
272
|
+
* @param options.meta Metadata about the request. Defaults to the data used to initialize the client.
|
|
273
|
+
*/
|
|
274
|
+
async resetPatientLinks(urlToResetPatientLinks, options) {
|
|
275
|
+
const headers = this.buildQueryHeaders(options?.meta);
|
|
276
|
+
const resp = await this.executeWithRetriesOn500IfEnabled(() => this.api.put(urlToResetPatientLinks, {}, { headers }));
|
|
277
|
+
return patient_1.statusResponseSchema.parse(resp.data);
|
|
278
|
+
}
|
|
279
|
+
//--------------------------------------------------------------------------------------------
|
|
280
|
+
// Document Management
|
|
281
|
+
//--------------------------------------------------------------------------------------------
|
|
282
|
+
async queryDocumentsInternal(patientId, options
|
|
283
|
+
//eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
284
|
+
) {
|
|
285
|
+
const { meta, ...params } = options ?? {};
|
|
286
|
+
const headers = this.buildQueryHeaders(meta);
|
|
287
|
+
const actualParams = {
|
|
288
|
+
...params,
|
|
289
|
+
status: options?.status ?? "current",
|
|
290
|
+
};
|
|
291
|
+
const subjectId = (0, util_1.encodePatientIdForDocumentExchange)(patientId);
|
|
292
|
+
if (!subjectId) {
|
|
293
|
+
throw new commonwell_error_1.CommonwellError(`Could not determine subject ID for document query`, undefined, {
|
|
294
|
+
patientId,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
const url = buildDocumentQueryUrl(subjectId, actualParams);
|
|
298
|
+
const response = await this.executeWithRetriesOn500IfEnabled(() => this.api.get(url, { headers }));
|
|
299
|
+
return response.data;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Queries a patient's Documents. Returns only documents.
|
|
303
|
+
*
|
|
304
|
+
* @param patientId The patient's ID.
|
|
305
|
+
* @param options Query parameters and query parameters.
|
|
306
|
+
* @param options.status The status of the document. Defaults to `current`, even if a param is
|
|
307
|
+
* provided without status.
|
|
308
|
+
* @param options.meta Metadata about the request. Defaults to the data used to initialize the client.
|
|
309
|
+
* @returns an array of DocumentReference FHIR resources.
|
|
310
|
+
*/
|
|
311
|
+
async queryDocuments(patientId, options) {
|
|
312
|
+
const response = await this.queryDocumentsInternal(patientId, options);
|
|
313
|
+
const entry = document_1.documentQueryResponseSchema.parse(response).entry;
|
|
314
|
+
return entry?.flatMap(entry => entry.resource ?? []) ?? [];
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Queries a patient's Documents. Returns documents and errors from the fanout to other gateways.
|
|
318
|
+
*
|
|
319
|
+
* @param patientId The patient's ID.
|
|
320
|
+
* @param options Query parameters and query parameters.
|
|
321
|
+
* @param options.status The status of the document. Defaults to `current`, even if a param is
|
|
322
|
+
* provided without status.
|
|
323
|
+
* @param options.meta Metadata about the request. Defaults to the data used to initialize the client.
|
|
324
|
+
* @returns a Bundle containing DocumentReferences of a patient's available DocumentReferences
|
|
325
|
+
* and/or OperationOutcomes denoting problems with the query.
|
|
326
|
+
*/
|
|
327
|
+
async queryDocumentsFull(patientId, options) {
|
|
328
|
+
const response = await this.queryDocumentsInternal(patientId, options);
|
|
329
|
+
return document_1.documentQueryFullResponseSchema.parse(response);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Retrieve a Document and send its bytes to the outputStream.
|
|
333
|
+
*
|
|
334
|
+
* @param inputUrl The URL of the file to be downloaded. Obtained from a DocumentReference that
|
|
335
|
+
* was retrieved from a previous call to `queryDocuments`.
|
|
336
|
+
* @param outputStream The stream to receive the downloaded file's bytes.
|
|
337
|
+
* @param options Optional parameters.
|
|
338
|
+
* @param options.meta Metadata about the request. Defaults to the data used to initialize the client.
|
|
339
|
+
* @returns The content type and size of the downloaded file.
|
|
340
|
+
*/
|
|
341
|
+
async retrieveDocument(inputUrl, outputStream, options) {
|
|
342
|
+
const headers = this.buildQueryHeaders(options?.meta);
|
|
343
|
+
try {
|
|
344
|
+
const binary = await this.executeWithRetriesOn500IfEnabled(() => (0, fileDownload_1.downloadFileInMemory)({
|
|
345
|
+
url: inputUrl,
|
|
346
|
+
client: this.api,
|
|
347
|
+
responseType: "json",
|
|
348
|
+
headers,
|
|
349
|
+
}));
|
|
350
|
+
if (typeof binary === "string") {
|
|
351
|
+
try {
|
|
352
|
+
const dataBuffer = (0, shared_1.base64ToBuffer)(binary);
|
|
353
|
+
outputStream.write(dataBuffer);
|
|
354
|
+
outputStream.end();
|
|
355
|
+
return { contentType: "application/xml", size: dataBuffer.byteLength };
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
// Continue with the flow...
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const errorMessage = "Invalid binary contents";
|
|
362
|
+
if (!("resourceType" in binary)) {
|
|
363
|
+
throw new commonwell_error_1.CommonwellError(errorMessage, undefined, { reason: "Missing resourceType" });
|
|
364
|
+
}
|
|
365
|
+
const resourceType = binary.resourceType;
|
|
366
|
+
if (typeof resourceType !== "string" || resourceType !== "Binary") {
|
|
367
|
+
throw new commonwell_error_1.CommonwellError(errorMessage, undefined, { reason: "Invalid resourceType" });
|
|
368
|
+
}
|
|
369
|
+
const contentType = binary.contentType;
|
|
370
|
+
if (!contentType || typeof contentType !== "string") {
|
|
371
|
+
throw new commonwell_error_1.CommonwellError(errorMessage, undefined, {
|
|
372
|
+
reason: "Missing or invalid contentType",
|
|
373
|
+
contentType,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
const data = binary.data;
|
|
377
|
+
if (!data) {
|
|
378
|
+
throw new commonwell_error_1.CommonwellError(errorMessage, undefined, {
|
|
379
|
+
reason: "Missing data",
|
|
380
|
+
contentType,
|
|
381
|
+
resourceType,
|
|
382
|
+
properties: typeof binary === "object" && binary != null
|
|
383
|
+
? Object.keys(binary).join(", ")
|
|
384
|
+
: "not-an-object",
|
|
385
|
+
inputUrl,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
const dataBuffer = (0, shared_1.base64ToBuffer)(data);
|
|
389
|
+
outputStream.write(dataBuffer);
|
|
390
|
+
return { contentType, size: dataBuffer.byteLength };
|
|
391
|
+
}
|
|
392
|
+
catch (error) {
|
|
393
|
+
throw this.getDescriptiveError(error, "Failed to download document");
|
|
394
|
+
}
|
|
395
|
+
finally {
|
|
396
|
+
outputStream.end();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
//--------------------------------------------------------------------------------------------
|
|
400
|
+
// Private methods
|
|
401
|
+
//--------------------------------------------------------------------------------------------
|
|
402
|
+
buildQueryHeaders(metaParam) {
|
|
403
|
+
const meta = metaParam ?? this.buildOrganizationQueryMeta();
|
|
404
|
+
const jwt = (0, make_jwt_1.makeJwt)({
|
|
405
|
+
rsaPrivateKey: this.rsaPrivateKey,
|
|
406
|
+
role: meta.role,
|
|
407
|
+
subjectId: meta.subjectId,
|
|
408
|
+
orgName: this.orgName,
|
|
409
|
+
oid: this.oid,
|
|
410
|
+
purposeOfUse: meta.purposeOfUse,
|
|
411
|
+
npi: meta.npi,
|
|
412
|
+
authGrantorReference: meta.authGrantorReference,
|
|
413
|
+
});
|
|
414
|
+
return { Authorization: `Bearer ${jwt}` };
|
|
415
|
+
}
|
|
416
|
+
buildOrganizationQueryMeta() {
|
|
417
|
+
const base = (0, util_1.buildBaseQueryMeta)(this.orgName);
|
|
418
|
+
return {
|
|
419
|
+
...base,
|
|
420
|
+
npi: this.npi,
|
|
421
|
+
...(this._authGrantorReferenceOid
|
|
422
|
+
? { authGrantorReference: this._authGrantorReferenceOid }
|
|
423
|
+
: {}),
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
getDescriptiveError(error, title) {
|
|
427
|
+
if ((0, axios_1.isAxiosError)(error)) {
|
|
428
|
+
const status = error.response?.status;
|
|
429
|
+
const data = isOperationOutcome(error.response?.data)
|
|
430
|
+
? getPrimaryIssueDetails(error.response?.data.issue)
|
|
431
|
+
: undefined;
|
|
432
|
+
const cwReference = this.lastTransactionId;
|
|
433
|
+
const additionalInfo = { status, cwReference, ...data };
|
|
434
|
+
if (status === http_status_1.default.BAD_REQUEST) {
|
|
435
|
+
return new shared_1.BadRequestError(title, error, additionalInfo);
|
|
436
|
+
}
|
|
437
|
+
if (status === http_status_1.default.NOT_FOUND) {
|
|
438
|
+
return new shared_1.NotFoundError(title, error, additionalInfo);
|
|
439
|
+
}
|
|
440
|
+
return new shared_1.MetriportError(title, error, additionalInfo);
|
|
441
|
+
}
|
|
442
|
+
return error;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
exports.CommonWell = CommonWell;
|
|
446
|
+
function isOperationOutcome(data) {
|
|
447
|
+
return (typeof data === "object" &&
|
|
448
|
+
data != null &&
|
|
449
|
+
"resourceType" in data &&
|
|
450
|
+
data.resourceType === "OperationOutcome");
|
|
451
|
+
}
|
|
452
|
+
function getPrimaryIssueDetails(issue) {
|
|
453
|
+
const primaryIssue = issue?.[0];
|
|
454
|
+
if (!primaryIssue)
|
|
455
|
+
return undefined;
|
|
456
|
+
return {
|
|
457
|
+
code: primaryIssue.code,
|
|
458
|
+
severity: primaryIssue.severity ?? "error",
|
|
459
|
+
diagnostics: primaryIssue.diagnostics ?? primaryIssue.details?.text ?? "Unknown error",
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
function buildOrgEndpoint(orgId) {
|
|
463
|
+
return `/v2/org/${orgId}`;
|
|
464
|
+
}
|
|
465
|
+
function buildPatientEndpoint(orgId, patientId) {
|
|
466
|
+
return `${buildOrgEndpoint(orgId)}/Patient${patientId ? `/${patientId}` : ""}`;
|
|
467
|
+
}
|
|
468
|
+
function buildPatientLinkEndpoint(orgId, patientId) {
|
|
469
|
+
return `${buildOrgEndpoint(orgId)}/PatientLink/${patientId}`;
|
|
470
|
+
}
|
|
471
|
+
function buildProbableLinkEndpoint(orgId, patientId) {
|
|
472
|
+
return `${buildOrgEndpoint(orgId)}/ProbableLink${patientId ? `/${patientId}` : ""}`;
|
|
473
|
+
}
|
|
474
|
+
function buildPatientMergeEndpoint(orgId, nonSurvivingPatientId) {
|
|
475
|
+
return `${buildPatientEndpoint(orgId, nonSurvivingPatientId)}/Merge`;
|
|
476
|
+
}
|
|
477
|
+
function buildDocumentQueryUrl(patientId, params) {
|
|
478
|
+
const urlParams = new URLSearchParams();
|
|
479
|
+
urlParams.append("patient.identifier", patientId);
|
|
480
|
+
if (params.status)
|
|
481
|
+
urlParams.append("status", params.status);
|
|
482
|
+
if (params.author?.given)
|
|
483
|
+
urlParams.append("author.given", params.author.given);
|
|
484
|
+
if (params.author?.family)
|
|
485
|
+
urlParams.append("author.family", params.author.family);
|
|
486
|
+
if (params.period?.start)
|
|
487
|
+
urlParams.append("period.start", params.period.start);
|
|
488
|
+
if (params.period?.end)
|
|
489
|
+
urlParams.append("period.end", params.period.end);
|
|
490
|
+
if (params.date?.start)
|
|
491
|
+
urlParams.append("date.start", params.date.start);
|
|
492
|
+
if (params.date?.end)
|
|
493
|
+
urlParams.append("date.end", params.date.end);
|
|
494
|
+
return `/v2/R4/DocumentReference?${urlParams.toString()}`;
|
|
495
|
+
}
|
|
496
|
+
function normalizePatient(patient) {
|
|
497
|
+
return {
|
|
498
|
+
...patient,
|
|
499
|
+
...(patient.birthDate ? { birthDate: (0, date_1.normalizeDatetime)(patient.birthDate) } : {}),
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
//# sourceMappingURL=commonwell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonwell.js","sourceRoot":"","sources":["../../src/client/commonwell.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAmG;AACnG,iCAAqC;AACrC,8DAAqC;AAErC,iEAA6D;AAC7D,yDAA8D;AAC9D,iDAA6C;AAC7C,yCAIwB;AACxB,yCAAmD;AAEnD,iDAM4B;AAC5B,+CAW2B;AAU3B,uDAAmD;AAEnD;;;GAGG;AACH,MAAa,UAAW,SAAQ,gCAAc;IAO5C;;;OAGG;IACH,YAAY,EACV,OAAO,EACP,aAAa,EACb,OAAO,EACP,GAAG,EACH,GAAG,EACH,eAAe,EACf,OAAO,EACP,uBAAuB,EAAE,oBAAoB,EAC7C,OAAO,GAAG,EAAE,GAuBb;QACC,KAAK,CAAC;YACJ,OAAO;YACP,aAAa;YACb,OAAO;YACP,OAAO;SACR,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,IAA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e,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnF,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK;QAAE,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG;QAAE,SAAS,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1E,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK;QAAE,SAAS,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1E,IAAI,MAAM,CAAC,IAAI,EAAE,GAAG;QAAE,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpE,OAAO,4BAA4B,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC;AAC5D,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAgB;IACxC,OAAO;QACL,GAAG,OAAO;QACV,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAA,wBAAiB,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.test.d.ts","sourceRoot":"","sources":["../../../src/common/__tests__/util.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
describe("util", () => {
|
|
6
|
+
describe("decodeCwPatientId", () => {
|
|
7
|
+
it("returns decoded patient id with all components when valid", async () => {
|
|
8
|
+
const res = (0, util_1.decodeCwPatientIdV2)("601^^^&2.16.840.1.113883.3.2611.9.99.101.1&ISO");
|
|
9
|
+
expect(res).toBeTruthy();
|
|
10
|
+
expect(res.value).toBe("601");
|
|
11
|
+
expect(res.assignAuthority).toBe("2.16.840.1.113883.3.2611.9.99.101.1");
|
|
12
|
+
expect(res.assignAuthorityType).toBe("ISO");
|
|
13
|
+
});
|
|
14
|
+
it("returns value and assignAuthority when assignAuthType is not provided", async () => {
|
|
15
|
+
const res = (0, util_1.decodeCwPatientIdV2)("601^^^&2.16.840.1.113883.3.2611.9.99.101.1");
|
|
16
|
+
expect(res).toBeTruthy();
|
|
17
|
+
expect(res.value).toBe("601");
|
|
18
|
+
expect(res.assignAuthority).toBe("2.16.840.1.113883.3.2611.9.99.101.1");
|
|
19
|
+
expect(res.assignAuthorityType).toBeUndefined();
|
|
20
|
+
});
|
|
21
|
+
it("doesnt return value when assignAuthority is not provided", async () => {
|
|
22
|
+
const res = (0, util_1.decodeCwPatientIdV2)("601^^^&&ISO");
|
|
23
|
+
expect(res).toBeTruthy();
|
|
24
|
+
expect(res.value).toBeUndefined();
|
|
25
|
+
expect(res.assignAuthority).toBeUndefined();
|
|
26
|
+
expect(res.assignAuthorityType).toBeUndefined();
|
|
27
|
+
});
|
|
28
|
+
it("doesnt return value when assignAuthority and assignAuthType are not provided", async () => {
|
|
29
|
+
const res = (0, util_1.decodeCwPatientIdV2)("601^^^");
|
|
30
|
+
expect(res).toBeTruthy();
|
|
31
|
+
expect(res.value).toBeUndefined();
|
|
32
|
+
expect(res.assignAuthority).toBeUndefined();
|
|
33
|
+
expect(res.assignAuthorityType).toBeUndefined();
|
|
34
|
+
});
|
|
35
|
+
it("doesnt return assigningAuthority when value is not provided", async () => {
|
|
36
|
+
const res = (0, util_1.decodeCwPatientIdV2)("^^^&2.16.840.1.113883.3.2611.9.99.101.1&ISO");
|
|
37
|
+
expect(res).toBeTruthy();
|
|
38
|
+
expect(res.value).toBeUndefined();
|
|
39
|
+
expect(res.assignAuthority).toBeUndefined();
|
|
40
|
+
expect(res.assignAuthorityType).toBeUndefined();
|
|
41
|
+
});
|
|
42
|
+
it("returns emtpy object when value is empty string", async () => {
|
|
43
|
+
const res = (0, util_1.decodeCwPatientIdV2)("");
|
|
44
|
+
expect(res).toBeTruthy();
|
|
45
|
+
expect(res.value).toBeUndefined();
|
|
46
|
+
expect(res.assignAuthority).toBeUndefined();
|
|
47
|
+
expect(res.assignAuthorityType).toBeUndefined();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=util.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.test.js","sourceRoot":"","sources":["../../../src/common/__tests__/util.test.ts"],"names":[],"mappings":";;AAAA,yDAAyD;AACzD,kCAAmE;AAEnE,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACjC,EAAE,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;YACzE,MAAM,GAAG,GAAG,IAAA,0BAAiB,EAAC,gDAAgD,CAAC,CAAC;YAChF,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC9B,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;YACxE,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,uEAAuE,EAAE,KAAK,IAAI,EAAE;YACrF,MAAM,GAAG,GAAG,IAAA,0BAAiB,EAAC,4CAA4C,CAAC,CAAC;YAC5E,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;YACzB,M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CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC;YAClC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,aAAa,EAAE,CAAC;YAC5C,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,aAAa,EAAE,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;YAC/D,MAAM,GAAG,GAAG,IAAA,0BAAiB,EAAC,EAAE,CAAC,CAAC;YAClC,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC;YAClC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,aAAa,EAAE,CAAC;YAC5C,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,aAAa,EAAE,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-npi.test.d.ts","sourceRoot":"","sources":["../../../src/common/__tests__/validate-npi.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
4
|
+
const faker_1 = require("@faker-js/faker");
|
|
5
|
+
const validate_npi_1 = require("../validate-npi");
|
|
6
|
+
const validNPIs = [
|
|
7
|
+
"2974324529",
|
|
8
|
+
"1407080450",
|
|
9
|
+
"1053415810",
|
|
10
|
+
"1730961061",
|
|
11
|
+
"1427836782",
|
|
12
|
+
"1447933353",
|
|
13
|
+
"1013414374",
|
|
14
|
+
"1831886555",
|
|
15
|
+
"1649966466",
|
|
16
|
+
"1285017277",
|
|
17
|
+
"1093408148",
|
|
18
|
+
"1104925569",
|
|
19
|
+
];
|
|
20
|
+
describe("validateNPI", () => {
|
|
21
|
+
it("returns false when undefined", async () => {
|
|
22
|
+
const res = (0, validate_npi_1.validateNPI)(undefined);
|
|
23
|
+
expect(res).toBeFalsy();
|
|
24
|
+
});
|
|
25
|
+
it("returns false when empty string", async () => {
|
|
26
|
+
const npi = "";
|
|
27
|
+
const res = (0, validate_npi_1.validateNPI)(npi);
|
|
28
|
+
expect(res).toBeFalsy();
|
|
29
|
+
});
|
|
30
|
+
it("returns false when alpha string", async () => {
|
|
31
|
+
const npi = faker_1.faker.lorem.word();
|
|
32
|
+
const res = (0, validate_npi_1.validateNPI)(npi);
|
|
33
|
+
expect(res).toBeFalsy();
|
|
34
|
+
});
|
|
35
|
+
describe("returns true for valid NPI", () => {
|
|
36
|
+
for (const npi of validNPIs) {
|
|
37
|
+
it(` - npi ${npi}`, async () => {
|
|
38
|
+
const res = (0, validate_npi_1.validateNPI)(npi);
|
|
39
|
+
expect(res).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=validate-npi.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-npi.test.js","sourceRoot":"","sources":["../../../src/common/__tests__/validate-npi.test.ts"],"names":[],"mappings":";;AAAA,yDAAyD;AACzD,2CAAwC;AACxC,kDAA8C;AAE9C,MAAM,SAAS,GAAa;IAC1B,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;CACb,CAAC;AAEF,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,GAAG,GAAG,IAAA,0BAAW,EAAC,SAA8B,CAAC,CAAC;QACxD,MAAM,CA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