@metriport/commonwell-sdk 4.3.3 → 4.3.5
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 +20 -20
- package/README.md +40 -40
- package/lib/client/commonwell-api.d.ts +49 -49
- package/lib/client/commonwell-api.js +2 -2
- package/lib/client/commonwell.d.ts +425 -425
- package/lib/client/commonwell.js +739 -739
- package/lib/client/document.d.ts +7 -7
- package/lib/client/document.js +71 -71
- package/lib/common/commonwell-error.d.ts +12 -12
- package/lib/common/commonwell-error.js +34 -34
- package/lib/common/fileDownload.d.ts +11 -11
- package/lib/common/fileDownload.js +43 -43
- package/lib/common/make-jwt.d.ts +24 -24
- package/lib/common/make-jwt.js +90 -90
- package/lib/common/metriport-error.d.ts +4 -4
- package/lib/common/metriport-error.js +33 -33
- package/lib/common/util.d.ts +25 -25
- package/lib/common/util.js +70 -70
- package/lib/common/validate-npi.d.ts +9 -9
- package/lib/common/validate-npi.js +39 -39
- package/lib/index.d.ts +20 -20
- package/lib/index.js +54 -54
- package/lib/models/address.d.ts +50 -50
- package/lib/models/address.js +28 -28
- package/lib/models/certificates.d.ts +156 -156
- package/lib/models/certificates.js +26 -26
- package/lib/models/contact.d.ts +50 -50
- package/lib/models/contact.js +39 -39
- package/lib/models/demographics.d.ts +292 -292
- package/lib/models/demographics.js +34 -34
- package/lib/models/document.d.ts +4421 -4421
- package/lib/models/document.js +151 -151
- package/lib/models/enrollment-summary.d.ts +18 -18
- package/lib/models/enrollment-summary.js +14 -14
- package/lib/models/facility.d.ts +75 -75
- package/lib/models/facility.js +10 -10
- package/lib/models/human-name.d.ts +53 -53
- package/lib/models/human-name.js +37 -37
- package/lib/models/identifier.d.ts +79 -79
- package/lib/models/identifier.js +36 -36
- package/lib/models/iso-date.d.ts +3 -3
- package/lib/models/iso-date.js +6 -6
- package/lib/models/iso-datetime.d.ts +3 -3
- package/lib/models/iso-datetime.js +8 -8
- package/lib/models/link.d.ts +642 -642
- package/lib/models/link.js +50 -50
- package/lib/models/organization.d.ts +763 -763
- package/lib/models/organization.js +83 -83
- package/lib/models/patient.d.ts +3617 -3617
- package/lib/models/patient.js +49 -49
- package/lib/models/period.d.ts +12 -12
- package/lib/models/period.js +12 -12
- package/lib/models/person.d.ts +2440 -2440
- package/lib/models/person.js +39 -39
- package/lib/models/purpose-of-use.d.ts +29 -29
- package/lib/models/purpose-of-use.js +34 -34
- package/package.json +2 -2
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const httpStatus = __importStar(require("http-status"));
|
|
27
|
-
class MetriportError extends Error {
|
|
28
|
-
constructor(message, status = httpStatus.INTERNAL_SERVER_ERROR) {
|
|
29
|
-
super(message);
|
|
30
|
-
this.status = status;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.default = MetriportError;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const httpStatus = __importStar(require("http-status"));
|
|
27
|
+
class MetriportError extends Error {
|
|
28
|
+
constructor(message, status = httpStatus.INTERNAL_SERVER_ERROR) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.status = status;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = MetriportError;
|
|
34
34
|
//# sourceMappingURL=metriport-error.js.map
|
package/lib/common/util.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Demographics } from "../models/demographics";
|
|
2
|
-
import { StrongId } from "../models/identifier";
|
|
3
|
-
import { Organization } from "../models/organization";
|
|
4
|
-
import { Patient } from "../models/patient";
|
|
5
|
-
import { Person, PersonSearchResp } from "../models/person";
|
|
6
|
-
export declare function getId(object: Person | undefined): string | undefined;
|
|
7
|
-
export declare function getPersonIdFromSearchByPatientDemo(object: PersonSearchResp): string | undefined;
|
|
8
|
-
export declare function getIdTrailingSlash(object: Patient | Organization): string | undefined;
|
|
9
|
-
export declare function getPatientStrongIds(object: Patient): StrongId[] | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Converts the patient ID into subject ID, to be used during document query.
|
|
12
|
-
*
|
|
13
|
-
* @param {string} patientId - The patient's ID
|
|
14
|
-
* @returns {string} - The subject ID as defined by the specification: [system]|[code] where 'system'
|
|
15
|
-
* is the OID of the organization and 'code' is the first (numeric) part of the patient ID.
|
|
16
|
-
*
|
|
17
|
-
* @see {@link https://specification.commonwellalliance.org/services/data-broker/protocol-operations-data-broker#8781-find-documents|API spec}
|
|
18
|
-
*/
|
|
19
|
-
export declare function convertPatientIdToSubjectId(patientId: string): string | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Return the demographics for the results of a person search or a list of persons.
|
|
22
|
-
*
|
|
23
|
-
* @param personRelated structure containing person data, either an array of Person or a PersonSearchResp
|
|
24
|
-
*/
|
|
25
|
-
export declare function getDemographics(personRelated: Person[] | PersonSearchResp): Demographics[];
|
|
1
|
+
import { Demographics } from "../models/demographics";
|
|
2
|
+
import { StrongId } from "../models/identifier";
|
|
3
|
+
import { Organization } from "../models/organization";
|
|
4
|
+
import { Patient } from "../models/patient";
|
|
5
|
+
import { Person, PersonSearchResp } from "../models/person";
|
|
6
|
+
export declare function getId(object: Person | undefined): string | undefined;
|
|
7
|
+
export declare function getPersonIdFromSearchByPatientDemo(object: PersonSearchResp): string | undefined;
|
|
8
|
+
export declare function getIdTrailingSlash(object: Patient | Organization): string | undefined;
|
|
9
|
+
export declare function getPatientStrongIds(object: Patient): StrongId[] | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Converts the patient ID into subject ID, to be used during document query.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} patientId - The patient's ID
|
|
14
|
+
* @returns {string} - The subject ID as defined by the specification: [system]|[code] where 'system'
|
|
15
|
+
* is the OID of the organization and 'code' is the first (numeric) part of the patient ID.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link https://specification.commonwellalliance.org/services/data-broker/protocol-operations-data-broker#8781-find-documents|API spec}
|
|
18
|
+
*/
|
|
19
|
+
export declare function convertPatientIdToSubjectId(patientId: string): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Return the demographics for the results of a person search or a list of persons.
|
|
22
|
+
*
|
|
23
|
+
* @param personRelated structure containing person data, either an array of Person or a PersonSearchResp
|
|
24
|
+
*/
|
|
25
|
+
export declare function getDemographics(personRelated: Person[] | PersonSearchResp): Demographics[];
|
package/lib/common/util.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDemographics = exports.convertPatientIdToSubjectId = exports.getPatientStrongIds = exports.getIdTrailingSlash = exports.getPersonIdFromSearchByPatientDemo = exports.getId = void 0;
|
|
4
|
-
function getId(object) {
|
|
5
|
-
if (!object)
|
|
6
|
-
return undefined;
|
|
7
|
-
const url = object._links?.self?.href;
|
|
8
|
-
if (!url)
|
|
9
|
-
return undefined;
|
|
10
|
-
return url.substring(url.lastIndexOf("/") + 1);
|
|
11
|
-
}
|
|
12
|
-
exports.getId = getId;
|
|
13
|
-
function getPersonIdFromSearchByPatientDemo(object) {
|
|
14
|
-
if (!object._embedded || !object._embedded.person)
|
|
15
|
-
return undefined;
|
|
16
|
-
const embeddedPersons = object._embedded.person.filter(p => p.enrolled);
|
|
17
|
-
if (embeddedPersons.length < 1)
|
|
18
|
-
return undefined;
|
|
19
|
-
if (embeddedPersons.length > 1) {
|
|
20
|
-
console.log(`Found more than one person, using the first one: `, object);
|
|
21
|
-
}
|
|
22
|
-
const person = embeddedPersons[0];
|
|
23
|
-
return person && getId(person);
|
|
24
|
-
}
|
|
25
|
-
exports.getPersonIdFromSearchByPatientDemo = getPersonIdFromSearchByPatientDemo;
|
|
26
|
-
function getIdTrailingSlash(object) {
|
|
27
|
-
const url = object._links?.self?.href;
|
|
28
|
-
if (!url)
|
|
29
|
-
return undefined;
|
|
30
|
-
const removeTrailingSlash = url.substring(0, url.length - 1);
|
|
31
|
-
return removeTrailingSlash.substring(removeTrailingSlash.lastIndexOf("/") + 1);
|
|
32
|
-
}
|
|
33
|
-
exports.getIdTrailingSlash = getIdTrailingSlash;
|
|
34
|
-
function getPatientStrongIds(object) {
|
|
35
|
-
return object.identifier ?? undefined;
|
|
36
|
-
}
|
|
37
|
-
exports.getPatientStrongIds = getPatientStrongIds;
|
|
38
|
-
function buildPatiendIdToDocQuery(code, system) {
|
|
39
|
-
return `${system}|${code}`;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Converts the patient ID into subject ID, to be used during document query.
|
|
43
|
-
*
|
|
44
|
-
* @param {string} patientId - The patient's ID
|
|
45
|
-
* @returns {string} - The subject ID as defined by the specification: [system]|[code] where 'system'
|
|
46
|
-
* is the OID of the organization and 'code' is the first (numeric) part of the patient ID.
|
|
47
|
-
*
|
|
48
|
-
* @see {@link https://specification.commonwellalliance.org/services/data-broker/protocol-operations-data-broker#8781-find-documents|API spec}
|
|
49
|
-
*/
|
|
50
|
-
function convertPatientIdToSubjectId(patientId) {
|
|
51
|
-
const value = decodeURIComponent(decodeURI(patientId));
|
|
52
|
-
const regex = /(.+)\^\^\^(.+)/i;
|
|
53
|
-
const match = value.match(regex);
|
|
54
|
-
const code = match && match[1];
|
|
55
|
-
const system = match && match[2];
|
|
56
|
-
return code && system ? buildPatiendIdToDocQuery(code, system) : undefined;
|
|
57
|
-
}
|
|
58
|
-
exports.convertPatientIdToSubjectId = convertPatientIdToSubjectId;
|
|
59
|
-
/**
|
|
60
|
-
* Return the demographics for the results of a person search or a list of persons.
|
|
61
|
-
*
|
|
62
|
-
* @param personRelated structure containing person data, either an array of Person or a PersonSearchResp
|
|
63
|
-
*/
|
|
64
|
-
function getDemographics(personRelated) {
|
|
65
|
-
if (personRelated instanceof Array) {
|
|
66
|
-
return personRelated.map(p => p.details);
|
|
67
|
-
}
|
|
68
|
-
return personRelated._embedded.person.map(p => p.details);
|
|
69
|
-
}
|
|
70
|
-
exports.getDemographics = getDemographics;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDemographics = exports.convertPatientIdToSubjectId = exports.getPatientStrongIds = exports.getIdTrailingSlash = exports.getPersonIdFromSearchByPatientDemo = exports.getId = void 0;
|
|
4
|
+
function getId(object) {
|
|
5
|
+
if (!object)
|
|
6
|
+
return undefined;
|
|
7
|
+
const url = object._links?.self?.href;
|
|
8
|
+
if (!url)
|
|
9
|
+
return undefined;
|
|
10
|
+
return url.substring(url.lastIndexOf("/") + 1);
|
|
11
|
+
}
|
|
12
|
+
exports.getId = getId;
|
|
13
|
+
function getPersonIdFromSearchByPatientDemo(object) {
|
|
14
|
+
if (!object._embedded || !object._embedded.person)
|
|
15
|
+
return undefined;
|
|
16
|
+
const embeddedPersons = object._embedded.person.filter(p => p.enrolled);
|
|
17
|
+
if (embeddedPersons.length < 1)
|
|
18
|
+
return undefined;
|
|
19
|
+
if (embeddedPersons.length > 1) {
|
|
20
|
+
console.log(`Found more than one person, using the first one: `, object);
|
|
21
|
+
}
|
|
22
|
+
const person = embeddedPersons[0];
|
|
23
|
+
return person && getId(person);
|
|
24
|
+
}
|
|
25
|
+
exports.getPersonIdFromSearchByPatientDemo = getPersonIdFromSearchByPatientDemo;
|
|
26
|
+
function getIdTrailingSlash(object) {
|
|
27
|
+
const url = object._links?.self?.href;
|
|
28
|
+
if (!url)
|
|
29
|
+
return undefined;
|
|
30
|
+
const removeTrailingSlash = url.substring(0, url.length - 1);
|
|
31
|
+
return removeTrailingSlash.substring(removeTrailingSlash.lastIndexOf("/") + 1);
|
|
32
|
+
}
|
|
33
|
+
exports.getIdTrailingSlash = getIdTrailingSlash;
|
|
34
|
+
function getPatientStrongIds(object) {
|
|
35
|
+
return object.identifier ?? undefined;
|
|
36
|
+
}
|
|
37
|
+
exports.getPatientStrongIds = getPatientStrongIds;
|
|
38
|
+
function buildPatiendIdToDocQuery(code, system) {
|
|
39
|
+
return `${system}|${code}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Converts the patient ID into subject ID, to be used during document query.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} patientId - The patient's ID
|
|
45
|
+
* @returns {string} - The subject ID as defined by the specification: [system]|[code] where 'system'
|
|
46
|
+
* is the OID of the organization and 'code' is the first (numeric) part of the patient ID.
|
|
47
|
+
*
|
|
48
|
+
* @see {@link https://specification.commonwellalliance.org/services/data-broker/protocol-operations-data-broker#8781-find-documents|API spec}
|
|
49
|
+
*/
|
|
50
|
+
function convertPatientIdToSubjectId(patientId) {
|
|
51
|
+
const value = decodeURIComponent(decodeURI(patientId));
|
|
52
|
+
const regex = /(.+)\^\^\^(.+)/i;
|
|
53
|
+
const match = value.match(regex);
|
|
54
|
+
const code = match && match[1];
|
|
55
|
+
const system = match && match[2];
|
|
56
|
+
return code && system ? buildPatiendIdToDocQuery(code, system) : undefined;
|
|
57
|
+
}
|
|
58
|
+
exports.convertPatientIdToSubjectId = convertPatientIdToSubjectId;
|
|
59
|
+
/**
|
|
60
|
+
* Return the demographics for the results of a person search or a list of persons.
|
|
61
|
+
*
|
|
62
|
+
* @param personRelated structure containing person data, either an array of Person or a PersonSearchResp
|
|
63
|
+
*/
|
|
64
|
+
function getDemographics(personRelated) {
|
|
65
|
+
if (personRelated instanceof Array) {
|
|
66
|
+
return personRelated.map(p => p.details);
|
|
67
|
+
}
|
|
68
|
+
return personRelated._embedded.person.map(p => p.details);
|
|
69
|
+
}
|
|
70
|
+
exports.getDemographics = getDemographics;
|
|
71
71
|
//# sourceMappingURL=util.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the specified 10 digit NPI is valid as per ISO standard mod 10 Luhn algorithm.
|
|
3
|
-
*
|
|
4
|
-
* See: https://www.cms.gov/Regulations-and-Guidance/Administrative-Simplification/NationalProvIdentStand/Downloads/NPIcheckdigit.pdf
|
|
5
|
-
*
|
|
6
|
-
* @param npi The npi number to validate, must be 10 digits.
|
|
7
|
-
* @returns true if valid; false otherwise.
|
|
8
|
-
*/
|
|
9
|
-
export declare function validateNPI(npi: string): boolean;
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the specified 10 digit NPI is valid as per ISO standard mod 10 Luhn algorithm.
|
|
3
|
+
*
|
|
4
|
+
* See: https://www.cms.gov/Regulations-and-Guidance/Administrative-Simplification/NationalProvIdentStand/Downloads/NPIcheckdigit.pdf
|
|
5
|
+
*
|
|
6
|
+
* @param npi The npi number to validate, must be 10 digits.
|
|
7
|
+
* @returns true if valid; false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateNPI(npi: string): boolean;
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateNPI = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Checks if the specified 10 digit NPI is valid as per ISO standard mod 10 Luhn algorithm.
|
|
6
|
-
*
|
|
7
|
-
* See: https://www.cms.gov/Regulations-and-Guidance/Administrative-Simplification/NationalProvIdentStand/Downloads/NPIcheckdigit.pdf
|
|
8
|
-
*
|
|
9
|
-
* @param npi The npi number to validate, must be 10 digits.
|
|
10
|
-
* @returns true if valid; false otherwise.
|
|
11
|
-
*/
|
|
12
|
-
function validateNPI(npi) {
|
|
13
|
-
if (npi.length !== 10) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
const firstNPIDigit = parseInt(npi.charAt(0), 10);
|
|
17
|
-
if (firstNPIDigit !== 1 && firstNPIDigit !== 2) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
let sum = 0;
|
|
21
|
-
let shouldDouble = true;
|
|
22
|
-
for (let i = 0; i < npi.length - 1; i++) {
|
|
23
|
-
let digit = parseInt(npi.charAt(i), 10);
|
|
24
|
-
if (shouldDouble) {
|
|
25
|
-
digit *= 2;
|
|
26
|
-
if (digit > 9) {
|
|
27
|
-
digit -= 9;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
sum += digit;
|
|
31
|
-
shouldDouble = !shouldDouble;
|
|
32
|
-
}
|
|
33
|
-
// account for NPI prefix
|
|
34
|
-
sum += 24;
|
|
35
|
-
const checkDigit = 10 - (sum % 10);
|
|
36
|
-
const lastNPIDigit = parseInt(npi.charAt(npi.length - 1), 10);
|
|
37
|
-
return checkDigit === lastNPIDigit;
|
|
38
|
-
}
|
|
39
|
-
exports.validateNPI = validateNPI;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateNPI = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the specified 10 digit NPI is valid as per ISO standard mod 10 Luhn algorithm.
|
|
6
|
+
*
|
|
7
|
+
* See: https://www.cms.gov/Regulations-and-Guidance/Administrative-Simplification/NationalProvIdentStand/Downloads/NPIcheckdigit.pdf
|
|
8
|
+
*
|
|
9
|
+
* @param npi The npi number to validate, must be 10 digits.
|
|
10
|
+
* @returns true if valid; false otherwise.
|
|
11
|
+
*/
|
|
12
|
+
function validateNPI(npi) {
|
|
13
|
+
if (npi.length !== 10) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const firstNPIDigit = parseInt(npi.charAt(0), 10);
|
|
17
|
+
if (firstNPIDigit !== 1 && firstNPIDigit !== 2) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
let sum = 0;
|
|
21
|
+
let shouldDouble = true;
|
|
22
|
+
for (let i = 0; i < npi.length - 1; i++) {
|
|
23
|
+
let digit = parseInt(npi.charAt(i), 10);
|
|
24
|
+
if (shouldDouble) {
|
|
25
|
+
digit *= 2;
|
|
26
|
+
if (digit > 9) {
|
|
27
|
+
digit -= 9;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
sum += digit;
|
|
31
|
+
shouldDouble = !shouldDouble;
|
|
32
|
+
}
|
|
33
|
+
// account for NPI prefix
|
|
34
|
+
sum += 24;
|
|
35
|
+
const checkDigit = 10 - (sum % 10);
|
|
36
|
+
const lastNPIDigit = parseInt(npi.charAt(npi.length - 1), 10);
|
|
37
|
+
return checkDigit === lastNPIDigit;
|
|
38
|
+
}
|
|
39
|
+
exports.validateNPI = validateNPI;
|
|
40
40
|
//# sourceMappingURL=validate-npi.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export { APIMode, CommonWell, RequestMetadata } from "./client/commonwell";
|
|
2
|
-
export { CommonWellAPI } from "./client/commonwell-api";
|
|
3
|
-
export { CommonwellError } from "./common/commonwell-error";
|
|
4
|
-
export { downloadFile } from "./common/fileDownload";
|
|
5
|
-
export { makeJwt } from "./common/make-jwt";
|
|
6
|
-
export { getDemographics, getId, getIdTrailingSlash, getPersonIdFromSearchByPatientDemo, } from "./common/util";
|
|
7
|
-
export { Address, AddressUseCodes } from "./models/address";
|
|
8
|
-
export { CertificateParam, CertificatePurpose, CertificateResp } from "./models/certificates";
|
|
9
|
-
export { Contact, ContactSystemCodes, ContactUseCodes } from "./models/contact";
|
|
10
|
-
export { Demographics, GenderCodes } from "./models/demographics";
|
|
11
|
-
export * from "./models/document";
|
|
12
|
-
export { EnrollmentSummary } from "./models/enrollment-summary";
|
|
13
|
-
export { HumanName, NameUseCodes } from "./models/human-name";
|
|
14
|
-
export { Identifier, StrongId } from "./models/identifier";
|
|
15
|
-
export { isLOLA1, isLOLA2, isLOLA3, isLOLA4, LOLA, NetworkLink, PatientLinkProxy, } from "./models/link";
|
|
16
|
-
export { Organization, OrganizationList } from "./models/organization";
|
|
17
|
-
export { Patient, PatientLinkResp, PatientNetworkLinkResp, PatientSearchResp, } from "./models/patient";
|
|
18
|
-
export { PatientLink, PatientLinkSearchResp, Person, PersonSearchResp } from "./models/person";
|
|
19
|
-
export { PurposeOfUse } from "./models/purpose-of-use";
|
|
20
|
-
export { documentReferenceResourceType, operationOutcomeResourceType } from "./models/document";
|
|
1
|
+
export { APIMode, CommonWell, RequestMetadata } from "./client/commonwell";
|
|
2
|
+
export { CommonWellAPI } from "./client/commonwell-api";
|
|
3
|
+
export { CommonwellError } from "./common/commonwell-error";
|
|
4
|
+
export { downloadFile } from "./common/fileDownload";
|
|
5
|
+
export { makeJwt } from "./common/make-jwt";
|
|
6
|
+
export { getDemographics, getId, getIdTrailingSlash, getPersonIdFromSearchByPatientDemo, } from "./common/util";
|
|
7
|
+
export { Address, AddressUseCodes } from "./models/address";
|
|
8
|
+
export { CertificateParam, CertificatePurpose, CertificateResp } from "./models/certificates";
|
|
9
|
+
export { Contact, ContactSystemCodes, ContactUseCodes } from "./models/contact";
|
|
10
|
+
export { Demographics, GenderCodes } from "./models/demographics";
|
|
11
|
+
export * from "./models/document";
|
|
12
|
+
export { EnrollmentSummary } from "./models/enrollment-summary";
|
|
13
|
+
export { HumanName, NameUseCodes } from "./models/human-name";
|
|
14
|
+
export { Identifier, StrongId } from "./models/identifier";
|
|
15
|
+
export { isLOLA1, isLOLA2, isLOLA3, isLOLA4, LOLA, NetworkLink, PatientLinkProxy, } from "./models/link";
|
|
16
|
+
export { Organization, OrganizationList } from "./models/organization";
|
|
17
|
+
export { Patient, PatientLinkResp, PatientNetworkLinkResp, PatientSearchResp, } from "./models/patient";
|
|
18
|
+
export { PatientLink, PatientLinkSearchResp, Person, PersonSearchResp } from "./models/person";
|
|
19
|
+
export { PurposeOfUse } from "./models/purpose-of-use";
|
|
20
|
+
export { documentReferenceResourceType, operationOutcomeResourceType } from "./models/document";
|
package/lib/index.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.operationOutcomeResourceType = exports.documentReferenceResourceType = exports.PurposeOfUse = exports.LOLA = exports.isLOLA4 = exports.isLOLA3 = exports.isLOLA2 = exports.isLOLA1 = exports.NameUseCodes = exports.GenderCodes = exports.ContactUseCodes = exports.ContactSystemCodes = exports.CertificatePurpose = exports.AddressUseCodes = exports.getPersonIdFromSearchByPatientDemo = exports.getIdTrailingSlash = exports.getId = exports.getDemographics = exports.makeJwt = exports.downloadFile = exports.CommonwellError = exports.CommonWell = exports.APIMode = void 0;
|
|
18
|
-
var commonwell_1 = require("./client/commonwell");
|
|
19
|
-
Object.defineProperty(exports, "APIMode", { enumerable: true, get: function () { return commonwell_1.APIMode; } });
|
|
20
|
-
Object.defineProperty(exports, "CommonWell", { enumerable: true, get: function () { return commonwell_1.CommonWell; } });
|
|
21
|
-
var commonwell_error_1 = require("./common/commonwell-error");
|
|
22
|
-
Object.defineProperty(exports, "CommonwellError", { enumerable: true, get: function () { return commonwell_error_1.CommonwellError; } });
|
|
23
|
-
var fileDownload_1 = require("./common/fileDownload");
|
|
24
|
-
Object.defineProperty(exports, "downloadFile", { enumerable: true, get: function () { return fileDownload_1.downloadFile; } });
|
|
25
|
-
var make_jwt_1 = require("./common/make-jwt");
|
|
26
|
-
Object.defineProperty(exports, "makeJwt", { enumerable: true, get: function () { return make_jwt_1.makeJwt; } });
|
|
27
|
-
var util_1 = require("./common/util");
|
|
28
|
-
Object.defineProperty(exports, "getDemographics", { enumerable: true, get: function () { return util_1.getDemographics; } });
|
|
29
|
-
Object.defineProperty(exports, "getId", { enumerable: true, get: function () { return util_1.getId; } });
|
|
30
|
-
Object.defineProperty(exports, "getIdTrailingSlash", { enumerable: true, get: function () { return util_1.getIdTrailingSlash; } });
|
|
31
|
-
Object.defineProperty(exports, "getPersonIdFromSearchByPatientDemo", { enumerable: true, get: function () { return util_1.getPersonIdFromSearchByPatientDemo; } });
|
|
32
|
-
var address_1 = require("./models/address");
|
|
33
|
-
Object.defineProperty(exports, "AddressUseCodes", { enumerable: true, get: function () { return address_1.AddressUseCodes; } });
|
|
34
|
-
var certificates_1 = require("./models/certificates");
|
|
35
|
-
Object.defineProperty(exports, "CertificatePurpose", { enumerable: true, get: function () { return certificates_1.CertificatePurpose; } });
|
|
36
|
-
var contact_1 = require("./models/contact");
|
|
37
|
-
Object.defineProperty(exports, "ContactSystemCodes", { enumerable: true, get: function () { return contact_1.ContactSystemCodes; } });
|
|
38
|
-
Object.defineProperty(exports, "ContactUseCodes", { enumerable: true, get: function () { return contact_1.ContactUseCodes; } });
|
|
39
|
-
var demographics_1 = require("./models/demographics");
|
|
40
|
-
Object.defineProperty(exports, "GenderCodes", { enumerable: true, get: function () { return demographics_1.GenderCodes; } });
|
|
41
|
-
__exportStar(require("./models/document"), exports);
|
|
42
|
-
var human_name_1 = require("./models/human-name");
|
|
43
|
-
Object.defineProperty(exports, "NameUseCodes", { enumerable: true, get: function () { return human_name_1.NameUseCodes; } });
|
|
44
|
-
var link_1 = require("./models/link");
|
|
45
|
-
Object.defineProperty(exports, "isLOLA1", { enumerable: true, get: function () { return link_1.isLOLA1; } });
|
|
46
|
-
Object.defineProperty(exports, "isLOLA2", { enumerable: true, get: function () { return link_1.isLOLA2; } });
|
|
47
|
-
Object.defineProperty(exports, "isLOLA3", { enumerable: true, get: function () { return link_1.isLOLA3; } });
|
|
48
|
-
Object.defineProperty(exports, "isLOLA4", { enumerable: true, get: function () { return link_1.isLOLA4; } });
|
|
49
|
-
Object.defineProperty(exports, "LOLA", { enumerable: true, get: function () { return link_1.LOLA; } });
|
|
50
|
-
var purpose_of_use_1 = require("./models/purpose-of-use");
|
|
51
|
-
Object.defineProperty(exports, "PurposeOfUse", { enumerable: true, get: function () { return purpose_of_use_1.PurposeOfUse; } });
|
|
52
|
-
var document_1 = require("./models/document");
|
|
53
|
-
Object.defineProperty(exports, "documentReferenceResourceType", { enumerable: true, get: function () { return document_1.documentReferenceResourceType; } });
|
|
54
|
-
Object.defineProperty(exports, "operationOutcomeResourceType", { enumerable: true, get: function () { return document_1.operationOutcomeResourceType; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.operationOutcomeResourceType = exports.documentReferenceResourceType = exports.PurposeOfUse = exports.LOLA = exports.isLOLA4 = exports.isLOLA3 = exports.isLOLA2 = exports.isLOLA1 = exports.NameUseCodes = exports.GenderCodes = exports.ContactUseCodes = exports.ContactSystemCodes = exports.CertificatePurpose = exports.AddressUseCodes = exports.getPersonIdFromSearchByPatientDemo = exports.getIdTrailingSlash = exports.getId = exports.getDemographics = exports.makeJwt = exports.downloadFile = exports.CommonwellError = exports.CommonWell = exports.APIMode = void 0;
|
|
18
|
+
var commonwell_1 = require("./client/commonwell");
|
|
19
|
+
Object.defineProperty(exports, "APIMode", { enumerable: true, get: function () { return commonwell_1.APIMode; } });
|
|
20
|
+
Object.defineProperty(exports, "CommonWell", { enumerable: true, get: function () { return commonwell_1.CommonWell; } });
|
|
21
|
+
var commonwell_error_1 = require("./common/commonwell-error");
|
|
22
|
+
Object.defineProperty(exports, "CommonwellError", { enumerable: true, get: function () { return commonwell_error_1.CommonwellError; } });
|
|
23
|
+
var fileDownload_1 = require("./common/fileDownload");
|
|
24
|
+
Object.defineProperty(exports, "downloadFile", { enumerable: true, get: function () { return fileDownload_1.downloadFile; } });
|
|
25
|
+
var make_jwt_1 = require("./common/make-jwt");
|
|
26
|
+
Object.defineProperty(exports, "makeJwt", { enumerable: true, get: function () { return make_jwt_1.makeJwt; } });
|
|
27
|
+
var util_1 = require("./common/util");
|
|
28
|
+
Object.defineProperty(exports, "getDemographics", { enumerable: true, get: function () { return util_1.getDemographics; } });
|
|
29
|
+
Object.defineProperty(exports, "getId", { enumerable: true, get: function () { return util_1.getId; } });
|
|
30
|
+
Object.defineProperty(exports, "getIdTrailingSlash", { enumerable: true, get: function () { return util_1.getIdTrailingSlash; } });
|
|
31
|
+
Object.defineProperty(exports, "getPersonIdFromSearchByPatientDemo", { enumerable: true, get: function () { return util_1.getPersonIdFromSearchByPatientDemo; } });
|
|
32
|
+
var address_1 = require("./models/address");
|
|
33
|
+
Object.defineProperty(exports, "AddressUseCodes", { enumerable: true, get: function () { return address_1.AddressUseCodes; } });
|
|
34
|
+
var certificates_1 = require("./models/certificates");
|
|
35
|
+
Object.defineProperty(exports, "CertificatePurpose", { enumerable: true, get: function () { return certificates_1.CertificatePurpose; } });
|
|
36
|
+
var contact_1 = require("./models/contact");
|
|
37
|
+
Object.defineProperty(exports, "ContactSystemCodes", { enumerable: true, get: function () { return contact_1.ContactSystemCodes; } });
|
|
38
|
+
Object.defineProperty(exports, "ContactUseCodes", { enumerable: true, get: function () { return contact_1.ContactUseCodes; } });
|
|
39
|
+
var demographics_1 = require("./models/demographics");
|
|
40
|
+
Object.defineProperty(exports, "GenderCodes", { enumerable: true, get: function () { return demographics_1.GenderCodes; } });
|
|
41
|
+
__exportStar(require("./models/document"), exports);
|
|
42
|
+
var human_name_1 = require("./models/human-name");
|
|
43
|
+
Object.defineProperty(exports, "NameUseCodes", { enumerable: true, get: function () { return human_name_1.NameUseCodes; } });
|
|
44
|
+
var link_1 = require("./models/link");
|
|
45
|
+
Object.defineProperty(exports, "isLOLA1", { enumerable: true, get: function () { return link_1.isLOLA1; } });
|
|
46
|
+
Object.defineProperty(exports, "isLOLA2", { enumerable: true, get: function () { return link_1.isLOLA2; } });
|
|
47
|
+
Object.defineProperty(exports, "isLOLA3", { enumerable: true, get: function () { return link_1.isLOLA3; } });
|
|
48
|
+
Object.defineProperty(exports, "isLOLA4", { enumerable: true, get: function () { return link_1.isLOLA4; } });
|
|
49
|
+
Object.defineProperty(exports, "LOLA", { enumerable: true, get: function () { return link_1.LOLA; } });
|
|
50
|
+
var purpose_of_use_1 = require("./models/purpose-of-use");
|
|
51
|
+
Object.defineProperty(exports, "PurposeOfUse", { enumerable: true, get: function () { return purpose_of_use_1.PurposeOfUse; } });
|
|
52
|
+
var document_1 = require("./models/document");
|
|
53
|
+
Object.defineProperty(exports, "documentReferenceResourceType", { enumerable: true, get: function () { return document_1.documentReferenceResourceType; } });
|
|
54
|
+
Object.defineProperty(exports, "operationOutcomeResourceType", { enumerable: true, get: function () { return document_1.operationOutcomeResourceType; } });
|
|
55
55
|
//# sourceMappingURL=index.js.map
|
package/lib/models/address.d.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare enum AddressUseCodes {
|
|
3
|
-
home = "home",
|
|
4
|
-
work = "work",
|
|
5
|
-
temp = "temp",
|
|
6
|
-
old = "old",
|
|
7
|
-
unspecified = "unspecified"
|
|
8
|
-
}
|
|
9
|
-
export declare const addressUseCodesSchema: z.ZodEnum<[string, ...string[]]>;
|
|
10
|
-
export declare const addressSchema: z.ZodObject<{
|
|
11
|
-
use: z.ZodNullable<z.ZodOptional<z.ZodEnum<[string, ...string[]]>>>;
|
|
12
|
-
line: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
13
|
-
city: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
14
|
-
state: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
15
|
-
zip: z.ZodString;
|
|
16
|
-
country: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
17
|
-
period: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
18
|
-
start: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodString]>>;
|
|
19
|
-
end: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodString]>>;
|
|
20
|
-
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
start?: string | undefined;
|
|
22
|
-
end?: string | undefined;
|
|
23
|
-
}, {
|
|
24
|
-
start?: string | undefined;
|
|
25
|
-
end?: string | undefined;
|
|
26
|
-
}>>>;
|
|
27
|
-
}, "strip", z.ZodTypeAny, {
|
|
28
|
-
zip: string;
|
|
29
|
-
use?: string | null | undefined;
|
|
30
|
-
line?: string[] | null | undefined;
|
|
31
|
-
city?: string | null | undefined;
|
|
32
|
-
state?: string | null | undefined;
|
|
33
|
-
country?: string | null | undefined;
|
|
34
|
-
period?: {
|
|
35
|
-
start?: string | undefined;
|
|
36
|
-
end?: string | undefined;
|
|
37
|
-
} | null | undefined;
|
|
38
|
-
}, {
|
|
39
|
-
zip: string;
|
|
40
|
-
use?: string | null | undefined;
|
|
41
|
-
line?: string[] | null | undefined;
|
|
42
|
-
city?: string | null | undefined;
|
|
43
|
-
state?: string | null | undefined;
|
|
44
|
-
country?: string | null | undefined;
|
|
45
|
-
period?: {
|
|
46
|
-
start?: string | undefined;
|
|
47
|
-
end?: string | undefined;
|
|
48
|
-
} | null | undefined;
|
|
49
|
-
}>;
|
|
50
|
-
export type Address = z.infer<typeof addressSchema>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare enum AddressUseCodes {
|
|
3
|
+
home = "home",
|
|
4
|
+
work = "work",
|
|
5
|
+
temp = "temp",
|
|
6
|
+
old = "old",
|
|
7
|
+
unspecified = "unspecified"
|
|
8
|
+
}
|
|
9
|
+
export declare const addressUseCodesSchema: z.ZodEnum<[string, ...string[]]>;
|
|
10
|
+
export declare const addressSchema: z.ZodObject<{
|
|
11
|
+
use: z.ZodNullable<z.ZodOptional<z.ZodEnum<[string, ...string[]]>>>;
|
|
12
|
+
line: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
13
|
+
city: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
14
|
+
state: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
15
|
+
zip: z.ZodString;
|
|
16
|
+
country: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
17
|
+
period: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
18
|
+
start: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodString]>>;
|
|
19
|
+
end: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodString]>>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
start?: string | undefined;
|
|
22
|
+
end?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
start?: string | undefined;
|
|
25
|
+
end?: string | undefined;
|
|
26
|
+
}>>>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
zip: string;
|
|
29
|
+
use?: string | null | undefined;
|
|
30
|
+
line?: string[] | null | undefined;
|
|
31
|
+
city?: string | null | undefined;
|
|
32
|
+
state?: string | null | undefined;
|
|
33
|
+
country?: string | null | undefined;
|
|
34
|
+
period?: {
|
|
35
|
+
start?: string | undefined;
|
|
36
|
+
end?: string | undefined;
|
|
37
|
+
} | null | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
zip: string;
|
|
40
|
+
use?: string | null | undefined;
|
|
41
|
+
line?: string[] | null | undefined;
|
|
42
|
+
city?: string | null | undefined;
|
|
43
|
+
state?: string | null | undefined;
|
|
44
|
+
country?: string | null | undefined;
|
|
45
|
+
period?: {
|
|
46
|
+
start?: string | undefined;
|
|
47
|
+
end?: string | undefined;
|
|
48
|
+
} | null | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
export type Address = z.infer<typeof addressSchema>;
|