@metriport/shared 0.26.5 → 0.26.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/__tests__/date.test.js +43 -7
- package/dist/common/__tests__/date.test.js.map +1 -1
- package/dist/common/__tests__/title-case.test.js +5 -0
- package/dist/common/__tests__/title-case.test.js.map +1 -1
- package/dist/common/date.d.ts +2 -2
- package/dist/common/date.d.ts.map +1 -1
- package/dist/common/date.js +5 -3
- package/dist/common/date.js.map +1 -1
- package/dist/common/error.d.ts +1 -15
- package/dist/common/error.d.ts.map +1 -1
- package/dist/common/error.js +4 -33
- package/dist/common/error.js.map +1 -1
- package/dist/common/title-case.d.ts +1 -0
- package/dist/common/title-case.d.ts.map +1 -1
- package/dist/common/title-case.js +12 -2
- package/dist/common/title-case.js.map +1 -1
- package/dist/domain/address/__tests__/zip.test.js +82 -3
- package/dist/domain/address/__tests__/zip.test.js.map +1 -1
- package/dist/domain/address/state.d.ts +1 -0
- package/dist/domain/address/state.d.ts.map +1 -1
- package/dist/domain/address/state.js +54 -1
- package/dist/domain/address/state.js.map +1 -1
- package/dist/domain/address/zip.d.ts +4 -0
- package/dist/domain/address/zip.d.ts.map +1 -1
- package/dist/domain/address/zip.js +31 -5
- package/dist/domain/address/zip.js.map +1 -1
- package/dist/domain/contact/__tests__/email.test.js +58 -2
- package/dist/domain/contact/__tests__/email.test.js.map +1 -1
- package/dist/domain/contact/email.d.ts +6 -0
- package/dist/domain/contact/email.d.ts.map +1 -1
- package/dist/domain/contact/email.js +30 -6
- package/dist/domain/contact/email.js.map +1 -1
- package/dist/domain/dob.d.ts.map +1 -1
- package/dist/domain/dob.js +0 -2
- package/dist/domain/dob.js.map +1 -1
- package/dist/domain/patient/patient-import/create.js +1 -1
- package/dist/domain/patient/patient-import/create.js.map +1 -1
- package/dist/domain/patient/patient-import/schemas.d.ts +13 -3
- package/dist/domain/patient/patient-import/schemas.d.ts.map +1 -1
- package/dist/domain/patient/patient-import/schemas.js +9 -1
- package/dist/domain/patient/patient-import/schemas.js.map +1 -1
- package/dist/domain/patient/patient-import/status.d.ts +2 -0
- package/dist/domain/patient/patient-import/status.d.ts.map +1 -1
- package/dist/domain/patient/patient-import/status.js +3 -2
- package/dist/domain/patient/patient-import/status.js.map +1 -1
- package/dist/domain/patient.d.ts +3 -3
- package/dist/domain/patient.js +1 -1
- package/dist/domain/patient.js.map +1 -1
- package/dist/domain/suspect.d.ts +5 -0
- package/dist/domain/suspect.d.ts.map +1 -0
- package/dist/domain/suspect.js +3 -0
- package/dist/domain/suspect.js.map +1 -0
- package/dist/error/__tests__/shared.test.d.ts +2 -0
- package/dist/error/__tests__/shared.test.d.ts.map +1 -0
- package/dist/error/__tests__/shared.test.js +81 -0
- package/dist/error/__tests__/shared.test.js.map +1 -0
- package/dist/error/shared.d.ts +2 -1
- package/dist/error/shared.d.ts.map +1 -1
- package/dist/error/shared.js +5 -4
- package/dist/error/shared.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/interface/external/ehr/athenahealth/cx-mapping.d.ts +38 -0
- package/dist/interface/external/ehr/athenahealth/cx-mapping.d.ts.map +1 -1
- package/dist/interface/external/ehr/canvas/cx-mapping.d.ts +38 -0
- package/dist/interface/external/ehr/canvas/cx-mapping.d.ts.map +1 -1
- package/dist/interface/external/ehr/elation/cx-mapping.d.ts +38 -0
- package/dist/interface/external/ehr/elation/cx-mapping.d.ts.map +1 -1
- package/dist/interface/external/ehr/healthie/cx-mapping.d.ts +38 -0
- package/dist/interface/external/ehr/healthie/cx-mapping.d.ts.map +1 -1
- package/dist/interface/external/ehr/salesforce/index.d.ts +2 -0
- package/dist/interface/external/ehr/salesforce/index.d.ts.map +1 -0
- package/dist/interface/external/ehr/salesforce/index.js +18 -0
- package/dist/interface/external/ehr/salesforce/index.js.map +1 -0
- package/dist/interface/external/ehr/salesforce/jwt-token.d.ts +21 -0
- package/dist/interface/external/ehr/salesforce/jwt-token.d.ts.map +1 -0
- package/dist/interface/external/ehr/salesforce/jwt-token.js +16 -0
- package/dist/interface/external/ehr/salesforce/jwt-token.js.map +1 -0
- package/dist/interface/external/ehr/salesforce/patient.d.ts +182 -0
- package/dist/interface/external/ehr/salesforce/patient.d.ts.map +1 -0
- package/dist/interface/external/ehr/salesforce/patient.js +31 -0
- package/dist/interface/external/ehr/salesforce/patient.js.map +1 -0
- package/dist/interface/external/ehr/shared.d.ts +64 -0
- package/dist/interface/external/ehr/shared.d.ts.map +1 -1
- package/dist/interface/external/ehr/shared.js +10 -0
- package/dist/interface/external/ehr/shared.js.map +1 -1
- package/dist/interface/external/ehr/source.d.ts +2 -1
- package/dist/interface/external/ehr/source.d.ts.map +1 -1
- package/dist/interface/external/ehr/source.js +1 -0
- package/dist/interface/external/ehr/source.js.map +1 -1
- package/dist/medical/webhook/webhook-request.d.ts +106 -10
- package/dist/medical/webhook/webhook-request.d.ts.map +1 -1
- package/dist/medical/webhook/webhook-request.js +1 -0
- package/dist/medical/webhook/webhook-request.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,23 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeZipCodeNewSafe = exports.normalizeZipCodeNew = exports.isValidZipCodeStrict = void 0;
|
|
3
|
+
exports.normalizeZipCodeNewSafe = exports.normalizeZipCodeNew = exports.isValidZipCodeStrict = exports.isValidZipCodeLength = exports.isValidZipCode = exports.knownInvalidZipCodes = exports.zipLength = void 0;
|
|
4
4
|
const metriport_error_1 = require("../../error/metriport-error");
|
|
5
|
+
exports.zipLength = 5;
|
|
6
|
+
exports.knownInvalidZipCodes = [
|
|
7
|
+
"00000",
|
|
8
|
+
"99999",
|
|
9
|
+
"10000",
|
|
10
|
+
"20000",
|
|
11
|
+
"30000",
|
|
12
|
+
"40000",
|
|
13
|
+
"50000",
|
|
14
|
+
"60000",
|
|
15
|
+
"70000",
|
|
16
|
+
"80000",
|
|
17
|
+
"90000",
|
|
18
|
+
"12345",
|
|
19
|
+
"54321",
|
|
20
|
+
];
|
|
21
|
+
// TODO This should be more comprehensive and include a check for the length of the zip code
|
|
22
|
+
// and the contents (4324- should fail)
|
|
5
23
|
function isValidZipCode(zipCode) {
|
|
6
24
|
if (!zipCode)
|
|
7
25
|
return false;
|
|
8
|
-
|
|
26
|
+
// TODO Ideally we'd call isValidZipCodeLength here, but this would be a breaking change at this point
|
|
27
|
+
if (zipCode.length < 1)
|
|
9
28
|
return false;
|
|
10
29
|
if (!zipCode.match(/^[0-9-]+$/))
|
|
11
30
|
return false;
|
|
31
|
+
if (exports.knownInvalidZipCodes.some(invalidZipCode => zipCode === invalidZipCode))
|
|
32
|
+
return false;
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
exports.isValidZipCode = isValidZipCode;
|
|
36
|
+
function isValidZipCodeLength(zipCode) {
|
|
37
|
+
if (zipCode.length !== exports.zipLength)
|
|
38
|
+
return false;
|
|
12
39
|
return true;
|
|
13
40
|
}
|
|
41
|
+
exports.isValidZipCodeLength = isValidZipCodeLength;
|
|
14
42
|
function isValidZipCodeStrict(zipCode) {
|
|
15
43
|
const isValid = isValidZipCode(zipCode);
|
|
16
44
|
if (!isValid)
|
|
17
45
|
return false;
|
|
18
|
-
|
|
19
|
-
return false;
|
|
20
|
-
return true;
|
|
46
|
+
return isValidZipCodeLength(zipCode);
|
|
21
47
|
}
|
|
22
48
|
exports.isValidZipCodeStrict = isValidZipCodeStrict;
|
|
23
49
|
// TODO 2330 Move/merge this to normalizeZipCode
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../../../src/domain/address/zip.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;
|
|
1
|
+
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../../../src/domain/address/zip.ts"],"names":[],"mappings":";;;AAA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,EAAE,CAAC,CAAC;IACtF,OAAO,cAAc,CAAC;AACxB,CAAC;AAPD,kDAOC;AAED,oDAAoD;AACpD,yKAAyK;AACzK,SAAgB,uBAAuB,CAAC,OAAe;IACrD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAClC,IAAI,UAAU,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC;QAAE,OAAO,SAAS,CAAC;IACrD,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACrF,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,IAAI,CAAC,QAAQ;QAAE,OAAO,UAAU,CAAC;IACjC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC3C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1D,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9B,CAAC;AAXD,0DAWC"}
|
|
@@ -15,6 +15,48 @@ describe("Email Utility Functions", () => {
|
|
|
15
15
|
it('should return false for email with "mailto:" prefix', () => {
|
|
16
16
|
expect((0, email_1.isEmailValid)("mailto:test@example.com")).toBe(false);
|
|
17
17
|
});
|
|
18
|
+
it("should return true for email with exclamation mark", () => {
|
|
19
|
+
expect((0, email_1.isEmailValid)("test!user@example.com")).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
it("should return true for email with other valid special characters", () => {
|
|
22
|
+
expect((0, email_1.isEmailValid)("test#user@example.com")).toBe(true);
|
|
23
|
+
expect((0, email_1.isEmailValid)("test$user@example.com")).toBe(true);
|
|
24
|
+
expect((0, email_1.isEmailValid)("test%user@example.com")).toBe(true);
|
|
25
|
+
expect((0, email_1.isEmailValid)("test&user@example.com")).toBe(true);
|
|
26
|
+
expect((0, email_1.isEmailValid)("test'user@example.com")).toBe(true);
|
|
27
|
+
expect((0, email_1.isEmailValid)("test*user@example.com")).toBe(true);
|
|
28
|
+
expect((0, email_1.isEmailValid)("test+user@example.com")).toBe(true);
|
|
29
|
+
expect((0, email_1.isEmailValid)("test-user@example.com")).toBe(true);
|
|
30
|
+
expect((0, email_1.isEmailValid)("test/user@example.com")).toBe(true);
|
|
31
|
+
expect((0, email_1.isEmailValid)("test=user@example.com")).toBe(true);
|
|
32
|
+
expect((0, email_1.isEmailValid)("test?user@example.com")).toBe(true);
|
|
33
|
+
expect((0, email_1.isEmailValid)("test^user@example.com")).toBe(true);
|
|
34
|
+
expect((0, email_1.isEmailValid)("test_user@example.com")).toBe(true);
|
|
35
|
+
expect((0, email_1.isEmailValid)("test`user@example.com")).toBe(true);
|
|
36
|
+
expect((0, email_1.isEmailValid)("test{user@example.com")).toBe(true);
|
|
37
|
+
expect((0, email_1.isEmailValid)("test|user@example.com")).toBe(true);
|
|
38
|
+
expect((0, email_1.isEmailValid)("test}user@example.com")).toBe(true);
|
|
39
|
+
expect((0, email_1.isEmailValid)("test~user@example.com")).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
it("should return false for phone number format (+1 prefix)", () => {
|
|
42
|
+
expect((0, email_1.isEmailValid)("+1234567890@example.com")).toBe(false);
|
|
43
|
+
expect((0, email_1.isEmailValid)("+1-234-567-8900@example.com")).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe("isEmailAPhoneNumber", () => {
|
|
47
|
+
it("should return true for phone number format", () => {
|
|
48
|
+
expect((0, email_1.isEmailAPhoneNumber)("+1234567890")).toBe(true);
|
|
49
|
+
expect((0, email_1.isEmailAPhoneNumber)("+1-234-567-8900")).toBe(true);
|
|
50
|
+
expect((0, email_1.isEmailAPhoneNumber)("+1 (234) 567-8900")).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
it("should return false for regular email", () => {
|
|
53
|
+
expect((0, email_1.isEmailAPhoneNumber)("test@example.com")).toBe(false);
|
|
54
|
+
expect((0, email_1.isEmailAPhoneNumber)("user+tag@example.com")).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
it("should handle whitespace", () => {
|
|
57
|
+
expect((0, email_1.isEmailAPhoneNumber)(" +1234567890")).toBe(true);
|
|
58
|
+
expect((0, email_1.isEmailAPhoneNumber)(" +1-234-567-8900")).toBe(true);
|
|
59
|
+
});
|
|
18
60
|
});
|
|
19
61
|
describe("normalizeEmail", () => {
|
|
20
62
|
it("should trim whitespace and convert to lowercase", () => {
|
|
@@ -28,12 +70,18 @@ describe("Email Utility Functions", () => {
|
|
|
28
70
|
it("should return normalized email when valid", () => {
|
|
29
71
|
expect((0, email_1.normalizeEmailStrict)(" Test@Example.COM ")).toBe("test@example.com");
|
|
30
72
|
});
|
|
73
|
+
it("should return normalized email with special characters", () => {
|
|
74
|
+
expect((0, email_1.normalizeEmailStrict)(" Test!User@Example.COM ")).toBe("test!user@example.com");
|
|
75
|
+
});
|
|
31
76
|
it("should throw an error for invalid email format", () => {
|
|
32
77
|
expect(() => (0, email_1.normalizeEmailStrict)("invalid-email")).toThrow("Invalid email.");
|
|
33
78
|
});
|
|
34
79
|
it('should throw an error for email with "mailto:" prefix', () => {
|
|
35
80
|
expect(() => (0, email_1.normalizeEmailStrict)("mailto:test@example.com")).toThrow("Invalid email.");
|
|
36
81
|
});
|
|
82
|
+
it("should throw specific error for phone number format", () => {
|
|
83
|
+
expect(() => (0, email_1.normalizeEmailStrict)("+1234567890@example.com")).toThrow("Invalid email: appears to be a phone number (starts with +1). Please enter a valid email address.");
|
|
84
|
+
});
|
|
37
85
|
});
|
|
38
86
|
});
|
|
39
87
|
describe("email", () => {
|
|
@@ -66,15 +114,23 @@ describe("email", () => {
|
|
|
66
114
|
const input = expectedOutput + " ";
|
|
67
115
|
expect((0, email_1.normalizeEmailNewSafe)(input)).toBe(expectedOutput);
|
|
68
116
|
});
|
|
69
|
-
it("should
|
|
117
|
+
it("should replace mailto: prefix", () => {
|
|
70
118
|
const expectedOutput = email_1.exampleEmail;
|
|
71
119
|
const input = "mailto:" + expectedOutput;
|
|
72
120
|
expect((0, email_1.normalizeEmailNewSafe)(input)).toBe(expectedOutput);
|
|
73
121
|
});
|
|
74
|
-
it("should return undefined for emails that invalid", () => {
|
|
122
|
+
it("should return undefined for emails that are invalid", () => {
|
|
75
123
|
const input = "this.is.not.an.email";
|
|
76
124
|
expect((0, email_1.normalizeEmailNewSafe)(input)).toBeUndefined();
|
|
77
125
|
});
|
|
126
|
+
it("should handle emails with special characters", () => {
|
|
127
|
+
const input = "test!user@example.com";
|
|
128
|
+
expect((0, email_1.normalizeEmailNewSafe)(input)).toBe("test!user@example.com");
|
|
129
|
+
});
|
|
130
|
+
it("should return undefined for phone number format", () => {
|
|
131
|
+
const input = "+1234567890@example.com";
|
|
132
|
+
expect((0, email_1.normalizeEmailNewSafe)(input)).toBeUndefined();
|
|
133
|
+
});
|
|
78
134
|
});
|
|
79
135
|
});
|
|
80
136
|
//# sourceMappingURL=email.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.test.js","sourceRoot":"","sources":["../../../../src/domain/contact/__tests__/email.test.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"email.test.js","sourceRoot":"","sources":["../../../../src/domain/contact/__tests__/email.test.ts"],"names":[],"mappings":";;AAAA,oCAOkB;AAElB,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9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AAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export declare const exampleEmail = "test@test.com";
|
|
2
2
|
export declare function isEmail(email: string): boolean;
|
|
3
3
|
export declare function isEmailValid(email: string): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if an email appears to be a phone number (starts with +1)
|
|
6
|
+
* This has been decided by the team to be an invalid email, and we should not allow it.
|
|
7
|
+
* This means the +1iamarealuser@example.com is an invalid email to us, even though it is technically a valid email.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isEmailAPhoneNumber(email: string): boolean;
|
|
4
10
|
/**
|
|
5
11
|
* @deprecated Use noramlizeEmailBase instead
|
|
6
12
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../src/domain/contact/email.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../src/domain/contact/email.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,kBAAkB,CAAC;AAG5C,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAcnD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAa1D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD;AASD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,aAAa,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAA2B,GAC5D,MAAM,GAAG,SAAS,CAIpB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAavD"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeEmailNew = exports.normalizeEmailNewSafe = exports.noramlizeEmailBase = exports.normalizeEmailStrict = exports.normalizeEmail = exports.isEmailValid = exports.isEmail = exports.exampleEmail = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
6
|
+
exports.normalizeEmailNew = exports.normalizeEmailNewSafe = exports.noramlizeEmailBase = exports.normalizeEmailStrict = exports.normalizeEmail = exports.isEmailAPhoneNumber = exports.isEmailValid = exports.isEmail = exports.exampleEmail = void 0;
|
|
5
7
|
const bad_request_1 = require("../../error/bad-request");
|
|
8
|
+
const validator_1 = __importDefault(require("validator"));
|
|
6
9
|
exports.exampleEmail = "test@test.com";
|
|
7
10
|
const mailtoPrefix = "mailto:";
|
|
8
11
|
function isEmail(email) {
|
|
@@ -14,12 +17,26 @@ function isEmailValid(email) {
|
|
|
14
17
|
return false;
|
|
15
18
|
if (email.length === 0)
|
|
16
19
|
return false;
|
|
17
|
-
|
|
18
|
-
if (
|
|
20
|
+
// Check for phone number format (+1 prefix)
|
|
21
|
+
if (isEmailAPhoneNumber(email)) {
|
|
19
22
|
return false;
|
|
20
|
-
|
|
23
|
+
}
|
|
24
|
+
// Use our enhanced regex instead of Zod's potentially too-strict validation
|
|
25
|
+
return validator_1.default.isEmail(email, {
|
|
26
|
+
allow_utf8_local_part: true,
|
|
27
|
+
blacklisted_chars: "",
|
|
28
|
+
});
|
|
21
29
|
}
|
|
22
30
|
exports.isEmailValid = isEmailValid;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if an email appears to be a phone number (starts with +1)
|
|
33
|
+
* This has been decided by the team to be an invalid email, and we should not allow it.
|
|
34
|
+
* This means the +1iamarealuser@example.com is an invalid email to us, even though it is technically a valid email.
|
|
35
|
+
*/
|
|
36
|
+
function isEmailAPhoneNumber(email) {
|
|
37
|
+
return email.trim().startsWith("+1");
|
|
38
|
+
}
|
|
39
|
+
exports.isEmailAPhoneNumber = isEmailAPhoneNumber;
|
|
23
40
|
/**
|
|
24
41
|
* @deprecated Use noramlizeEmailBase instead
|
|
25
42
|
*/
|
|
@@ -33,8 +50,12 @@ exports.normalizeEmail = normalizeEmail;
|
|
|
33
50
|
*/
|
|
34
51
|
function normalizeEmailStrict(email) {
|
|
35
52
|
const normalEmail = normalizeEmail(email);
|
|
36
|
-
if (!isEmailValid(normalEmail))
|
|
53
|
+
if (!isEmailValid(normalEmail)) {
|
|
54
|
+
if (isEmailAPhoneNumber(email)) {
|
|
55
|
+
throw new bad_request_1.BadRequestError("Invalid email: appears to be a phone number (starts with +1). Please enter a valid email address.", undefined, { email });
|
|
56
|
+
}
|
|
37
57
|
throw new Error("Invalid email.");
|
|
58
|
+
}
|
|
38
59
|
return normalEmail;
|
|
39
60
|
}
|
|
40
61
|
exports.normalizeEmailStrict = normalizeEmailStrict;
|
|
@@ -69,6 +90,9 @@ exports.normalizeEmailNewSafe = normalizeEmailNewSafe;
|
|
|
69
90
|
function normalizeEmailNew(email) {
|
|
70
91
|
const emailOrUndefined = normalizeEmailNewSafe(email);
|
|
71
92
|
if (!emailOrUndefined) {
|
|
93
|
+
if (isEmailAPhoneNumber(email)) {
|
|
94
|
+
throw new bad_request_1.BadRequestError("Invalid email: appears to be a phone number (starts with +1). Please enter a valid email address.", undefined, { email });
|
|
95
|
+
}
|
|
72
96
|
throw new bad_request_1.BadRequestError("Invalid email", undefined, { email });
|
|
73
97
|
}
|
|
74
98
|
return emailOrUndefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../src/domain/contact/email.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../src/domain/contact/email.ts"],"names":[],"mappings":";;;;;;AAAA,yDAA0D;AAC1D,0DAAkC;AACrB,QAAA,YAAY,GAAG,eAAe,CAAC;AAC5C,MAAM,YAAY,GAAG,SAAS,CAAC;AAE/B,SAAgB,OAAO,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAFD,0BAEC;AAED,SAAgB,YAAY,CAAC,KAAa;IACxC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAErC,4CAA4C;IAC5C,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE;QAC9B,OAAO,KAAK,CAAC;KACd;IAED,4EAA4E;IAC5E,OAAO,mBAAS,CAAC,OAAO,CAAC,KAAK,EAAE;QAC9B,qBAAqB,EAAE,IAAI;QAC3B,iBAAiB,EAAE,EAAE;KACtB,CAAC,CAAC;AACL,CAAC;AAdD,oCAcC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,KAAa;IAC/C,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC;AAFD,kDAEC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAa;IAC1C,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAClC,OAAO,YAAY,CAAC,WAAW,EAAE,CAAC;AACpC,CAAC;AAHD,wCAGC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAa;IAChD,MAAM,WAAW,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IAC1C,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;QAC9B,IAAI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/domain/dob.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dob.d.ts","sourceRoot":"","sources":["../../src/domain/dob.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"dob.d.ts","sourceRoot":"","sources":["../../src/domain/dob.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIjE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIjD"}
|
package/dist/domain/dob.js
CHANGED
|
@@ -12,8 +12,6 @@ const bad_request_1 = require("../error/bad-request");
|
|
|
12
12
|
*/
|
|
13
13
|
function normalizeDobSafe(date) {
|
|
14
14
|
const trimmedDate = date.trim();
|
|
15
|
-
if (trimmedDate.length < 1)
|
|
16
|
-
return undefined;
|
|
17
15
|
if (!(0, date_1.validateDateOfBirth)(trimmedDate))
|
|
18
16
|
return undefined;
|
|
19
17
|
return (0, date_1.buildDayjs)(trimmedDate).format(date_1.ISO_DATE);
|
package/dist/domain/dob.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dob.js","sourceRoot":"","sources":["../../src/domain/dob.ts"],"names":[],"mappings":";;;AAAA,yCAA2E;AAC3E,sDAAuD;AAEvD;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,
|
|
1
|
+
{"version":3,"file":"dob.js","sourceRoot":"","sources":["../../src/domain/dob.ts"],"names":[],"mappings":";;;AAAA,yCAA2E;AAC3E,sDAAuD;AAEvD;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,CAAC,IAAA,0BAAmB,EAAC,WAAW,CAAC;QAAE,OAAO,SAAS,CAAC;IACxD,OAAO,IAAA,iBAAU,EAAC,WAAW,CAAC,CAAC,MAAM,CAAC,eAAQ,CAAC,CAAC;AAClD,CAAC;AAJD,4CAIC;AAED,SAAgB,YAAY,CAAC,IAAY;IACvC,MAAM,eAAe,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,CAAC,eAAe;QAAE,MAAM,IAAI,6BAAe,CAAC,uBAAuB,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9F,OAAO,eAAe,CAAC;AACzB,CAAC;AAJD,oCAIC"}
|
|
@@ -18,7 +18,7 @@ function createPatientImport({ cxId, facilityId, paramsCx = {}, paramsOps = {},
|
|
|
18
18
|
const initializedParamsCx = {
|
|
19
19
|
dryRun: dryRunCx,
|
|
20
20
|
};
|
|
21
|
-
const { rerunPdOnNewDemographics =
|
|
21
|
+
const { rerunPdOnNewDemographics = true, triggerConsolidated = true, disableWebhooks = false, } = paramsOps;
|
|
22
22
|
const initializedParamsOps = {
|
|
23
23
|
rerunPdOnNewDemographics,
|
|
24
24
|
triggerConsolidated,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/domain/patient/patient-import/create.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAClD,mDAA+C;AAIlC,QAAA,aAAa,GAA2B,SAAS,CAAC;AAC/D;;;;;;;;GAQG;AACH,SAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,UAAU,EACV,QAAQ,GAAG,EAAE,EACb,SAAS,GAAG,EAAE,GAMf;IACC,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,QAAQ,CAAC;IAC9C,MAAM,mBAAmB,GAA0B;QACjD,MAAM,EAAE,QAAQ;KACjB,CAAC;IAEF,MAAM,EACJ,wBAAwB,GAAG,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/domain/patient/patient-import/create.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAClD,mDAA+C;AAIlC,QAAA,aAAa,GAA2B,SAAS,CAAC;AAC/D;;;;;;;;GAQG;AACH,SAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,UAAU,EACV,QAAQ,GAAG,EAAE,EACb,SAAS,GAAG,EAAE,GAMf;IACC,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,QAAQ,CAAC;IAC9C,MAAM,mBAAmB,GAA0B;QACjD,MAAM,EAAE,QAAQ;KACjB,CAAC;IAEF,MAAM,EACJ,wBAAwB,GAAG,IAAI,EAC/B,mBAAmB,GAAG,IAAI,EAC1B,eAAe,GAAG,KAAK,GACxB,GAAG,SAAS,CAAC;IACd,MAAM,oBAAoB,GAA2B;QACnD,wBAAwB;QACxB,mBAAmB;QACnB,eAAe;QACf,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3D,CAAC;IAEF,MAAM,KAAK,GAAG,IAAA,gBAAM,GAAE,CAAC;IACvB,MAAM,MAAM,GAAG,qBAAa,CAAC;IAC7B,MAAM,SAAS,GAAG,IAAA,iBAAU,GAAE,CAAC,MAAM,EAAE,CAAC;IAExC,MAAM,gBAAgB,GAAqB;QACzC,EAAE,EAAE,KAAK;QACT,IAAI;QACJ,UAAU;QACV,MAAM;QACN,MAAM,EAAE,SAAS;QACjB,SAAS;QACT,SAAS,EAAE,SAAS;QACpB,UAAU,EAAE,SAAS;QACrB,KAAK,EAAE,CAAC;QACR,UAAU,EAAE,CAAC;QACb,MAAM,EAAE,CAAC;QACT,QAAQ,EAAE,mBAAmB;QAC7B,SAAS,EAAE,oBAAoB;KAChC,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAjDD,kDAiDC"}
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const updateJobSchema: z.ZodObject<{
|
|
3
|
-
status: z.ZodEnum<["
|
|
3
|
+
status: z.ZodOptional<z.ZodEnum<["processing" | "completed" | "failed", ...("processing" | "completed" | "failed")[]]>>;
|
|
4
4
|
total: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
/**
|
|
6
|
+
* Only to be set on dry run mode - on regular mode, the successful count is incremented
|
|
7
|
+
* individually as each patient is created.
|
|
8
|
+
*/
|
|
9
|
+
successful: z.ZodOptional<z.ZodNumber>;
|
|
5
10
|
failed: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
6
12
|
forceStatusUpdate: z.ZodOptional<z.ZodBoolean>;
|
|
7
13
|
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
status
|
|
14
|
+
status?: "processing" | "completed" | "failed" | undefined;
|
|
9
15
|
failed?: number | undefined;
|
|
10
16
|
total?: number | undefined;
|
|
17
|
+
successful?: number | undefined;
|
|
18
|
+
reason?: string | undefined;
|
|
11
19
|
forceStatusUpdate?: boolean | undefined;
|
|
12
20
|
}, {
|
|
13
|
-
status
|
|
21
|
+
status?: "processing" | "completed" | "failed" | undefined;
|
|
14
22
|
failed?: number | undefined;
|
|
15
23
|
total?: number | undefined;
|
|
24
|
+
successful?: number | undefined;
|
|
25
|
+
reason?: string | undefined;
|
|
16
26
|
forceStatusUpdate?: boolean | undefined;
|
|
17
27
|
}>;
|
|
18
28
|
export type UpdateJobSchema = z.infer<typeof updateJobSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/domain/patient/patient-import/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA4BxB,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/domain/patient/patient-import/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA4BxB,eAAO,MAAM,eAAe;;;IAU1B;;;OAGG;;;;;;;;;;;;;;;;;;;EAKH,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;EAKlC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -27,9 +27,17 @@ const status_1 = require("./status");
|
|
|
27
27
|
// patients: patientImportPatientSchema.array(),
|
|
28
28
|
// });
|
|
29
29
|
exports.updateJobSchema = zod_1.z.object({
|
|
30
|
-
status: zod_1.z
|
|
30
|
+
status: zod_1.z
|
|
31
|
+
.enum(status_1.patientImportJobStatus.filter(s => s !== "waiting"))
|
|
32
|
+
.optional(),
|
|
31
33
|
total: zod_1.z.number().optional(),
|
|
34
|
+
/**
|
|
35
|
+
* Only to be set on dry run mode - on regular mode, the successful count is incremented
|
|
36
|
+
* individually as each patient is created.
|
|
37
|
+
*/
|
|
38
|
+
successful: zod_1.z.number().optional(),
|
|
32
39
|
failed: zod_1.z.number().optional(),
|
|
40
|
+
reason: zod_1.z.string().optional(),
|
|
33
41
|
forceStatusUpdate: zod_1.z.boolean().optional(),
|
|
34
42
|
});
|
|
35
43
|
exports.addPatientMappingSchema = zod_1.z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../../src/domain/patient/patient-import/schemas.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../../src/domain/patient/patient-import/sch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"failed"];
|
|
2
|
+
export type PatientImportJobUpdatableStatus = (typeof patientImportJobUpdatableStatus)[number];
|
|
1
3
|
export declare const patientImportJobStatus: readonly ["waiting", "processing", "completed", "failed"];
|
|
2
4
|
export type PatientImportJobStatus = (typeof patientImportJobStatus)[number];
|
|
3
5
|
export declare function isPatientImportDone(status: PatientImportJobStatus): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../src/domain/patient/patient-import/status.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../src/domain/patient/patient-import/status.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,+BAA+B,gDAAiD,CAAC;AAC9F,MAAM,MAAM,+BAA+B,GAAG,CAAC,OAAO,+BAA+B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/F,eAAO,MAAM,sBAAsB,2DAA2D,CAAC;AAC/F,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAE3E;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,sBAAsB,EACrC,SAAS,EAAE,sBAAsB,GAChC,sBAAsB,CA2CxB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateNewStatus = exports.isPatientImportDone = exports.patientImportJobStatus = void 0;
|
|
3
|
+
exports.validateNewStatus = exports.isPatientImportDone = exports.patientImportJobStatus = exports.patientImportJobUpdatableStatus = void 0;
|
|
4
4
|
const bad_request_1 = require("../../../error/bad-request");
|
|
5
|
-
exports.
|
|
5
|
+
exports.patientImportJobUpdatableStatus = ["processing", "completed", "failed"];
|
|
6
|
+
exports.patientImportJobStatus = ["waiting", ...exports.patientImportJobUpdatableStatus];
|
|
6
7
|
function isPatientImportDone(status) {
|
|
7
8
|
return status === "completed" || status === "failed";
|
|
8
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../../src/domain/patient/patient-import/status.ts"],"names":[],"mappings":";;;AAAA,4DAA6D;AAEhD,QAAA,
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../../src/domain/patient/patient-import/status.ts"],"names":[],"mappings":";;;AAAA,4DAA6D;AAEhD,QAAA,+BAA+B,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,QAAQ,CAAU,CAAC;AAGjF,QAAA,sBAAsB,GAAG,CAAC,SAAS,EAAE,GAAG,uCAA+B,CAAU,CAAC;AAG/F,SAAgB,mBAAmB,CAAC,MAA8B;IAChE,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,QAAQ,CAAC;AACvD,CAAC;AAFD,kDAEC;AAED;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAC/B,aAAqC,EACrC,SAAiC;IAEjC,MAAM,cAAc,GAAG;QACrB,aAAa;QACb,SAAS;KACV,CAAC;IACF,QAAQ,SAAS,EAAE;QACjB,KAAK,SAAS;YACZ,MAAM,IAAI,6BAAe,CACvB,4CAA4C,EAC5C,SAAS,EACT,cAAc,CACf,CAAC;QACJ,KAAK,YAAY;YACf,IAAI,aAAa,KAAK,SAAS,IAAI,aAAa,KAAK,YAAY,EAAE;gBACjE,MAAM,IAAI,6BAAe,CACvB,4DAA4D,EAC5D,SAAS,EACT,cAAc,CACf,CAAC;aACH;YACD,MAAM;QACR,KAAK,WAAW;YACd,IAAI,aAAa,KAAK,YAAY,EAAE;gBAClC,MAAM,IAAI,6BAAe,CACvB,0DAA0D,EAC1D,SAAS,EACT,cAAc,CACf,CAAC;aACH;YACD,MAAM;QACR,KAAK,QAAQ;YACX,IAAI,aAAa,KAAK,WAAW,EAAE;gBACjC,MAAM,IAAI,6BAAe,CACvB,kDAAkD,EAClD,SAAS,EACT,cAAc,CACf,CAAC;aACH;YACD,MAAM;QACR;YACE,MAAM,IAAI,6BAAe,CAAC,2BAA2B,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;KACrF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AA9CD,8CA8CC"}
|
package/dist/domain/patient.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const patientSchema: z.ZodObject<{
|
|
3
3
|
id: z.ZodString;
|
|
4
|
-
externalId: z.ZodOptional<z.ZodString
|
|
4
|
+
externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
5
5
|
facilityIds: z.ZodArray<z.ZodString, "many">;
|
|
6
6
|
firstName: z.ZodString;
|
|
7
7
|
lastName: z.ZodString;
|
|
@@ -43,7 +43,7 @@ export declare const patientSchema: z.ZodObject<{
|
|
|
43
43
|
dob: string;
|
|
44
44
|
genderAtBirth: "M" | "F" | "O" | "U";
|
|
45
45
|
dateCreated: string;
|
|
46
|
-
externalId?: string | undefined;
|
|
46
|
+
externalId?: string | null | undefined;
|
|
47
47
|
phoneNumber?: string | undefined;
|
|
48
48
|
}, {
|
|
49
49
|
address: {
|
|
@@ -60,7 +60,7 @@ export declare const patientSchema: z.ZodObject<{
|
|
|
60
60
|
dob: string;
|
|
61
61
|
genderAtBirth: "M" | "F" | "O" | "U";
|
|
62
62
|
dateCreated: string;
|
|
63
|
-
externalId?: string | undefined;
|
|
63
|
+
externalId?: string | null | undefined;
|
|
64
64
|
phoneNumber?: string | undefined;
|
|
65
65
|
}>;
|
|
66
66
|
export type Patient = z.infer<typeof patientSchema>;
|
package/dist/domain/patient.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.patientIdsSchema = exports.patientSchema = void 0;
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
exports.patientSchema = zod_1.z.object({
|
|
6
6
|
id: zod_1.z.string(),
|
|
7
|
-
externalId: zod_1.z.string().
|
|
7
|
+
externalId: zod_1.z.string().nullish(),
|
|
8
8
|
facilityIds: zod_1.z.array(zod_1.z.string()),
|
|
9
9
|
firstName: zod_1.z.string(),
|
|
10
10
|
lastName: zod_1.z.string(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patient.js","sourceRoot":"","sources":["../../src/domain/patient.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,aAAa,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"patient.js","sourceRoot":"","sources":["../../src/domain/patient.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,aAAa,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IAChC,WAAW,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;IAChC,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;IACrB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,aAAa,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3C,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;IACvB,OAAO,EAAE,OAAC,CAAC,KAAK,CACd,OAAC,CAAC,MAAM,CAAC;QACP,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACnC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACnC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC3B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC5B,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;KAChB,CAAC,CACH;IACD,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAGU,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;CAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suspect.d.ts","sourceRoot":"","sources":["../../src/domain/suspect.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suspect.js","sourceRoot":"","sources":["../../src/domain/suspect.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.test.d.ts","sourceRoot":"","sources":["../../../src/error/__tests__/shared.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const faker_1 = require("@faker-js/faker");
|
|
4
|
+
const metriport_error_1 = require("../metriport-error");
|
|
5
|
+
const shared_1 = require("../shared");
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
jest.restoreAllMocks();
|
|
8
|
+
});
|
|
9
|
+
describe("errorToString", () => {
|
|
10
|
+
it("returns error message when regular Error", async () => {
|
|
11
|
+
const message = faker_1.faker.lorem.sentence();
|
|
12
|
+
const error = new Error(message);
|
|
13
|
+
const res = (0, shared_1.errorToString)(error);
|
|
14
|
+
expect(res).toEqual(message);
|
|
15
|
+
});
|
|
16
|
+
it("returns error message when MetriportError", async () => {
|
|
17
|
+
const message = faker_1.faker.lorem.sentence();
|
|
18
|
+
const error = new metriport_error_1.MetriportError(message);
|
|
19
|
+
const res = (0, shared_1.errorToString)(error);
|
|
20
|
+
expect(res).toEqual(message);
|
|
21
|
+
});
|
|
22
|
+
it("returns error message when no cause but detailed=true", async () => {
|
|
23
|
+
const message = faker_1.faker.lorem.sentence();
|
|
24
|
+
const error = new metriport_error_1.MetriportError(message);
|
|
25
|
+
const res = (0, shared_1.errorToString)(error, { detailed: true });
|
|
26
|
+
expect(res).toEqual(message);
|
|
27
|
+
});
|
|
28
|
+
it("returns single error message when has causes but detailed=false", async () => {
|
|
29
|
+
const messageParent = faker_1.faker.lorem.sentence();
|
|
30
|
+
const errorParent = new metriport_error_1.MetriportError(messageParent);
|
|
31
|
+
const message = faker_1.faker.lorem.sentence();
|
|
32
|
+
const error = new metriport_error_1.MetriportError(message, errorParent);
|
|
33
|
+
const res = (0, shared_1.errorToString)(error, { detailed: false });
|
|
34
|
+
expect(res).toEqual(message);
|
|
35
|
+
});
|
|
36
|
+
it("has default detailed=true when not defined", async () => {
|
|
37
|
+
const messageParent = faker_1.faker.lorem.sentence();
|
|
38
|
+
const errorParent = new metriport_error_1.MetriportError(messageParent);
|
|
39
|
+
const message = faker_1.faker.lorem.sentence();
|
|
40
|
+
const error = new metriport_error_1.MetriportError(message, errorParent);
|
|
41
|
+
const expectedMessage = `${message}; caused by ${messageParent}`;
|
|
42
|
+
const res = (0, shared_1.errorToString)(error);
|
|
43
|
+
expect(res).toEqual(expectedMessage);
|
|
44
|
+
});
|
|
45
|
+
it("returns complete error message when has causes and detailed=true", async () => {
|
|
46
|
+
const messageGrandparent = faker_1.faker.lorem.sentence();
|
|
47
|
+
const errorGrandparent = new metriport_error_1.MetriportError(messageGrandparent);
|
|
48
|
+
const messageParent = faker_1.faker.lorem.sentence();
|
|
49
|
+
const errorParent = new metriport_error_1.MetriportError(messageParent, errorGrandparent);
|
|
50
|
+
const message = faker_1.faker.lorem.sentence();
|
|
51
|
+
const error = new metriport_error_1.MetriportError(message, errorParent);
|
|
52
|
+
const expectedMessage = `${message}; caused by ${messageParent}; caused by ${messageGrandparent}`;
|
|
53
|
+
const res = (0, shared_1.errorToString)(error, { detailed: true });
|
|
54
|
+
expect(res).toEqual(expectedMessage);
|
|
55
|
+
});
|
|
56
|
+
it("includes additionalInfo when detailed=true", async () => {
|
|
57
|
+
const message = faker_1.faker.lorem.sentence();
|
|
58
|
+
const additionalInfo = { foo: faker_1.faker.lorem.sentence(), bar: faker_1.faker.number.int().toString() };
|
|
59
|
+
const error = new metriport_error_1.MetriportError(message, undefined, additionalInfo);
|
|
60
|
+
const expectedMessage = `${message} (${JSON.stringify(additionalInfo)})`;
|
|
61
|
+
const res = (0, shared_1.errorToString)(error, { detailed: true });
|
|
62
|
+
expect(res).toEqual(expectedMessage);
|
|
63
|
+
});
|
|
64
|
+
it("includes additionalInfo from cause when detailed=true", async () => {
|
|
65
|
+
const messageGrandparent = faker_1.faker.lorem.sentence();
|
|
66
|
+
const additionalInfoGrandParent = {
|
|
67
|
+
foo: faker_1.faker.lorem.sentence(),
|
|
68
|
+
bar: faker_1.faker.number.int().toString(),
|
|
69
|
+
};
|
|
70
|
+
const errorGrandparent = new metriport_error_1.MetriportError(messageGrandparent, undefined, additionalInfoGrandParent);
|
|
71
|
+
const messageParent = faker_1.faker.lorem.sentence();
|
|
72
|
+
const errorParent = new metriport_error_1.MetriportError(messageParent, errorGrandparent);
|
|
73
|
+
const message = faker_1.faker.lorem.sentence();
|
|
74
|
+
const additionalInfo = { foo: faker_1.faker.lorem.sentence(), bar: faker_1.faker.number.int().toString() };
|
|
75
|
+
const error = new metriport_error_1.MetriportError(message, errorParent, additionalInfo);
|
|
76
|
+
const expectedMessage = `${message} (${JSON.stringify(additionalInfo)}); caused by ${messageParent}; caused by ${messageGrandparent} (${JSON.stringify(additionalInfoGrandParent)})`;
|
|
77
|
+
const res = (0, shared_1.errorToString)(error, { detailed: true });
|
|
78
|
+
expect(res).toEqual(expectedMessage);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=shared.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.test.js","sourceRoot":"","sources":["../../../src/error/__tests__/shared.test.ts"],"names":[],"mappings":";;AAAA,2CAAwC;AACxC,wDAAoD;AACpD,sCAA0C;AAE1C,UAAU,CAAC,GAAG,EAAE;IACd,IAAI,CAAC,eAAe,EAAE,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,OAAO,GAAG,aAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QACjC,MAAM,GAAG,GAAG,IAAA,sBAAa,EAAC,KAAK,CAAC,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,OAAO,GAAG,aAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,IAAI,gCAAc,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,GAAG,GAAG,IAAA,sBAAa,EAAC,KAAK,CAAC,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;QACrE,MAAM,OAAO,GAAG,aAAK,CAAC,KAAK,CAAC,QAAQ,EAAE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;QACL,MAAM,GAAG,GAAG,IAAA,sBAAa,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/error/shared.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export type ErrorToStringOptions = {
|
|
2
2
|
detailed: boolean;
|
|
3
|
+
includeStackTrace?: boolean;
|
|
3
4
|
};
|
|
4
5
|
export declare function errorToString(err: unknown, options?: ErrorToStringOptions): string;
|
|
5
6
|
export declare function genericErrorToString(err: any): string;
|
|
6
|
-
export declare function detailedErrorToString(err: any): string;
|
|
7
|
+
export declare function detailedErrorToString(err: any, includeStackTrace?: boolean): string;
|
|
7
8
|
export declare function getErrorMessage(error: unknown): string;
|
|
8
9
|
//# sourceMappingURL=shared.d.ts.map
|