cda-schematron-validator 1.1.12 → 2.0.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -9
- package/README.md +222 -243
- package/bin/cda-validate.js +36 -0
- package/docs/api.md +134 -0
- package/docs/architecture.md +102 -0
- package/docs/coverage.md +112 -0
- package/docs/deployment.md +126 -0
- package/docs/history.md +245 -0
- package/docs/legacy-api.md +70 -0
- package/lib/checkIfFileOrPath.js +27 -28
- package/lib/checkRule.js +97 -98
- package/lib/createClient.js +35 -0
- package/lib/getAssertionObject.js +23 -23
- package/lib/getErrorsAndWarnings.js +41 -41
- package/lib/getFailedAssertions.js +24 -25
- package/lib/getIgnored.js +27 -27
- package/lib/getResults.js +22 -22
- package/lib/getReturnObject.js +20 -20
- package/lib/getSchematronMap.js +34 -31
- package/lib/getSelectXmlChunk.js +27 -27
- package/lib/includeExternalDocument.js +113 -107
- package/lib/initializeProcess.js +34 -40
- package/lib/parseSchematron.js +122 -122
- package/lib/processFailedAssertions.js +17 -17
- package/lib/processRules.js +20 -20
- package/lib/processRulesAsync.js +18 -30
- package/lib/testAssertion.js +74 -74
- package/package.json +67 -59
- package/validateAsync.js +103 -117
- package/validateSync.js +51 -55
- package/validator.d.ts +87 -0
- package/validator.js +17 -16
- package/.eslintrc.js +0 -30
- package/.github/workflows/codeql-analysis.yml +0 -70
- package/.husky/pre-commit +0 -5
- package/.jshintrc +0 -96
- package/.vscode/launch.json +0 -37
- package/Gruntfile.js +0 -28
- package/SECURITY.md +0 -21
- package/test/CDAR2_IG_CCDA_CLINNOTES_R1_DSTU2.1_2015AUG_Vol2_2019JUNwith_errata.sch +0 -71
- package/test/VitalSigns.xml +0 -856
- package/test/async.test.js +0 -124
- package/test/asyncFileList.test.js +0 -61
- package/test/test.sch +0 -47
- package/test/test.xml +0 -80
- package/test/tests.js +0 -140
- package/test/vitalSigns.test.js +0 -34
- package/test/voc.xml +0 -44
package/LICENSE.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
License (MIT)
|
|
2
|
-
Copyright © 2017 Eric Wadkins
|
|
3
|
-
|
|
4
|
-
Copyright © 2022 Priyaranjan (Raj) Tokachichu
|
|
5
|
-
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
-
|
|
8
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
-
|
|
1
|
+
License (MIT)
|
|
2
|
+
Copyright © 2017 Eric Wadkins
|
|
3
|
+
|
|
4
|
+
Copyright © 2022 Priyaranjan (Raj) Tokachichu
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
10
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,243 +1,222 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
### Cache
|
|
224
|
-
|
|
225
|
-
The validator uses a cache to store parsed schematrons, an intermediate data structure used to store revelant schematron information. This reduces the runtime of the validator when validating against the same schematron multiple times. You can clear the cache at any time with:
|
|
226
|
-
|
|
227
|
-
```javascript
|
|
228
|
-
validator.clearCache();
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
## License (MIT)
|
|
234
|
-
|
|
235
|
-
Copyright © 2017 [Eric Wadkins](http://www.ericwadkins.com/)
|
|
236
|
-
|
|
237
|
-
Copyright © 2022 [Priyaranjan (Raj) Tokachichu](https://github.com/priyaranjan-tokachichu)
|
|
238
|
-
|
|
239
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
240
|
-
|
|
241
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
242
|
-
|
|
243
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<h1>CDA Validator</h1>
|
|
4
|
+
<p><strong>Validate clinical XML. Understand every finding.</strong></p>
|
|
5
|
+
<p>A self-hosted API and browser workspace for CDA and C-CDA,<br>with the original JavaScript APIs preserved.</p>
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
<a href="#quick-start">Quick start</a> ·
|
|
9
|
+
<a href="docs/api.md">API reference</a> ·
|
|
10
|
+
<a href="docs/deployment.md">Deployment</a> ·
|
|
11
|
+
<a href="docs/architecture.md">Architecture</a> ·
|
|
12
|
+
<a href="docs/legacy-api.md">Legacy API</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
> [!NOTE]
|
|
20
|
+
> **Version 2.0.0-preview.1.** The container includes the validation API and browser UI. The npm package includes the preserved legacy APIs, a typed HTTP client, and the CLI. Node 22.12+ is required. This is a preview while C-CDA 5.0 coverage gaps are addressed; npm’s stable default remains 1.1.12. See the [release notes](https://github.com/priyaranjan-tokachichu/cda-schematron-validator/releases/tag/v2.0.0-preview.1) for artifacts and compatibility details.
|
|
21
|
+
|
|
22
|
+
<table>
|
|
23
|
+
<tr>
|
|
24
|
+
<td width="50%"><h3>Findings you can investigate</h3><p>XML parsing, CDA schema validation, and official HL7 Schematron checks. Reports include severity, rule identifiers, XPath, and available line/column locations.</p></td>
|
|
25
|
+
<td width="50%"><h3>A workspace anyone can use</h3><p>Upload or paste XML, choose an implementation guide, inspect errors and warnings, jump to a line, and download the JSON report.</p></td>
|
|
26
|
+
</tr>
|
|
27
|
+
<tr>
|
|
28
|
+
<td width="50%"><h3>Self-hosted and offline at runtime</h3><p>One container includes the UI, API, Java runtime, and pinned validation resources. Submitted documents are not persisted or sent to external validation services.</p></td>
|
|
29
|
+
<td width="50%"><h3>Existing integrations preserved</h3><p>The seven legacy npm exports remain available locally. A new typed HTTP client and CLI connect applications to the modern validation engine.</p></td>
|
|
30
|
+
</tr>
|
|
31
|
+
</table>
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
Install Docker with Compose, then:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
git clone https://github.com/priyaranjan-tokachichu/cda-schematron-validator.git
|
|
39
|
+
cd cda-schematron-validator
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Start the service:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
docker compose up --build -d
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Open [the validation workspace](http://localhost:17643).** Try the synthetic example, or upload a UTF-8 XML document. The example intentionally contains errors so you can explore the findings.
|
|
49
|
+
|
|
50
|
+
| Open locally | Purpose |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| [Workspace](http://localhost:17643/) | Upload, paste, validate, and inspect findings |
|
|
53
|
+
| [Architecture report](http://localhost:17643/architecture.html) | Design, sources, limitations, and verification evidence |
|
|
54
|
+
| [OpenAPI contract](http://localhost:17643/openapi.json) | Integrate the HTTP API |
|
|
55
|
+
| [Readiness](http://localhost:17643/health/ready) | Confirm the profiles have compiled |
|
|
56
|
+
|
|
57
|
+
The first build downloads checksum-verified resources and dependencies. Normal validation runs offline. You do not need to install Java, Maven, Python, or Node on the host to run the container.
|
|
58
|
+
|
|
59
|
+
<details>
|
|
60
|
+
<summary><strong>Change the port, inspect logs, or stop the service</strong></summary>
|
|
61
|
+
|
|
62
|
+
The default host port is **17643**, bound to loopback. Choose a different port if needed:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
CDA_VALIDATOR_PORT=17644 docker compose up -d
|
|
66
|
+
docker compose logs validator
|
|
67
|
+
docker compose down
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
When changing the port, use the matching URL in browsers and API clients. See [deployment and configuration](docs/deployment.md).
|
|
71
|
+
|
|
72
|
+
</details>
|
|
73
|
+
|
|
74
|
+
## Choose your integration
|
|
75
|
+
|
|
76
|
+
| Use case | Interface | Runtime |
|
|
77
|
+
| --- | --- | --- |
|
|
78
|
+
| Validate a document manually | Browser workspace | Docker |
|
|
79
|
+
| Integrate any application or language | `POST /v1/validate` | HTTP + JSON |
|
|
80
|
+
| Integrate a Node application | `createClient()` | Node 22.12+ and the service |
|
|
81
|
+
| Validate from a terminal or script | `cda-validate` | Node 22.12+ and the service |
|
|
82
|
+
| Keep an existing JavaScript integration | Original `validate*`, parser, and cache APIs | Node only; no Java or Docker |
|
|
83
|
+
|
|
84
|
+
The legacy API remains a partial Schematron interpreter. Use the service for CDA XSD validation and execution of the pinned full official Schematron packages.
|
|
85
|
+
|
|
86
|
+
## Supported standards
|
|
87
|
+
|
|
88
|
+
| Profile | Official Schematron release | CDA schema |
|
|
89
|
+
| --- | --- | --- |
|
|
90
|
+
| **C-CDA 2.1** · `ccda-2.1` | `2025SEP`, with bundled vocabulary | CDA R2 + SDTC `20260205_SDTC` |
|
|
91
|
+
| **C-CDA 5.0** · `ccda-5.0` · default | `2026JUL` | CDA R2 + SDTC `20260205_SDTC` |
|
|
92
|
+
|
|
93
|
+
Sources are pinned by immutable release URL and SHA-256. The build verifies downloads; startup verifies extracted files. `GET /v1/profiles` exposes provenance, active limits, and known coverage gaps. [Inspect the source lock](profiles/sources.lock.json).
|
|
94
|
+
|
|
95
|
+
> [!IMPORTANT]
|
|
96
|
+
> **C-CDA 5.0 has known upstream conversion gaps:** 4 generation errors, 6 unhandled invariants across 4 categories, and 28 non-loaded value-set entries across 9 categories. Its embedded value-set expansions cover sets with fewer than 1,000 concepts. The service reports incomplete coverage even when execution succeeds. A supported document-level template is required for complete document validation; nested templates alone are insufficient.
|
|
97
|
+
|
|
98
|
+
Neither profile certifies clinical accuracy or every terminology requirement. See [standards, provenance, and coverage](docs/architecture.md#standards-and-coverage).
|
|
99
|
+
|
|
100
|
+
## Call the API
|
|
101
|
+
|
|
102
|
+
Save this minimal example as `request.json`. It intentionally produces validation findings:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"xml": "<ClinicalDocument xmlns=\"urn:hl7-org:v3\"/>",
|
|
107
|
+
"profile": "ccda-2.1",
|
|
108
|
+
"includeWarnings": true
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
curl http://localhost:17643/v1/validate \
|
|
114
|
+
-H 'Content-Type: application/json' \
|
|
115
|
+
--data-binary @request.json
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| Report status | Meaning |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| `valid` | No errors; configured checks and document coverage completed without recorded generation gaps or truncation |
|
|
121
|
+
| `invalid` | Errors found; inspect completeness separately |
|
|
122
|
+
| `incomplete` | No errors found, but execution or coverage is incomplete; this is not a pass |
|
|
123
|
+
|
|
124
|
+
**HTTP 200 means a report was produced, not that the document passed.** Inspect `status`, `executionComplete`, `validationComplete`, and `findings`.
|
|
125
|
+
|
|
126
|
+
[Request/response examples, endpoints, authentication, and error codes →](docs/api.md)
|
|
127
|
+
|
|
128
|
+
## JavaScript, TypeScript, and CLI
|
|
129
|
+
|
|
130
|
+
Install the package into your Node project:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
npm install cda-schematron-validator@next
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
const { createClient } = require('cda-schematron-validator');
|
|
138
|
+
const { readFileSync } = require('node:fs');
|
|
139
|
+
|
|
140
|
+
async function main() {
|
|
141
|
+
const client = createClient({ baseUrl: 'http://localhost:17643' });
|
|
142
|
+
const report = await client.validate(readFileSync('document.xml', 'utf8'), {
|
|
143
|
+
profile: 'ccda-2.1',
|
|
144
|
+
includeWarnings: true
|
|
145
|
+
});
|
|
146
|
+
console.log(report.status, report.findings);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
main().catch(error => {
|
|
150
|
+
console.error(error.message);
|
|
151
|
+
process.exitCode = 1;
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
From the checkout, with the service running:
|
|
156
|
+
|
|
157
|
+
```sh
|
|
158
|
+
node bin/cda-validate.js document.xml --profile ccda-2.1 --json
|
|
159
|
+
# After package installation:
|
|
160
|
+
cda-validate document.xml --profile ccda-2.1 --json
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
CLI exit codes: **0** valid · **1** invalid · **2** incomplete or operational failure. Use `CDA_VALIDATOR_URL`, `CDA_VALIDATOR_TOKEN`, or `--url` for your deployment. The CLI accepts `-` for stdin. Type declarations are included; CI checks Node 22 and 24.
|
|
164
|
+
|
|
165
|
+
[Client configuration →](docs/api.md#node-client-and-cli) · [Legacy API and migration →](docs/legacy-api.md)
|
|
166
|
+
|
|
167
|
+
## Capacity, queue, and privacy
|
|
168
|
+
|
|
169
|
+
| Default | Behavior |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| **20 MiB XML** | Configurable with `MAX_XML_MIB`; the API and UI advertise the active limit |
|
|
172
|
+
| **6 admitted requests** | Includes upload, queued, and validation work; 2 validation workers |
|
|
173
|
+
| **30-second upload queue wait** | Admitted uploads wait fairly for memory on their original HTTP request |
|
|
174
|
+
| **Shared upload memory budget** | Streaming decoding reserves memory before reading; serialized JSON is never retained in full |
|
|
175
|
+
| **No document persistence** | No patient-document/result cache, database, or application logging of submitted XML/findings |
|
|
176
|
+
|
|
177
|
+
**For more concurrent large uploads, increase Java heap and container memory together:**
|
|
178
|
+
|
|
179
|
+
```sh
|
|
180
|
+
VALIDATOR_MEMORY_LIMIT=3g VALIDATOR_JAVA_OPTIONS=-Xmx2g docker compose up -d
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
More heap can permit more large uploads concurrently. CPU and document complexity still affect validation speed. The UI's **Service capacity and queue** panel explains the active configuration. A full queue returns HTTP 429; an expired upload queue wait returns HTTP 503.
|
|
184
|
+
|
|
185
|
+
The isolated 1 GiB-heap regression processes **six simultaneous 20 MiB documents**, each encoded as roughly 120 MiB JSON, with both known-length and chunked uploads. All six complete without retries; health probes and post-load validation pass. [Recorded evidence](reports/upload-memory.json).
|
|
186
|
+
|
|
187
|
+
[Memory tuning, security, authentication, deadlines, and all limits →](docs/deployment.md)
|
|
188
|
+
|
|
189
|
+
## Documentation
|
|
190
|
+
|
|
191
|
+
| Guide | What you will find |
|
|
192
|
+
| --- | --- |
|
|
193
|
+
| [HTTP API](docs/api.md) | Payloads, reports, endpoints, errors, Node client, and CLI |
|
|
194
|
+
| [Deployment](docs/deployment.md) | Docker, configuration, queueing, heap tuning, and secure shared access |
|
|
195
|
+
| [Architecture](docs/architecture.md) | Runtime design, standards, provenance, privacy, and verification |
|
|
196
|
+
| [Legacy API](docs/legacy-api.md) | Existing exports, defaults, examples, and migration boundaries |
|
|
197
|
+
| [Historical documentation](docs/history.md) | Original release history, inherited examples, and attribution |
|
|
198
|
+
| [Contributing](CONTRIBUTING.md) | Development checks and owner-managed contribution policy |
|
|
199
|
+
| [Security](SECURITY.md) | Reporting vulnerabilities and deployment responsibilities |
|
|
200
|
+
|
|
201
|
+
For the complete HTML engineering report, start the service and open [localhost:17643/architecture.html](http://localhost:17643/architecture.html). Its source and evidence are in [reports/](reports/).
|
|
202
|
+
|
|
203
|
+
## Development
|
|
204
|
+
|
|
205
|
+
Local service development requires Java 21+, Maven 3.9+, and Python 3.11+. Node is required for the JavaScript library and its tests.
|
|
206
|
+
|
|
207
|
+
```sh
|
|
208
|
+
npm ci --ignore-scripts
|
|
209
|
+
npm test
|
|
210
|
+
npm run service:build
|
|
211
|
+
npm run service:start
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
`npm run service:test` exercises both official HL7 packages. `python3 scripts/check-upload-memory.py` runs the constrained-heap queue regression using Docker and curl. These checks run in CI alongside CodeQL. [Verification details](docs/architecture.md#verification).
|
|
215
|
+
|
|
216
|
+
Public issues are welcome. This repository accepts owner-authored PRs; changes reach `main` through review. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
**License and attribution** · [MIT](LICENSE.md) · [Third-party notices](THIRD_PARTY_NOTICES.md)
|
|
221
|
+
|
|
222
|
+
Original JavaScript implementation by **Eric Wadkins**, developed further by **Priyaranjan (Raj) Tokachichu**. John D'Amore's public clinical samples are credited in the source fixtures. This product includes software developed by Health Level Seven. HL7 resources and bundled dependencies retain their own licenses and notices.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const createClient = require('../lib/createClient');
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
let file, profile = 'ccda-5.0', baseUrl = process.env.CDA_VALIDATOR_URL || 'http://127.0.0.1:17643';
|
|
9
|
+
let json = false, includeWarnings = true;
|
|
10
|
+
for (let i = 0; i < args.length; i++) {
|
|
11
|
+
if (args[i] === '--help' || args[i] === '-h') {
|
|
12
|
+
console.log('Usage: cda-validate FILE|- [--profile ccda-5.0|ccda-2.1] [--url URL] [--json] [--no-warnings]\nSet CDA_VALIDATOR_TOKEN for authenticated services. Exit: 0 valid; 1 invalid; 2 incomplete or execution error.');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (args[i] === '--profile' || args[i] === '--url') {
|
|
16
|
+
const option = args[i], value = args[++i];
|
|
17
|
+
if (!value) throw new Error('Missing value for ' + option);
|
|
18
|
+
if (option === '--profile') profile = value; else baseUrl = value;
|
|
19
|
+
} else if (args[i] === '--json') json = true;
|
|
20
|
+
else if (args[i] === '--no-warnings') includeWarnings = false;
|
|
21
|
+
else if (!file && (args[i] === '-' || !args[i].startsWith('-'))) file = args[i];
|
|
22
|
+
else throw new Error('Unknown argument: ' + args[i]);
|
|
23
|
+
}
|
|
24
|
+
if (!file) throw new Error('An XML file or - for stdin is required. Use --help for usage.');
|
|
25
|
+
const data = fs.readFileSync(file === '-' ? 0 : file);
|
|
26
|
+
const xml = new TextDecoder('utf-8', { fatal: true }).decode(data);
|
|
27
|
+
const report = await createClient({ baseUrl, token: process.env.CDA_VALIDATOR_TOKEN }).validate(xml, { profile, includeWarnings });
|
|
28
|
+
if (json) console.log(JSON.stringify(report, null, 2));
|
|
29
|
+
else {
|
|
30
|
+
console.log(`${report.status.toUpperCase()} · ${report.profile.name} / ${report.profile.release} · ${report.summary.errors} errors · ${report.summary.warnings} warnings · ${report.durationMs} ms`);
|
|
31
|
+
for (const f of report.findings) console.log(`${f.severity.toUpperCase()} [${f.stage}]${f.line ? ' line ' + f.line : ''}: ${f.message}`);
|
|
32
|
+
if (!report.validationComplete) console.log('Coverage is incomplete; inspect the profile limitations and stage results.');
|
|
33
|
+
}
|
|
34
|
+
process.exitCode = report.status === 'invalid' ? 1 : report.validationComplete ? 0 : 2;
|
|
35
|
+
}
|
|
36
|
+
main().catch((error) => { console.error(error.message); process.exitCode = 2; });
|