@rethinkhealth/hl7v2-ack 0.12.0 → 0.13.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/dist/index.js CHANGED
@@ -1,212 +1,216 @@
1
- // src/acknowledge.ts
2
1
  import { c, f, m, s } from "@rethinkhealth/hl7v2-builder";
3
2
  import { value } from "@rethinkhealth/hl7v2-util-query";
4
3
  import { Timestamp } from "@rethinkhealth/hl7v2-util-timestamp";
5
-
6
- // src/constants.ts
7
- var AckCode = {
8
- ApplicationAccept: "AA",
9
- ApplicationError: "AE",
10
- ApplicationReject: "AR",
11
- CommitAccept: "CA",
12
- CommitError: "CE",
13
- CommitReject: "CR"
4
+ import { nanoid } from "nanoid";
5
+ //#region src/constants.ts
6
+ /** HL7v2 Table 0008 — Acknowledgment codes used in MSA-1. */
7
+ const AckCode = {
8
+ ApplicationAccept: "AA",
9
+ ApplicationError: "AE",
10
+ ApplicationReject: "AR",
11
+ CommitAccept: "CA",
12
+ CommitError: "CE",
13
+ CommitReject: "CR"
14
14
  };
15
- var Hl7ErrorCode = {
16
- MessageAccepted: "0",
17
- SegmentSequenceError: "100",
18
- RequiredFieldMissing: "101",
19
- DataTypeError: "102",
20
- TableValueNotFound: "103",
21
- UnsupportedMessageType: "200",
22
- UnsupportedEventCode: "201",
23
- UnsupportedProcessingId: "202",
24
- UnsupportedVersionId: "203",
25
- UnknownKeyIdentifier: "204",
26
- DuplicateKeyIdentifier: "205",
27
- ApplicationRecordLocked: "206",
28
- ApplicationInternalError: "207"
15
+ /** HL7v2 Table 0357 — Message error condition codes used in ERR-3. Stable across all versions (v2.1–v2.9). */
16
+ const Hl7ErrorCode = {
17
+ MessageAccepted: "0",
18
+ SegmentSequenceError: "100",
19
+ RequiredFieldMissing: "101",
20
+ DataTypeError: "102",
21
+ TableValueNotFound: "103",
22
+ UnsupportedMessageType: "200",
23
+ UnsupportedEventCode: "201",
24
+ UnsupportedProcessingId: "202",
25
+ UnsupportedVersionId: "203",
26
+ UnknownKeyIdentifier: "204",
27
+ DuplicateKeyIdentifier: "205",
28
+ ApplicationRecordLocked: "206",
29
+ ApplicationInternalError: "207"
29
30
  };
30
- var Severity = {
31
- Info: "I",
32
- Warning: "W",
33
- Error: "E"
31
+ /** HL7v2 Table 0516 — Error severity codes used in ERR-4. */
32
+ const Severity = {
33
+ Info: "I",
34
+ Warning: "W",
35
+ Error: "E"
34
36
  };
35
-
36
- // src/uid.ts
37
- import { nanoid } from "nanoid";
38
- var MAX_LENGTH = 20;
37
+ //#endregion
38
+ //#region src/uid.ts
39
+ const MAX_LENGTH = 20;
39
40
  function uid(options = {}) {
40
- const { prefix, size = MAX_LENGTH } = options;
41
- if (!prefix) {
42
- return nanoid(size);
43
- }
44
- const remaining = size - prefix.length;
45
- if (remaining <= 0) {
46
- return prefix.slice(0, size);
47
- }
48
- return `${prefix}${nanoid(remaining)}`;
41
+ const { prefix, size = MAX_LENGTH } = options;
42
+ if (!prefix) return nanoid(size);
43
+ const remaining = size - prefix.length;
44
+ if (remaining <= 0) return prefix.slice(0, size);
45
+ return `${prefix}${nanoid(remaining)}`;
49
46
  }
50
-
51
- // src/acknowledge.ts
47
+ //#endregion
48
+ //#region src/acknowledge.ts
52
49
  function extractOriginFields(tree) {
53
- return {
54
- controlId: value(tree, "MSH-10")?.value ?? "",
55
- processingId: value(tree, "MSH-11")?.value ?? "P",
56
- receivingApp: value(tree, "MSH-5")?.value ?? "",
57
- receivingFac: value(tree, "MSH-6")?.value ?? "",
58
- sendingApp: value(tree, "MSH-3")?.value ?? "",
59
- sendingFac: value(tree, "MSH-4")?.value ?? "",
60
- triggerEvent: value(tree, "MSH-9.2")?.value ?? "",
61
- version: value(tree, "MSH-12.1")?.value ?? ""
62
- };
50
+ return {
51
+ controlId: value(tree, "MSH-10")?.value ?? "",
52
+ processingId: value(tree, "MSH-11")?.value ?? "P",
53
+ receivingApp: value(tree, "MSH-5")?.value ?? "",
54
+ receivingFac: value(tree, "MSH-6")?.value ?? "",
55
+ sendingApp: value(tree, "MSH-3")?.value ?? "",
56
+ sendingFac: value(tree, "MSH-4")?.value ?? "",
57
+ triggerEvent: value(tree, "MSH-9.2")?.value ?? "",
58
+ version: value(tree, "MSH-12.1")?.value ?? ""
59
+ };
63
60
  }
64
61
  function buildMsh(origin, options) {
65
- const sendApp = options.sending?.application ?? origin.receivingApp;
66
- const sendFac = options.sending?.facility ?? origin.receivingFac;
67
- const pid = options.processingId ?? origin.processingId;
68
- const controlId = options.id ?? uid();
69
- const msgType = origin.triggerEvent ? f(c("ACK"), c(origin.triggerEvent)) : f("ACK");
70
- return s(
71
- "MSH",
72
- f("|"),
73
- f("^~\\&"),
74
- f(sendApp),
75
- f(sendFac),
76
- f(origin.sendingApp),
77
- f(origin.sendingFac),
78
- f(Timestamp.now().toString()),
79
- f(""),
80
- msgType,
81
- f(controlId),
82
- f(pid),
83
- f(origin.version)
84
- );
62
+ const sendApp = options.sending?.application ?? origin.receivingApp;
63
+ const sendFac = options.sending?.facility ?? origin.receivingFac;
64
+ const pid = options.processingId ?? origin.processingId;
65
+ const controlId = options.id ?? uid();
66
+ const msgType = origin.triggerEvent ? f(c("ACK"), c(origin.triggerEvent)) : f("ACK");
67
+ return s("MSH", f("|"), f("^~\\&"), f(sendApp), f(sendFac), f(origin.sendingApp), f(origin.sendingFac), f(Timestamp.now().toString()), f(""), msgType, f(controlId), f(pid), f(origin.version));
85
68
  }
86
69
  function buildMsa(code, controlId, message) {
87
- return message ? s("MSA", f(code), f(controlId), f(message)) : s("MSA", f(code), f(controlId));
70
+ return message ? s("MSA", f(code), f(controlId), f(message)) : s("MSA", f(code), f(controlId));
88
71
  }
89
- function acknowledge(origin, {
90
- id,
91
- processingId,
92
- sending,
93
- error,
94
- includeErrSegment = true,
95
- successCode = AckCode.ApplicationAccept
96
- } = {}) {
97
- const fields = extractOriginFields(origin);
98
- const code = error?.code ?? successCode;
99
- const segments = [
100
- buildMsh(fields, {
101
- id,
102
- processingId,
103
- sending
104
- }),
105
- buildMsa(code, fields.controlId, error?.message)
106
- ];
107
- if (error && includeErrSegment) {
108
- segments.push(error.toErrSegment());
109
- }
110
- return m(...segments);
72
+ function acknowledge(origin, { id, processingId, sending, error, includeErrSegment = true, successCode = AckCode.ApplicationAccept } = {}) {
73
+ const fields = extractOriginFields(origin);
74
+ const code = error?.code ?? successCode;
75
+ const segments = [buildMsh(fields, {
76
+ id,
77
+ processingId,
78
+ sending
79
+ }), buildMsa(code, fields.controlId, error?.message)];
80
+ if (error && includeErrSegment) segments.push(error.toErrSegment());
81
+ return m(...segments);
111
82
  }
112
-
113
- // src/exception.ts
114
- import { f as f2, s as s2 } from "@rethinkhealth/hl7v2-builder";
83
+ //#endregion
84
+ //#region src/exception.ts
85
+ /**
86
+ * Abstract base class for all HL7v2 acknowledgment exceptions.
87
+ *
88
+ * Subclasses map to specific MSA-1 acknowledgment codes (Table 0008).
89
+ * Each exception carries an error code (Table 0357), optional severity
90
+ * (Table 0516), and can build its own ERR segment AST via {@link toErrSegment}.
91
+ *
92
+ * Use `instanceof AckException` to detect any ACK-level error in middleware.
93
+ */
115
94
  var AckException = class extends Error {
116
- errorCode;
117
- severity;
118
- constructor(message, options) {
119
- super(message, { cause: options.cause });
120
- this.errorCode = options.errorCode;
121
- this.severity = options.severity;
122
- }
123
- /** Build an ERR segment AST node from this exception's error code and severity. */
124
- toErrSegment() {
125
- return s2(
126
- "ERR",
127
- f2(""),
128
- f2(""),
129
- f2(this.errorCode),
130
- f2(this.severity ?? Severity.Error)
131
- );
132
- }
95
+ errorCode;
96
+ severity;
97
+ constructor(message, options) {
98
+ super(message, { cause: options.cause });
99
+ this.errorCode = options.errorCode;
100
+ this.severity = options.severity;
101
+ }
102
+ /** Build an ERR segment AST node from this exception's error code and severity. */
103
+ toErrSegment() {
104
+ return s("ERR", f(""), f(""), f(this.errorCode), f(this.severity ?? Severity.Error));
105
+ }
133
106
  };
107
+ /**
108
+ * Application-level error (MSA-1 = `AE`).
109
+ *
110
+ * Throw when the message was understood but could not be processed
111
+ * due to an application-level problem (e.g. validation failure, unknown key).
112
+ */
134
113
  var AckApplicationError = class extends AckException {
135
- code = AckCode.ApplicationError;
136
- constructor(message, options) {
137
- super(message, options);
138
- this.name = "AckApplicationError";
139
- }
114
+ code = AckCode.ApplicationError;
115
+ constructor(message, options) {
116
+ super(message, options);
117
+ this.name = "AckApplicationError";
118
+ }
140
119
  };
120
+ /**
121
+ * Application-level reject (MSA-1 = `AR`).
122
+ *
123
+ * Throw when the message is rejected outright at the application level
124
+ * (e.g. unsupported message type, unsupported version).
125
+ */
141
126
  var AckApplicationReject = class extends AckException {
142
- code = AckCode.ApplicationReject;
143
- constructor(message, options) {
144
- super(message, options);
145
- this.name = "AckApplicationReject";
146
- }
127
+ code = AckCode.ApplicationReject;
128
+ constructor(message, options) {
129
+ super(message, options);
130
+ this.name = "AckApplicationReject";
131
+ }
147
132
  };
133
+ /**
134
+ * Commit-level error (MSA-1 = `CE`).
135
+ *
136
+ * Throw when the message could not be safely persisted/committed
137
+ * (e.g. storage failure). Used in enhanced acknowledgment mode.
138
+ */
148
139
  var AckCommitError = class extends AckException {
149
- code = AckCode.CommitError;
150
- constructor(message, options) {
151
- super(message, options);
152
- this.name = "AckCommitError";
153
- }
140
+ code = AckCode.CommitError;
141
+ constructor(message, options) {
142
+ super(message, options);
143
+ this.name = "AckCommitError";
144
+ }
154
145
  };
146
+ /**
147
+ * Commit-level reject (MSA-1 = `CR`).
148
+ *
149
+ * Throw when the message is rejected at the commit level
150
+ * (e.g. message cannot be stored). Used in enhanced acknowledgment mode.
151
+ */
155
152
  var AckCommitReject = class extends AckException {
156
- code = AckCode.CommitReject;
157
- constructor(message, options) {
158
- super(message, options);
159
- this.name = "AckCommitReject";
160
- }
153
+ code = AckCode.CommitReject;
154
+ constructor(message, options) {
155
+ super(message, options);
156
+ this.name = "AckCommitReject";
157
+ }
161
158
  };
162
-
163
- // src/errors/application-internal-error.ts
159
+ //#endregion
160
+ //#region src/errors/application-internal-error.ts
161
+ /**
162
+ * Application internal error (MSA-1 = `AE`, ERR-3 = `207`, ERR-4 = `E`).
163
+ *
164
+ * Used to wrap unexpected/unknown errors that don't map to a specific
165
+ * HL7v2 error condition. This is the default error produced by
166
+ * `ackMiddleware` when a handler throws an unrecognized exception.
167
+ */
164
168
  var ApplicationInternalError = class extends AckApplicationError {
165
- constructor(message, cause) {
166
- super(message, {
167
- errorCode: Hl7ErrorCode.ApplicationInternalError,
168
- severity: Severity.Error,
169
- cause
170
- });
171
- this.name = "ApplicationInternalError";
172
- }
169
+ constructor(message, cause) {
170
+ super(message, {
171
+ errorCode: Hl7ErrorCode.ApplicationInternalError,
172
+ severity: Severity.Error,
173
+ cause
174
+ });
175
+ this.name = "ApplicationInternalError";
176
+ }
173
177
  };
174
-
175
- // src/errors/commit-internal-error.ts
178
+ //#endregion
179
+ //#region src/errors/commit-internal-error.ts
180
+ /**
181
+ * Commit-level internal error (MSA-1 = `CE`, ERR-3 = `207`, ERR-4 = `E`).
182
+ *
183
+ * Used when the message could not be persisted due to an internal
184
+ * infrastructure failure (e.g. database unavailable).
185
+ */
176
186
  var CommitInternalError = class extends AckCommitError {
177
- constructor(message, cause) {
178
- super(message, {
179
- errorCode: Hl7ErrorCode.ApplicationInternalError,
180
- severity: Severity.Error,
181
- cause
182
- });
183
- this.name = "CommitInternalError";
184
- }
187
+ constructor(message, cause) {
188
+ super(message, {
189
+ errorCode: Hl7ErrorCode.ApplicationInternalError,
190
+ severity: Severity.Error,
191
+ cause
192
+ });
193
+ this.name = "CommitInternalError";
194
+ }
185
195
  };
186
-
187
- // src/errors/unsupported-message-type-reject.ts
196
+ //#endregion
197
+ //#region src/errors/unsupported-message-type-reject.ts
198
+ /**
199
+ * Unsupported message type reject (MSA-1 = `AR`, ERR-3 = `200`, ERR-4 = `E`).
200
+ *
201
+ * Throw when the receiving application does not handle the inbound
202
+ * message type (e.g. ADT^A01 sent to a system that only accepts ORU).
203
+ */
188
204
  var UnsupportedMessageTypeReject = class extends AckApplicationReject {
189
- constructor(message) {
190
- super(message, {
191
- errorCode: Hl7ErrorCode.UnsupportedMessageType,
192
- severity: Severity.Error
193
- });
194
- this.name = "UnsupportedMessageTypeReject";
195
- }
196
- };
197
- export {
198
- AckApplicationError,
199
- AckApplicationReject,
200
- AckCode,
201
- AckCommitError,
202
- AckCommitReject,
203
- AckException,
204
- ApplicationInternalError,
205
- CommitInternalError,
206
- Hl7ErrorCode,
207
- Severity,
208
- UnsupportedMessageTypeReject,
209
- acknowledge,
210
- uid
205
+ constructor(message) {
206
+ super(message, {
207
+ errorCode: Hl7ErrorCode.UnsupportedMessageType,
208
+ severity: Severity.Error
209
+ });
210
+ this.name = "UnsupportedMessageTypeReject";
211
+ }
211
212
  };
213
+ //#endregion
214
+ export { AckApplicationError, AckApplicationReject, AckCode, AckCommitError, AckCommitReject, AckException, ApplicationInternalError, CommitInternalError, Hl7ErrorCode, Severity, UnsupportedMessageTypeReject, acknowledge, uid };
215
+
212
216
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/acknowledge.ts","../src/constants.ts","../src/uid.ts","../src/exception.ts","../src/errors/application-internal-error.ts","../src/errors/commit-internal-error.ts","../src/errors/unsupported-message-type-reject.ts"],"sourcesContent":["import type { Root, Segment } from \"@rethinkhealth/hl7v2-ast\";\nimport { c, f, m, s } from \"@rethinkhealth/hl7v2-builder\";\nimport { value } from \"@rethinkhealth/hl7v2-util-query\";\nimport { Timestamp } from \"@rethinkhealth/hl7v2-util-timestamp\";\n\nimport { AckCode } from \"./constants\";\nimport type { AckSuccessCode } from \"./constants\";\nimport type { AckException } from \"./exception\";\nimport { uid } from \"./uid\";\n\nexport interface SendingInfo {\n application: string;\n facility: string;\n}\n\nexport type AcknowledgeOptions = {\n /** Custom MSH-10 control ID. Auto-generated via `uid()` when omitted. */\n id?: string;\n /** MSH-3/MSH-4 of the ACK. Defaults to the original message's MSH-5/MSH-6. */\n sending?: SendingInfo;\n /** MSH-11 processing ID. Defaults to the original message's MSH-11. */\n processingId?: string;\n} & (\n | {\n /** Sets the ACK code (AE/AR/CE/CR) and populates MSA-3 with the error message. */\n error: AckException;\n /** Include ERR segment when an error is provided. Defaults to `true`. */\n includeErrSegment?: boolean;\n successCode?: never;\n }\n | {\n error?: never;\n includeErrSegment?: never;\n /** MSA-1 code when no error is present. Defaults to `AckCode.ApplicationAccept`. */\n successCode?: AckSuccessCode;\n }\n);\n\n// -- Field extraction ----\n\ninterface OriginFields {\n controlId: string;\n version: string;\n triggerEvent: string;\n processingId: string;\n sendingApp: string;\n sendingFac: string;\n receivingApp: string;\n receivingFac: string;\n}\n\nfunction extractOriginFields(tree: Root): OriginFields {\n return {\n controlId: value(tree, \"MSH-10\")?.value ?? \"\",\n processingId: value(tree, \"MSH-11\")?.value ?? \"P\",\n receivingApp: value(tree, \"MSH-5\")?.value ?? \"\",\n receivingFac: value(tree, \"MSH-6\")?.value ?? \"\",\n sendingApp: value(tree, \"MSH-3\")?.value ?? \"\",\n sendingFac: value(tree, \"MSH-4\")?.value ?? \"\",\n triggerEvent: value(tree, \"MSH-9.2\")?.value ?? \"\",\n version: value(tree, \"MSH-12.1\")?.value ?? \"\",\n };\n}\n\n// -- Segment builders ----\n\nfunction buildMsh(\n origin: OriginFields,\n options: Pick<AcknowledgeOptions, \"id\" | \"sending\" | \"processingId\">\n): Segment {\n const sendApp = options.sending?.application ?? origin.receivingApp;\n const sendFac = options.sending?.facility ?? origin.receivingFac;\n const pid = options.processingId ?? origin.processingId;\n const controlId = options.id ?? uid();\n const msgType = origin.triggerEvent\n ? f(c(\"ACK\"), c(origin.triggerEvent))\n : f(\"ACK\");\n\n return s(\n \"MSH\",\n f(\"|\"),\n f(\"^~\\\\&\"),\n f(sendApp),\n f(sendFac),\n f(origin.sendingApp),\n f(origin.sendingFac),\n f(Timestamp.now().toString()),\n f(\"\"),\n msgType,\n f(controlId),\n f(pid),\n f(origin.version)\n );\n}\n\nfunction buildMsa(code: string, controlId: string, message?: string): Segment {\n return message\n ? s(\"MSA\", f(code), f(controlId), f(message))\n : s(\"MSA\", f(code), f(controlId));\n}\n\n// -- Public API ----\n\nexport function acknowledge(\n origin: Root,\n {\n id,\n processingId,\n sending,\n error,\n includeErrSegment = true,\n successCode = AckCode.ApplicationAccept,\n }: AcknowledgeOptions = {}\n): Root {\n const fields = extractOriginFields(origin);\n const code = error?.code ?? successCode;\n\n const segments: Segment[] = [\n buildMsh(fields, {\n id,\n processingId,\n sending,\n }),\n buildMsa(code, fields.controlId, error?.message),\n ];\n\n if (error && includeErrSegment) {\n segments.push(error.toErrSegment());\n }\n\n return m(...segments);\n}\n","/** HL7v2 Table 0008 — Acknowledgment codes used in MSA-1. */\nexport const AckCode = {\n ApplicationAccept: \"AA\",\n ApplicationError: \"AE\",\n ApplicationReject: \"AR\",\n CommitAccept: \"CA\",\n CommitError: \"CE\",\n CommitReject: \"CR\",\n} as const;\n\nexport type AckCodeValue = (typeof AckCode)[keyof typeof AckCode];\n\n/** Accept codes used as `successCode` in `acknowledge()`. */\nexport type AckSuccessCode =\n | typeof AckCode.ApplicationAccept\n | typeof AckCode.CommitAccept;\n\n/** HL7v2 Table 0357 — Message error condition codes used in ERR-3. Stable across all versions (v2.1–v2.9). */\nexport const Hl7ErrorCode = {\n MessageAccepted: \"0\",\n SegmentSequenceError: \"100\",\n RequiredFieldMissing: \"101\",\n DataTypeError: \"102\",\n TableValueNotFound: \"103\",\n UnsupportedMessageType: \"200\",\n UnsupportedEventCode: \"201\",\n UnsupportedProcessingId: \"202\",\n UnsupportedVersionId: \"203\",\n UnknownKeyIdentifier: \"204\",\n DuplicateKeyIdentifier: \"205\",\n ApplicationRecordLocked: \"206\",\n ApplicationInternalError: \"207\",\n} as const;\n\nexport type Hl7ErrorCodeValue =\n (typeof Hl7ErrorCode)[keyof typeof Hl7ErrorCode];\n\n/** HL7v2 Table 0516 — Error severity codes used in ERR-4. */\nexport const Severity = {\n Info: \"I\",\n Warning: \"W\",\n Error: \"E\",\n} as const;\n\nexport type SeverityValue = (typeof Severity)[keyof typeof Severity];\n","import { nanoid } from \"nanoid\";\n\nconst MAX_LENGTH = 20;\n\nexport interface Options {\n prefix?: string;\n size?: number;\n}\n\nexport function uid(options: Options = {}): string {\n const { prefix, size = MAX_LENGTH } = options;\n\n if (!prefix) {\n return nanoid(size);\n }\n\n const remaining = size - prefix.length;\n\n if (remaining <= 0) {\n return prefix.slice(0, size);\n }\n\n return `${prefix}${nanoid(remaining)}`;\n}\n","import type { Segment } from \"@rethinkhealth/hl7v2-ast\";\nimport { f, s } from \"@rethinkhealth/hl7v2-builder\";\n\nimport { AckCode, Severity } from \"./constants\";\nimport type {\n AckCodeValue,\n Hl7ErrorCodeValue,\n SeverityValue,\n} from \"./constants\";\n\nexport interface AckExceptionOptions extends ErrorOptions {\n errorCode: Hl7ErrorCodeValue;\n severity?: SeverityValue;\n}\n\n/**\n * Abstract base class for all HL7v2 acknowledgment exceptions.\n *\n * Subclasses map to specific MSA-1 acknowledgment codes (Table 0008).\n * Each exception carries an error code (Table 0357), optional severity\n * (Table 0516), and can build its own ERR segment AST via {@link toErrSegment}.\n *\n * Use `instanceof AckException` to detect any ACK-level error in middleware.\n */\nexport abstract class AckException extends Error {\n abstract readonly code: AckCodeValue;\n readonly errorCode: Hl7ErrorCodeValue;\n readonly severity: SeverityValue | undefined;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, { cause: options.cause });\n this.errorCode = options.errorCode;\n this.severity = options.severity;\n }\n\n /** Build an ERR segment AST node from this exception's error code and severity. */\n toErrSegment(): Segment {\n return s(\n \"ERR\",\n f(\"\"),\n f(\"\"),\n f(this.errorCode),\n f(this.severity ?? Severity.Error)\n );\n }\n}\n\n/**\n * Application-level error (MSA-1 = `AE`).\n *\n * Throw when the message was understood but could not be processed\n * due to an application-level problem (e.g. validation failure, unknown key).\n */\nexport class AckApplicationError extends AckException {\n readonly code = AckCode.ApplicationError;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckApplicationError\";\n }\n}\n\n/**\n * Application-level reject (MSA-1 = `AR`).\n *\n * Throw when the message is rejected outright at the application level\n * (e.g. unsupported message type, unsupported version).\n */\nexport class AckApplicationReject extends AckException {\n readonly code = AckCode.ApplicationReject;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckApplicationReject\";\n }\n}\n\n/**\n * Commit-level error (MSA-1 = `CE`).\n *\n * Throw when the message could not be safely persisted/committed\n * (e.g. storage failure). Used in enhanced acknowledgment mode.\n */\nexport class AckCommitError extends AckException {\n readonly code = AckCode.CommitError;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckCommitError\";\n }\n}\n\n/**\n * Commit-level reject (MSA-1 = `CR`).\n *\n * Throw when the message is rejected at the commit level\n * (e.g. message cannot be stored). Used in enhanced acknowledgment mode.\n */\nexport class AckCommitReject extends AckException {\n readonly code = AckCode.CommitReject;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckCommitReject\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckApplicationError } from \"../exception\";\n\n/**\n * Application internal error (MSA-1 = `AE`, ERR-3 = `207`, ERR-4 = `E`).\n *\n * Used to wrap unexpected/unknown errors that don't map to a specific\n * HL7v2 error condition. This is the default error produced by\n * `ackMiddleware` when a handler throws an unrecognized exception.\n */\nexport class ApplicationInternalError extends AckApplicationError {\n constructor(message: string, cause?: Error) {\n super(message, {\n errorCode: Hl7ErrorCode.ApplicationInternalError,\n severity: Severity.Error,\n cause,\n });\n this.name = \"ApplicationInternalError\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckCommitError } from \"../exception\";\n\n/**\n * Commit-level internal error (MSA-1 = `CE`, ERR-3 = `207`, ERR-4 = `E`).\n *\n * Used when the message could not be persisted due to an internal\n * infrastructure failure (e.g. database unavailable).\n */\nexport class CommitInternalError extends AckCommitError {\n constructor(message: string, cause?: Error) {\n super(message, {\n errorCode: Hl7ErrorCode.ApplicationInternalError,\n severity: Severity.Error,\n cause,\n });\n this.name = \"CommitInternalError\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckApplicationReject } from \"../exception\";\n\n/**\n * Unsupported message type reject (MSA-1 = `AR`, ERR-3 = `200`, ERR-4 = `E`).\n *\n * Throw when the receiving application does not handle the inbound\n * message type (e.g. ADT^A01 sent to a system that only accepts ORU).\n */\nexport class UnsupportedMessageTypeReject extends AckApplicationReject {\n constructor(message: string) {\n super(message, {\n errorCode: Hl7ErrorCode.UnsupportedMessageType,\n severity: Severity.Error,\n });\n this.name = \"UnsupportedMessageTypeReject\";\n }\n}\n"],"mappings":";AACA,SAAS,GAAG,GAAG,GAAG,SAAS;AAC3B,SAAS,aAAa;AACtB,SAAS,iBAAiB;;;ACFnB,IAAM,UAAU;AAAA,EACrB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,aAAa;AAAA,EACb,cAAc;AAChB;AAUO,IAAM,eAAe;AAAA,EAC1B,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,sBAAsB;AAAA,EACtB,yBAAyB;AAAA,EACzB,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,yBAAyB;AAAA,EACzB,0BAA0B;AAC5B;AAMO,IAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AACT;;;AC1CA,SAAS,cAAc;AAEvB,IAAM,aAAa;AAOZ,SAAS,IAAI,UAAmB,CAAC,GAAW;AACjD,QAAM,EAAE,QAAQ,OAAO,WAAW,IAAI;AAEtC,MAAI,CAAC,QAAQ;AACX,WAAO,OAAO,IAAI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,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAQO,IAAM,uBAAN,cAAmC,aAAa;AAAA,EAC5C,OAAO,QAAQ;AAAA,EAExB,YAAY,SAAiB,SAA8B;AACzD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAQO,IAAM,iBAAN,cAA6B,aAAa;AAAA,EACtC,OAAO,QAAQ;AAAA,EAExB,YAAY,SAAiB,SAA8B;AACzD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAQO,IAAM,kBAAN,cAA8B,aAAa;AAAA,EACvC,OAAO,QAAQ;AAAA,EAExB,YAAY,SAAiB,SAA8B;AACzD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;;;AC/FO,IAAM,2BAAN,cAAuC,oBAAoB;AAAA,EAChE,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS;AAAA,MACb,WAAW,aAAa;AAAA,MACxB,UAAU,SAAS;AAAA,MACnB;AAAA,IACF,CAAC;AACD,SAAK,OAAO;AAAA,EACd;AACF;;;ACVO,IAAM,sBAAN,cAAkC,eAAe;AAAA,EACtD,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS;AAAA,MACb,WAAW,aAAa;AAAA,MACxB,UAAU,SAAS;AAAA,MACnB;AAAA,IACF,CAAC;AACD,SAAK,OAAO;AAAA,EACd;AACF;;;ACTO,IAAM,+BAAN,cAA2C,qBAAqB;AAAA,EACrE,YAAY,SAAiB;AAC3B,UAAM,SAAS;AAAA,MACb,WAAW,aAAa;AAAA,MACxB,UAAU,SAAS;AAAA,IACrB,CAAC;AACD,SAAK,OAAO;AAAA,EACd;AACF;","names":["f","s","s","f"]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/constants.ts","../src/uid.ts","../src/acknowledge.ts","../src/exception.ts","../src/errors/application-internal-error.ts","../src/errors/commit-internal-error.ts","../src/errors/unsupported-message-type-reject.ts"],"sourcesContent":["/** HL7v2 Table 0008 — Acknowledgment codes used in MSA-1. */\nexport const AckCode = {\n ApplicationAccept: \"AA\",\n ApplicationError: \"AE\",\n ApplicationReject: \"AR\",\n CommitAccept: \"CA\",\n CommitError: \"CE\",\n CommitReject: \"CR\",\n} as const;\n\nexport type AckCodeValue = (typeof AckCode)[keyof typeof AckCode];\n\n/** Accept codes used as `successCode` in `acknowledge()`. */\nexport type AckSuccessCode =\n | typeof AckCode.ApplicationAccept\n | typeof AckCode.CommitAccept;\n\n/** HL7v2 Table 0357 — Message error condition codes used in ERR-3. Stable across all versions (v2.1–v2.9). */\nexport const Hl7ErrorCode = {\n MessageAccepted: \"0\",\n SegmentSequenceError: \"100\",\n RequiredFieldMissing: \"101\",\n DataTypeError: \"102\",\n TableValueNotFound: \"103\",\n UnsupportedMessageType: \"200\",\n UnsupportedEventCode: \"201\",\n UnsupportedProcessingId: \"202\",\n UnsupportedVersionId: \"203\",\n UnknownKeyIdentifier: \"204\",\n DuplicateKeyIdentifier: \"205\",\n ApplicationRecordLocked: \"206\",\n ApplicationInternalError: \"207\",\n} as const;\n\nexport type Hl7ErrorCodeValue =\n (typeof Hl7ErrorCode)[keyof typeof Hl7ErrorCode];\n\n/** HL7v2 Table 0516 — Error severity codes used in ERR-4. */\nexport const Severity = {\n Info: \"I\",\n Warning: \"W\",\n Error: \"E\",\n} as const;\n\nexport type SeverityValue = (typeof Severity)[keyof typeof Severity];\n","import { nanoid } from \"nanoid\";\n\nconst MAX_LENGTH = 20;\n\nexport interface Options {\n prefix?: string;\n size?: number;\n}\n\nexport function uid(options: Options = {}): string {\n const { prefix, size = MAX_LENGTH } = options;\n\n if (!prefix) {\n return nanoid(size);\n }\n\n const remaining = size - prefix.length;\n\n if (remaining <= 0) {\n return prefix.slice(0, size);\n }\n\n return `${prefix}${nanoid(remaining)}`;\n}\n","import type { Root, Segment } from \"@rethinkhealth/hl7v2-ast\";\nimport { c, f, m, s } from \"@rethinkhealth/hl7v2-builder\";\nimport { value } from \"@rethinkhealth/hl7v2-util-query\";\nimport { Timestamp } from \"@rethinkhealth/hl7v2-util-timestamp\";\n\nimport { AckCode } from \"./constants\";\nimport type { AckSuccessCode } from \"./constants\";\nimport type { AckException } from \"./exception\";\nimport { uid } from \"./uid\";\n\nexport interface SendingInfo {\n application: string;\n facility: string;\n}\n\nexport type AcknowledgeOptions = {\n /** Custom MSH-10 control ID. Auto-generated via `uid()` when omitted. */\n id?: string;\n /** MSH-3/MSH-4 of the ACK. Defaults to the original message's MSH-5/MSH-6. */\n sending?: SendingInfo;\n /** MSH-11 processing ID. Defaults to the original message's MSH-11. */\n processingId?: string;\n} & (\n | {\n /** Sets the ACK code (AE/AR/CE/CR) and populates MSA-3 with the error message. */\n error: AckException;\n /** Include ERR segment when an error is provided. Defaults to `true`. */\n includeErrSegment?: boolean;\n successCode?: never;\n }\n | {\n error?: never;\n includeErrSegment?: never;\n /** MSA-1 code when no error is present. Defaults to `AckCode.ApplicationAccept`. */\n successCode?: AckSuccessCode;\n }\n);\n\n// -- Field extraction ----\n\ninterface OriginFields {\n controlId: string;\n version: string;\n triggerEvent: string;\n processingId: string;\n sendingApp: string;\n sendingFac: string;\n receivingApp: string;\n receivingFac: string;\n}\n\nfunction extractOriginFields(tree: Root): OriginFields {\n return {\n controlId: value(tree, \"MSH-10\")?.value ?? \"\",\n processingId: value(tree, \"MSH-11\")?.value ?? \"P\",\n receivingApp: value(tree, \"MSH-5\")?.value ?? \"\",\n receivingFac: value(tree, \"MSH-6\")?.value ?? \"\",\n sendingApp: value(tree, \"MSH-3\")?.value ?? \"\",\n sendingFac: value(tree, \"MSH-4\")?.value ?? \"\",\n triggerEvent: value(tree, \"MSH-9.2\")?.value ?? \"\",\n version: value(tree, \"MSH-12.1\")?.value ?? \"\",\n };\n}\n\n// -- Segment builders ----\n\nfunction buildMsh(\n origin: OriginFields,\n options: Pick<AcknowledgeOptions, \"id\" | \"sending\" | \"processingId\">\n): Segment {\n const sendApp = options.sending?.application ?? origin.receivingApp;\n const sendFac = options.sending?.facility ?? origin.receivingFac;\n const pid = options.processingId ?? origin.processingId;\n const controlId = options.id ?? uid();\n const msgType = origin.triggerEvent\n ? f(c(\"ACK\"), c(origin.triggerEvent))\n : f(\"ACK\");\n\n return s(\n \"MSH\",\n f(\"|\"),\n f(\"^~\\\\&\"),\n f(sendApp),\n f(sendFac),\n f(origin.sendingApp),\n f(origin.sendingFac),\n f(Timestamp.now().toString()),\n f(\"\"),\n msgType,\n f(controlId),\n f(pid),\n f(origin.version)\n );\n}\n\nfunction buildMsa(code: string, controlId: string, message?: string): Segment {\n return message\n ? s(\"MSA\", f(code), f(controlId), f(message))\n : s(\"MSA\", f(code), f(controlId));\n}\n\n// -- Public API ----\n\nexport function acknowledge(\n origin: Root,\n {\n id,\n processingId,\n sending,\n error,\n includeErrSegment = true,\n successCode = AckCode.ApplicationAccept,\n }: AcknowledgeOptions = {}\n): Root {\n const fields = extractOriginFields(origin);\n const code = error?.code ?? successCode;\n\n const segments: Segment[] = [\n buildMsh(fields, {\n id,\n processingId,\n sending,\n }),\n buildMsa(code, fields.controlId, error?.message),\n ];\n\n if (error && includeErrSegment) {\n segments.push(error.toErrSegment());\n }\n\n return m(...segments);\n}\n","import type { Segment } from \"@rethinkhealth/hl7v2-ast\";\nimport { f, s } from \"@rethinkhealth/hl7v2-builder\";\n\nimport { AckCode, Severity } from \"./constants\";\nimport type {\n AckCodeValue,\n Hl7ErrorCodeValue,\n SeverityValue,\n} from \"./constants\";\n\nexport interface AckExceptionOptions extends ErrorOptions {\n errorCode: Hl7ErrorCodeValue;\n severity?: SeverityValue;\n}\n\n/**\n * Abstract base class for all HL7v2 acknowledgment exceptions.\n *\n * Subclasses map to specific MSA-1 acknowledgment codes (Table 0008).\n * Each exception carries an error code (Table 0357), optional severity\n * (Table 0516), and can build its own ERR segment AST via {@link toErrSegment}.\n *\n * Use `instanceof AckException` to detect any ACK-level error in middleware.\n */\nexport abstract class AckException extends Error {\n abstract readonly code: AckCodeValue;\n readonly errorCode: Hl7ErrorCodeValue;\n readonly severity: SeverityValue | undefined;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, { cause: options.cause });\n this.errorCode = options.errorCode;\n this.severity = options.severity;\n }\n\n /** Build an ERR segment AST node from this exception's error code and severity. */\n toErrSegment(): Segment {\n return s(\n \"ERR\",\n f(\"\"),\n f(\"\"),\n f(this.errorCode),\n f(this.severity ?? Severity.Error)\n );\n }\n}\n\n/**\n * Application-level error (MSA-1 = `AE`).\n *\n * Throw when the message was understood but could not be processed\n * due to an application-level problem (e.g. validation failure, unknown key).\n */\nexport class AckApplicationError extends AckException {\n readonly code = AckCode.ApplicationError;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckApplicationError\";\n }\n}\n\n/**\n * Application-level reject (MSA-1 = `AR`).\n *\n * Throw when the message is rejected outright at the application level\n * (e.g. unsupported message type, unsupported version).\n */\nexport class AckApplicationReject extends AckException {\n readonly code = AckCode.ApplicationReject;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckApplicationReject\";\n }\n}\n\n/**\n * Commit-level error (MSA-1 = `CE`).\n *\n * Throw when the message could not be safely persisted/committed\n * (e.g. storage failure). Used in enhanced acknowledgment mode.\n */\nexport class AckCommitError extends AckException {\n readonly code = AckCode.CommitError;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckCommitError\";\n }\n}\n\n/**\n * Commit-level reject (MSA-1 = `CR`).\n *\n * Throw when the message is rejected at the commit level\n * (e.g. message cannot be stored). Used in enhanced acknowledgment mode.\n */\nexport class AckCommitReject extends AckException {\n readonly code = AckCode.CommitReject;\n\n constructor(message: string, options: AckExceptionOptions) {\n super(message, options);\n this.name = \"AckCommitReject\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckApplicationError } from \"../exception\";\n\n/**\n * Application internal error (MSA-1 = `AE`, ERR-3 = `207`, ERR-4 = `E`).\n *\n * Used to wrap unexpected/unknown errors that don't map to a specific\n * HL7v2 error condition. This is the default error produced by\n * `ackMiddleware` when a handler throws an unrecognized exception.\n */\nexport class ApplicationInternalError extends AckApplicationError {\n constructor(message: string, cause?: Error) {\n super(message, {\n errorCode: Hl7ErrorCode.ApplicationInternalError,\n severity: Severity.Error,\n cause,\n });\n this.name = \"ApplicationInternalError\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckCommitError } from \"../exception\";\n\n/**\n * Commit-level internal error (MSA-1 = `CE`, ERR-3 = `207`, ERR-4 = `E`).\n *\n * Used when the message could not be persisted due to an internal\n * infrastructure failure (e.g. database unavailable).\n */\nexport class CommitInternalError extends AckCommitError {\n constructor(message: string, cause?: Error) {\n super(message, {\n errorCode: Hl7ErrorCode.ApplicationInternalError,\n severity: Severity.Error,\n cause,\n });\n this.name = \"CommitInternalError\";\n }\n}\n","import { Hl7ErrorCode, Severity } from \"../constants\";\nimport { AckApplicationReject } from \"../exception\";\n\n/**\n * Unsupported message type reject (MSA-1 = `AR`, ERR-3 = `200`, ERR-4 = `E`).\n *\n * Throw when the receiving application does not handle the inbound\n * message type (e.g. ADT^A01 sent to a system that only accepts ORU).\n */\nexport class UnsupportedMessageTypeReject extends AckApplicationReject {\n constructor(message: string) {\n super(message, {\n errorCode: Hl7ErrorCode.UnsupportedMessageType,\n severity: Severity.Error,\n });\n this.name = \"UnsupportedMessageTypeReject\";\n }\n}\n"],"mappings":";;;;;;AACA,MAAa,UAAU;CACrB,mBAAmB;CACnB,kBAAkB;CAClB,mBAAmB;CACnB,cAAc;CACd,aAAa;CACb,cAAc;CACf;;AAUD,MAAa,eAAe;CAC1B,iBAAiB;CACjB,sBAAsB;CACtB,sBAAsB;CACtB,eAAe;CACf,oBAAoB;CACpB,wBAAwB;CACxB,sBAAsB;CACtB,yBAAyB;CACzB,sBAAsB;CACtB,sBAAsB;CACtB,wBAAwB;CACxB,yBAAyB;CACzB,0BAA0B;CAC3B;;AAMD,MAAa,WAAW;C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B,SAA8B;AACzD,QAAM,SAAS,QAAQ;AACvB,OAAK,OAAO;;;;;;;;;AAUhB,IAAa,kBAAb,cAAqC,aAAa;CAChD,OAAgB,QAAQ;CAExB,YAAY,SAAiB,SAA8B;AACzD,QAAM,SAAS,QAAQ;AACvB,OAAK,OAAO;;;;;;;;;;;;AC7FhB,IAAa,2BAAb,cAA8C,oBAAoB;CAChE,YAAY,SAAiB,OAAe;AAC1C,QAAM,SAAS;GACb,WAAW,aAAa;GACxB,UAAU,SAAS;GACnB;GACD,CAAC;AACF,OAAK,OAAO;;;;;;;;;;;ACRhB,IAAa,sBAAb,cAAyC,eAAe;CACtD,YAAY,SAAiB,OAAe;AAC1C,QAAM,SAAS;GACb,WAAW,aAAa;GACxB,UAAU,SAAS;GACnB;GACD,CAAC;AACF,OAAK,OAAO;;;;;;;;;;;ACPhB,IAAa,+BAAb,cAAkD,qBAAqB;CACrE,YAAY,SAAiB;AAC3B,QAAM,SAAS;GACb,WAAW,aAAa;GACxB,UAAU,SAAS;GACpB,CAAC;AACF,OAAK,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rethinkhealth/hl7v2-ack",
3
- "version": "0.12.0",
3
+ "version": "0.13.1",
4
4
  "description": "HL7v2 acknowledgment message builder and typed error classes",
5
5
  "keywords": [
6
6
  "ack",
@@ -31,19 +31,19 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "nanoid": "5.1.7",
34
- "@rethinkhealth/hl7v2-builder": "0.12.0",
35
- "@rethinkhealth/hl7v2-ast": "0.12.0",
36
- "@rethinkhealth/hl7v2-util-query": "0.12.0",
37
- "@rethinkhealth/hl7v2-util-timestamp": "0.12.0"
34
+ "@rethinkhealth/hl7v2-ast": "0.13.1",
35
+ "@rethinkhealth/hl7v2-builder": "0.13.1",
36
+ "@rethinkhealth/hl7v2-util-query": "0.13.1",
37
+ "@rethinkhealth/hl7v2-util-timestamp": "0.13.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^25.5.0",
41
41
  "@vitest/coverage-v8": "4.1.0",
42
- "tsup": "^8.5.1",
42
+ "tsdown": "0.21.7",
43
43
  "typescript": "^5.9.3",
44
44
  "vitest": "4.1.0",
45
+ "@rethinkhealth/hl7v2-to-hl7v2": "0.13.1",
45
46
  "@rethinkhealth/testing": "0.0.2",
46
- "@rethinkhealth/hl7v2-to-hl7v2": "0.12.0",
47
47
  "@rethinkhealth/tsconfig": "0.0.1"
48
48
  },
49
49
  "engines": {
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "packageManager": "pnpm@10.14.0",
53
53
  "scripts": {
54
- "build": "tsup && tsc --emitDeclarationOnly",
54
+ "build": "tsdown && tsc --emitDeclarationOnly",
55
55
  "check-types": "tsc --noEmit",
56
56
  "test": "vitest run",
57
57
  "test:coverage": "vitest run --coverage",