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/docs/api.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# HTTP API and clients
|
|
2
|
+
|
|
3
|
+
[← Project home](../README.md) · [Deployment](deployment.md) · [Legacy API](legacy-api.md)
|
|
4
|
+
|
|
5
|
+
The API accepts UTF-8 XML text and an installed profile ID. It does not accept file paths, remote URLs, or uploaded Schematron. Default local base URL: `http://localhost:17643`.
|
|
6
|
+
|
|
7
|
+
## Endpoints
|
|
8
|
+
|
|
9
|
+
| Method | Route | Result |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| POST | `/v1/validate` | Validation report for one document |
|
|
12
|
+
| GET | `/v1/profiles` | Installed profiles, source provenance, coverage gaps, and active capacity/size limits |
|
|
13
|
+
| GET | `/v1/version` | Application and engine versions |
|
|
14
|
+
| GET | `/health/live` | Process liveness |
|
|
15
|
+
| GET | `/health/ready` | Readiness after profile compilation |
|
|
16
|
+
| GET | `/openapi.json` | OpenAPI 3.1 contract |
|
|
17
|
+
| GET | `/` | Browser workspace |
|
|
18
|
+
| GET | `/architecture.html` | Full HTML engineering report |
|
|
19
|
+
|
|
20
|
+
[OpenAPI source](../service/web/openapi.json) is the machine-readable contract.
|
|
21
|
+
|
|
22
|
+
## Validate a document
|
|
23
|
+
|
|
24
|
+
Send `Content-Type: application/json`. Fields may appear in any order. Unknown or duplicate fields are rejected.
|
|
25
|
+
|
|
26
|
+
| Field | Required | Default | Meaning |
|
|
27
|
+
| --- | --- | --- | --- |
|
|
28
|
+
| `xml` | Yes | — | Nonempty XML text, UTF-8; 20 MiB default maximum |
|
|
29
|
+
| `profile` | No | `ccda-5.0` | `ccda-2.1` or `ccda-5.0`; maximum 128 UTF-8 bytes |
|
|
30
|
+
| `includeWarnings` | No | `true` | Include advisory Schematron findings; coverage limitations remain explicit |
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
curl http://localhost:17643/v1/validate \
|
|
34
|
+
-H 'Content-Type: application/json' \
|
|
35
|
+
--data-binary @request.json
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`request.json` can contain:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"xml": "<ClinicalDocument xmlns=\"urn:hl7-org:v3\"/>",
|
|
43
|
+
"profile": "ccda-2.1",
|
|
44
|
+
"includeWarnings": true
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This XML is intentionally minimal and will produce findings. Replace it with your document, or use the browser/Node client to load XML from a file.
|
|
49
|
+
|
|
50
|
+
## Understand the report
|
|
51
|
+
|
|
52
|
+
**HTTP 200 means the service produced a report. It does not mean the document passed.**
|
|
53
|
+
|
|
54
|
+
| Field | Interpretation |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| `status` | `valid`, `invalid`, or `incomplete` |
|
|
57
|
+
| `executionComplete` | Whether the configured engine stages finished without truncation |
|
|
58
|
+
| `validationComplete` | Also requires supported document-level coverage and no recorded upstream generation gaps |
|
|
59
|
+
| `truncated` | The finding limit was reached; the report is partial |
|
|
60
|
+
| `summary` | Errors, warnings, total findings, and fired rules |
|
|
61
|
+
| `findings` | Severity, stage, message, rule ID, assertion test, XPath/context, and available locations |
|
|
62
|
+
| `stages` | XML, XSD, and Schematron execution status |
|
|
63
|
+
| `profile`, `sources`, `engine` | Exact pinned validation resources and engine versions |
|
|
64
|
+
| `uploadQueueWaitMs` | Wait for upload memory before decoding |
|
|
65
|
+
| `durationMs` | Engine validation duration, separate from upload queue wait |
|
|
66
|
+
| `requestId`, `validatedAt` | Request identity and timestamp |
|
|
67
|
+
|
|
68
|
+
`invalid` can coexist with `validationComplete: false`: errors were found, and some coverage is missing. `incomplete` is never a pass. C-CDA 5.0 currently always discloses its upstream conversion gaps. A missing or unsupported root document template cannot be rescued by nested section/entry rules firing.
|
|
69
|
+
|
|
70
|
+
See an [actual synthetic-example response](../reports/example-result.json). The service does not return XML snippets. Finding messages can contain document values, so callers must handle reports as sensitive.
|
|
71
|
+
|
|
72
|
+
## Authentication and errors
|
|
73
|
+
|
|
74
|
+
When the deployment sets `API_TOKEN`, `/v1/*` requests require:
|
|
75
|
+
|
|
76
|
+
```http
|
|
77
|
+
Authorization: Bearer YOUR_SERVICE_TOKEN
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Liveness, readiness, and static UI routes remain available. Use authenticated HTTPS and access controls for shared deployments; see [deployment](deployment.md#shared-deployments).
|
|
81
|
+
|
|
82
|
+
| HTTP | Meaning |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| 200 | Report produced; inspect its status and completeness |
|
|
85
|
+
| 400 | Malformed JSON, invalid UTF-8, missing/wrong fields, or duplicate/unknown fields |
|
|
86
|
+
| 401 | Missing or incorrect bearer token |
|
|
87
|
+
| 403 | Cross-origin submission rejected |
|
|
88
|
+
| 413 | Decoded XML or serialized request exceeds its active limit |
|
|
89
|
+
| 415 | Unsupported content type |
|
|
90
|
+
| 422 | Unknown validation profile |
|
|
91
|
+
| 429 | Bounded request/worker capacity is full; `Retry-After: 2` |
|
|
92
|
+
| 500 | Engine or execution failure; a partial report may be included |
|
|
93
|
+
| 503 | Upload queue wait expired or service is stopping |
|
|
94
|
+
| 504 | Validation deadline exceeded |
|
|
95
|
+
|
|
96
|
+
Admitted uploads queue fairly for up to 30 seconds while waiting for memory. Validation then has its own 30-second deadline, including any wait for a validation worker. The server bounds the total HTTP upload/read window to 65 seconds. Validation cancellation is cooperative; it is not hard process termination. Configure proxies and client timeouts for the whole request lifecycle.
|
|
97
|
+
|
|
98
|
+
## Node client and CLI
|
|
99
|
+
|
|
100
|
+
Requires Node 22.12+. Install the version 2 preview:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
npm install cda-schematron-validator@next
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
const { createClient } = require('cda-schematron-validator');
|
|
108
|
+
const client = createClient({
|
|
109
|
+
baseUrl: 'http://localhost:17643',
|
|
110
|
+
token: process.env.CDA_VALIDATOR_TOKEN,
|
|
111
|
+
timeoutMs: 110000
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`client.validate(xml, { profile, includeWarnings })` returns the modern report. `client.profiles()` returns profile/source metadata and active limits. `client.version()` returns version information. The default timeout is 110 seconds to accommodate upload and queueing. Non-2xx responses throw an error with `status` and `report` properties; validation findings in a 200 report do not throw.
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
cda-validate document.xml --profile ccda-2.1 --json
|
|
119
|
+
cat document.xml | cda-validate - --profile ccda-2.1 --json
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
From the checkout, use `node bin/cda-validate.js` in place of `cda-validate`.
|
|
123
|
+
|
|
124
|
+
| CLI setting | Purpose |
|
|
125
|
+
| --- | --- |
|
|
126
|
+
| `--profile ccda-2.1` | Select the guide |
|
|
127
|
+
| `--url URL` / `CDA_VALIDATOR_URL` | Service address |
|
|
128
|
+
| `CDA_VALIDATOR_TOKEN` | Service bearer token |
|
|
129
|
+
| `--json` | Print the full JSON report |
|
|
130
|
+
| `--no-warnings` | Exclude advisory Schematron findings |
|
|
131
|
+
|
|
132
|
+
Exit **0**: valid. Exit **1**: invalid. Exit **2**: incomplete or operational failure.
|
|
133
|
+
|
|
134
|
+
[Type declarations](../validator.d.ts) cover both modern and legacy interfaces.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Architecture, standards, and verification
|
|
2
|
+
|
|
3
|
+
[← Project home](../README.md) · [Deployment](deployment.md) · [API reference](api.md)
|
|
4
|
+
|
|
5
|
+
## Request lifecycle
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
flowchart LR
|
|
9
|
+
A[Browser / API / Node / CLI] --> B[Bounded admission]
|
|
10
|
+
B --> C[Fair upload memory queue]
|
|
11
|
+
C --> D[Streaming JSON decode]
|
|
12
|
+
D --> E[Strict XML parsing]
|
|
13
|
+
E --> F[CDA XSD]
|
|
14
|
+
F --> G[Compiled HL7 Schematron]
|
|
15
|
+
G --> H[Findings and coverage report]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Java 21+ hosts the HTTP adapter and validation engine. Saxon-HE 12.9 executes XSLT compiled from the pinned Schematron using SchXslt 1.10.1. The JDK XML Schema validator checks the pinned CDA schema; Gson serializes JSON reports. No database or application framework is required.
|
|
19
|
+
|
|
20
|
+
The browser uses HTML, CSS, and JavaScript. The original JavaScript library remains independent of Java; the new Node client communicates with the service over HTTP/JSON. Python scripts prepare assets, check upstream releases, benchmark, verify, and generate the HTML report.
|
|
21
|
+
|
|
22
|
+
## Shared work and document isolation
|
|
23
|
+
|
|
24
|
+
At startup, the service verifies the asset inventory and compiles immutable schemas/stylesheets. Trusted bundled vocabulary XML may be cached. Each submitted document owns its parser, schema validator, transformer, line lookup, and finding collector.
|
|
25
|
+
|
|
26
|
+
There is **no patient-document or result cache**. Warm performance comes from reusing compiled rules and trusted vocabulary. SVRL findings are collected as a bounded stream rather than an unlimited intermediate report.
|
|
27
|
+
|
|
28
|
+
The pinned releases omit query binding and use XPath 1.0 coercions. Compilation retains backwards-compatible expression semantics, makes phase severity explicit, and assigns deterministic IDs where assertions have none. Original rule tests and messages are retained.
|
|
29
|
+
|
|
30
|
+
[Queue/memory design and all limits](deployment.md#bounded-queue-and-memory) are described separately from validation semantics.
|
|
31
|
+
|
|
32
|
+
## Standards and coverage
|
|
33
|
+
|
|
34
|
+
| Resource | Official release | Used for |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| [HL7 CDA Core](https://github.com/HL7/CDA-core-2.0/releases/tag/20260205_SDTC) | `20260205_SDTC` | CDA R2 XSD and approved SDTC extensions |
|
|
37
|
+
| [HL7 C-CDA 2.1](https://github.com/HL7/CDA-ccda-2.1/releases/tag/2025SEP) | `2025SEP` | Full supplied Schematron and vocabulary snapshot |
|
|
38
|
+
| [HL7 C-CDA 5.0](https://github.com/HL7/CDA-ccda/releases/tag/2026JUL) | `2026JUL` | Full supplied Schematron, bindings, and generation report |
|
|
39
|
+
|
|
40
|
+
[The source lock](../profiles/sources.lock.json) records immutable archive URLs and SHA-256 hashes. [Asset preparation](../scripts/prepare-assets.py) verifies archives and writes per-file inventories. Startup verifies those files again. No mutable upstream rules are downloaded during validation.
|
|
41
|
+
|
|
42
|
+
C-CDA 5.0's supplied generation report records **4 errors, 6 unhandled invariants across 4 categories, and 28 non-loaded value-set entries across 9 categories**. Embedded expansions are limited to value sets with fewer than 1,000 concepts. Consequently, `validationComplete` remains false for that package even when every configured stage executes. C-CDA 2.1 uses its bundled vocabulary snapshot.
|
|
43
|
+
|
|
44
|
+
A supported document-level template must match the root ClinicalDocument for complete document coverage. Nested section or entry templates firing alone cannot establish a document-level pass. Template versions are derived from the selected pinned profile's rules.
|
|
45
|
+
|
|
46
|
+
The application does not implement full FHIR StructureDefinition validation or every terminology requirement. HL7's [validation guidance](https://hl7.org/cda/us/ccda/5.0.0/validation.html) describes additional approaches; a StructureDefinition adapter is a future capability, not a current claim.
|
|
47
|
+
|
|
48
|
+
## Updates and releases
|
|
49
|
+
|
|
50
|
+
A weekly workflow checks official latest releases against the lock. It signals differences without silently replacing rules or opening automated PRs. An update requires review of checksums, generation gaps, vocabulary changes, tests, and benchmark results.
|
|
51
|
+
|
|
52
|
+
The container is the primary service distribution. The npm package preserves legacy integrations and supplies the thin modern client/CLI. These release paths can evolve independently. Owner-authorized releases publish versioned container and npm artifacts separately. Merging does not publish either artifact.
|
|
53
|
+
|
|
54
|
+
## Verification
|
|
55
|
+
|
|
56
|
+
Current evidence is recorded in [verification.json](../reports/verification.json), [upload-memory.json](../reports/upload-memory.json), [browser-verification.json](../reports/browser-verification.json), and [benchmark.json](../reports/benchmark.json).
|
|
57
|
+
|
|
58
|
+
| Check | Coverage |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| JavaScript tests | Legacy results/exports, document isolation, ordered batches, frozen options, missing IDs, client behavior, and UI input races |
|
|
61
|
+
| Java tests | XML security/complexity, schema findings, rule semantics, coverage, decoded/encoded size limits, upload queue bounds, disconnect recovery, and HTTP contracts |
|
|
62
|
+
| Official package integration | Compile and execute both complete pinned HL7 packages |
|
|
63
|
+
| Constrained-heap regression | Six simultaneous maximum-size documents, both known-length and chunked framing, in an isolated 1 GiB-heap container; all requests complete without retries |
|
|
64
|
+
| Browser verification | Upload/example validation, findings, filters, line navigation, JSON download, mobile layout, stale-result clearing, and queue/heap guidance |
|
|
65
|
+
| CI | Node 22/24, Java service, Docker build, upload-memory regression, owner/branch policy, and CodeQL |
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
npm ci --ignore-scripts
|
|
69
|
+
npm test
|
|
70
|
+
npm run service:test
|
|
71
|
+
docker compose up --build -d
|
|
72
|
+
python3 scripts/verify.py
|
|
73
|
+
python3 scripts/check-upload-memory.py
|
|
74
|
+
python3 scripts/benchmark.py --requests 100 --concurrency 1 2 4
|
|
75
|
+
python3 scripts/build-report.py
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The benchmark records fixture sizes, concurrency, throughput, p50/p95 latency, and result consistency. It is a limited corpus, not an industry-wide speed comparison or clinical certification. Larger adjudicated corpora, reference-validator comparisons, and sustained production load tests remain important release work.
|
|
79
|
+
|
|
80
|
+
## Full HTML report
|
|
81
|
+
|
|
82
|
+
Run the service and open [localhost:17643/architecture.html](http://localhost:17643/architecture.html). The standalone artifact is [reports/architecture.html](../reports/architecture.html); download it to view its rendered design outside the service. GitHub's file viewer shows HTML source rather than hosting it as an application.
|
|
83
|
+
|
|
84
|
+
## Source map
|
|
85
|
+
|
|
86
|
+
| Location | Responsibility |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| [Java service](../service/src/main/java/org/cdavalidator/) | HTTP, streaming request decoding, validation engine, health probe |
|
|
89
|
+
| [Web workspace](../service/web/) | UI, API contract, synthetic sample, engineering report |
|
|
90
|
+
| [Source lock](../profiles/sources.lock.json) | Pinned official resources |
|
|
91
|
+
| [JavaScript exports](../validator.js) | Legacy API and modern client entry point |
|
|
92
|
+
| [Client](../lib/createClient.js) / [CLI](../bin/cda-validate.js) | HTTP integrations |
|
|
93
|
+
| [Scripts](../scripts/) | Assets, upstream checks, verification, benchmarks, reports |
|
|
94
|
+
| [Dockerfile](../Dockerfile) / [Compose](../compose.yaml) | Build/runtime packaging and local deployment |
|
|
95
|
+
|
|
96
|
+
## Attribution and licensing
|
|
97
|
+
|
|
98
|
+
The JavaScript code descends from Eric Wadkins' validator and subsequent work by Priyaranjan (Raj) Tokachichu. John D'Amore's public sample repository is credited in test fixtures; that sample influence is distinct from verified code ancestry.
|
|
99
|
+
|
|
100
|
+
Application code uses the [MIT license](../LICENSE.md). HL7 assets and runtime dependencies retain separate notices and licenses in [THIRD_PARTY_NOTICES.md](../THIRD_PARTY_NOTICES.md) and [licenses/](../licenses/). This product includes software developed by Health Level Seven.
|
|
101
|
+
|
|
102
|
+
See the [coverage remediation inventory](coverage.md) for individual gaps, causes, and acceptance criteria.
|
package/docs/coverage.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# C-CDA 5.0 coverage remediation
|
|
2
|
+
|
|
3
|
+
[← Architecture](architecture.md) · [Official HL7 validation guidance](https://hl7.org/cda/us/ccda/5.0.0/validation.html)
|
|
4
|
+
|
|
5
|
+
This inventory is derived from the checksum-pinned `2026JUL/CCDA-5.0-Results.json`. It records unresolved upstream omissions, not completed fixes. The full report is also exposed as `generationReport` in profile metadata. `generationCoverage` counts individual entries rather than reason categories.
|
|
6
|
+
|
|
7
|
+
**Current totals:** 4 generation errors, 6 unhandled invariants in 4 categories, and 28 non-loaded value-set entries in 9 categories. Counts overlap: an expansion failure can also cause an invariant omission. Do not add these counts together as independent missing rules.
|
|
8
|
+
|
|
9
|
+
The earlier summary of 4 invariants and 9 value sets counted categories and understated the omissions. This preview corrects the accounting; it does not turn missing checks into passes.
|
|
10
|
+
|
|
11
|
+
## Rule-conversion work
|
|
12
|
+
|
|
13
|
+
| Invariant | Template | Why omitted | Required fix and verification |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| `1198-8487` | `OperativeNote` | Cannot calculate memberOf, Value Set http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.88.12.80.28 is not loaded. | Resolve and pin the required terminology data, then verify positive/negative membership and allowed alternative code systems. |
|
|
16
|
+
| `1198-8511` | `ProcedureNote` | Cannot calculate memberOf, Value Set http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.88.12.80.28 is not loaded. | Resolve and pin the required terminology data, then verify positive/negative membership and allowed alternative code systems. |
|
|
17
|
+
| `active-high-ts-after-document` | `ProcedureActivityProcedure` | Unsupported function allTrue | Translate collection Boolean semantics and CDA timestamp comparisons; verify absent values, precision, timezone offsets, equality, and every comparison result. Do not compare timestamps as plain strings. |
|
|
18
|
+
| `ts-value-before-document` | `ProcedureActivityProcedure` | Unsupported function allTrue | Translate collection Boolean semantics and CDA timestamp comparisons; verify absent values, precision, timezone offsets, equality, and every comparison result. Do not compare timestamps as plain strings. |
|
|
19
|
+
| `shall-use-one-binding` | `ServiceDeliveryLocation` | Cannot calculate memberOf, Value Set http://hl7.org/cda/us/ccda/ValueSet/CMSPlaceOfServiceCodes is not loaded. | Resolve and pin the required terminology data, then verify positive/negative membership and allowed alternative code systems. |
|
|
20
|
+
| `81-9371` | `USRealmPersonNamePNUSFIELDED` | Unsupported function conformsTo | Execute the referenced patient-name profile at the name node; verify both valid fielded names and invalid names, including the allowed text alternative. |
|
|
21
|
+
|
|
22
|
+
### Generation errors
|
|
23
|
+
|
|
24
|
+
- CarePlanAct: Profile http://hl7.org/cda/stds/core/StructureDefinition/Act does not have an identifier
|
|
25
|
+
- CarePlanAct: Profile http://hl7.org/cda/stds/core/StructureDefinition/Observation does not have an identifier
|
|
26
|
+
- CarePlanAct: Profile http://hl7.org/cda/stds/core/StructureDefinition/Act does not have an identifier
|
|
27
|
+
- Failed to expand value set v3-ActPriority: Unable to expand dependent value set http://terminology.hl7.org/ValueSet/v3-ActPriorityCallback
|
|
28
|
+
|
|
29
|
+
CarePlanAct profile-reference errors need comparison against the authoritative StructureDefinitions before adding any rule. A base CDA class without a template identifier cannot safely be assigned an invented templateId. ActPriority requires its dependent callback value-set definition and a complete expansion.
|
|
30
|
+
|
|
31
|
+
## Terminology work
|
|
32
|
+
|
|
33
|
+
Large sets should use versioned indexed terminology snapshots or a deliberately configured terminology adapter. Increasing the generator’s inline-list limit alone can harm compilation cost and still leaves unavailable expansions unresolved. Keep runtime validation offline by default; never send a clinical document to a public terminology service.
|
|
34
|
+
|
|
35
|
+
Public specifications do not automatically grant permission to redistribute every underlying terminology. Establish the applicable source/version and redistribution terms before bundling external SNOMED CT, CPT, NUBC, or VSAC-derived data. This is a release dependency where data is unavailable, not a reason to silently accept an unverified code.
|
|
36
|
+
|
|
37
|
+
### too-costly
|
|
38
|
+
|
|
39
|
+
Split grammar-based validation from enumerated membership. For enumerated sets, obtain complete paginated/versioned expansions and verify totals; for SNOMED descendants use an edition-specific hierarchy snapshot.
|
|
40
|
+
|
|
41
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1267.43 - too-costly: The value set 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1267.38' expansion has too many codes to produce (>10000)`
|
|
42
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1267.13 - too-costly: The value set 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1267.13' expansion has too many codes to produce (>3000)`
|
|
43
|
+
- `http://hl7.org/fhir/ValueSet/all-languages - too-costly: The code System "urn:ietf:bcp:47" has a grammar, and cannot be enumerated directly`
|
|
44
|
+
- `http://hl7.org/fhir/us/core/ValueSet/us-core-condition-code - too-costly: The value set 'http://hl7.org/fhir/us/core/ValueSet/us-core-condition-code' expansion has too many codes to produce (>3000)`
|
|
45
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.88.12.3221.8.9 - too-costly: The value set 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.88.12.3221.8.9' expansion has too many codes to produce (>3000)`
|
|
46
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1010.4 - too-costly: The value set 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1010.5' expansion has too many codes to produce (>10000)`
|
|
47
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1010.2 - too-costly: The value set 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.88.12.80.17' expansion has too many codes to produce (>10000)`
|
|
48
|
+
- `http://hl7.org/fhir/us/core/ValueSet/us-core-documentreference-type - too-costly: The value set 'http://hl7.org/fhir/us/core/ValueSet/us-core-documentreference-type' expansion has too many codes to produce (>3000)`
|
|
49
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.88.12.80.28 - too-costly: The value set 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.88.12.80.28' expansion has too many codes to produce (>3000)`
|
|
50
|
+
- `http://hl7.org/fhir/us/core/ValueSet/us-core-procedure-code - too-costly: The code System "http://www.ama-assn.org/go/cpt" has a grammar, and cannot be enumerated directly`
|
|
51
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1267.36 - too-costly: The value set 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1267.36' expansion has too many codes to produce (>3000)`
|
|
52
|
+
### too-many-concepts
|
|
53
|
+
|
|
54
|
+
Obtain the complete expansion and store it in an indexed resource rather than a very large XPath literal. Verify membership, version, checksum, and full concept count.
|
|
55
|
+
|
|
56
|
+
- `http://phinvads.cdc.gov/fhir/ValueSet/2.16.840.1.114222.4.11.7900 (19254)`
|
|
57
|
+
- `http://phinvads.cdc.gov/fhir/ValueSet/2.16.840.1.114222.4.11.7901 (59583)`
|
|
58
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.11.20.9.34 (1172)`
|
|
59
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1240.1 (1709)`
|
|
60
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1099.54 (1817)`
|
|
61
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.1.11.14914 (1279)`
|
|
62
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1267.25 (1282)`
|
|
63
|
+
### not-found: A definition for CodeSystem 'https://www.nubc.org/CodeSystem/PatDischargeStatus' could not be found, so the value set cannot be expanded
|
|
64
|
+
|
|
65
|
+
Resolve the named source/terminology-service failure against the intended edition. Pin the successful definition/expansion and verify complete membership; do not substitute an empty expansion or a different release.
|
|
66
|
+
|
|
67
|
+
- `http://terminology.hl7.org/ValueSet/v3-USEncounterDischargeDisposition`
|
|
68
|
+
### apostrophes-in-codes
|
|
69
|
+
|
|
70
|
+
Fix XPath literal escaping or use indexed vocabulary lookup; test apostrophes, quotation marks, and both together without altering codes. UCUM also requires grammar-aware validation where full enumeration is impossible.
|
|
71
|
+
|
|
72
|
+
- `http://terminology.hl7.org/ValueSet/v3-UnitsOfMeasureCaseSensitive (840)`
|
|
73
|
+
### Response from https://tx.fhir.org/r5 did not contain any codes in its expansion.
|
|
74
|
+
|
|
75
|
+
Resolve the named source/terminology-service failure against the intended edition. Pin the successful definition/expansion and verify complete membership; do not substitute an empty expansion or a different release.
|
|
76
|
+
|
|
77
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1021.48`
|
|
78
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1021.47`
|
|
79
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1021.46`
|
|
80
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1166.22`
|
|
81
|
+
### exception: The SNOMED CT Concept 1354756004 is not known
|
|
82
|
+
|
|
83
|
+
Resolve the named source/terminology-service failure against the intended edition. Pin the successful definition/expansion and verify complete membership; do not substitute an empty expansion or a different release.
|
|
84
|
+
|
|
85
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1095.65`
|
|
86
|
+
### not-found: A definition for CodeSystem 'https://nahdo.org/sopt' could not be found, so the value set cannot be expanded
|
|
87
|
+
|
|
88
|
+
Resolve the named source/terminology-service failure against the intended edition. Pin the successful definition/expansion and verify complete membership; do not substitute an empty expansion or a different release.
|
|
89
|
+
|
|
90
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591`
|
|
91
|
+
### business-rule: Cannot process resource http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.11.20.9.46|20240606 at "filter" due to the presence of the modifier extension vsacOpModifier
|
|
92
|
+
|
|
93
|
+
Resolve the named source/terminology-service failure against the intended edition. Pin the successful definition/expansion and verify complete membership; do not substitute an empty expansion or a different release.
|
|
94
|
+
|
|
95
|
+
- `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.11.20.9.46`
|
|
96
|
+
### not-found
|
|
97
|
+
|
|
98
|
+
Locate the canonical value-set definition in the pinned guide/dependencies and obtain the complete code-system data. Preserve canonical identity and provenance.
|
|
99
|
+
|
|
100
|
+
- `http://hl7.org/cda/us/ccda/ValueSet/CMSPlaceOfServiceCodes`
|
|
101
|
+
|
|
102
|
+
## Acceptance criteria for closing a gap
|
|
103
|
+
|
|
104
|
+
1. Trace the fix to a pinned official definition, terminology edition, or precisely identified invariant. Preserve the original upstream report and record local additions separately.
|
|
105
|
+
2. Add positive and negative examples that exercise the missing constraint, including nullFlavor, absent data, and relevant boundary cases. Compare against an independent reference where feasible.
|
|
106
|
+
3. Verify vocabulary completeness, provenance, permissions, and checksum. An unavailable external source remains an explicit unresolved gap.
|
|
107
|
+
4. Run both profiles, legacy compatibility, memory/concurrency tests, and compile/startup benchmarks.
|
|
108
|
+
5. Only remove an omission from the effective coverage summary after its replacement check and evidence exist. Do not clear the upstream report or force `validationComplete` to true.
|
|
109
|
+
|
|
110
|
+
## Release policy
|
|
111
|
+
|
|
112
|
+
Version 2 is a preview while this coverage work is unresolved. C-CDA 2.1 remains available with its bundled vocabulary snapshot. The stable npm default stays 1.1.12 until a separately authorized stable release. The preview is explicitly selected with `@next`.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Deployment and capacity
|
|
2
|
+
|
|
3
|
+
[← Project home](../README.md) · [API reference](api.md) · [Architecture](architecture.md)
|
|
4
|
+
|
|
5
|
+
## Run locally
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
docker compose up --build -d
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Open [localhost:17643](http://localhost:17643). Compose binds the published port to `127.0.0.1`. Java and all validation resources are inside the image; ordinary validation is offline. The first build needs network access for verified resources and dependencies.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
docker compose logs validator
|
|
15
|
+
docker compose down
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The owner-triggered release workflow publishes versioned AMD64/ARM64 images for `ghcr.io/priyaranjan-tokachichu/cda-schematron-validator`, with SBOM and provenance. A merge alone does not publish an image. The version 2 image is `ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.0-preview.1`.
|
|
19
|
+
|
|
20
|
+
Run the published image directly:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
docker run -d --name cda-validator --memory=1536m --cpus=2 \
|
|
24
|
+
--read-only --tmpfs /tmp:size=64m,noexec,nosuid \
|
|
25
|
+
--cap-drop=ALL --security-opt=no-new-privileges --pids-limit=128 \
|
|
26
|
+
-p 127.0.0.1:17643:17643 \
|
|
27
|
+
ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.0-preview.1
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
| Setting | Default | Scope |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| `CDA_VALIDATOR_PORT` | `17643` | Compose host port; container port stays `17643` |
|
|
35
|
+
| `MAX_XML_MIB` | `20` | Maximum decoded UTF-8 XML size in whole MiB |
|
|
36
|
+
| `VALIDATOR_MEMORY_LIMIT` | `1536m` | Compose container memory limit |
|
|
37
|
+
| `VALIDATOR_JAVA_OPTIONS` | Empty | Compose value forwarded to Java as `JAVA_TOOL_OPTIONS` |
|
|
38
|
+
| `HOST` | `127.0.0.1` outside Docker | Service bind address; image uses `0.0.0.0` inside the container |
|
|
39
|
+
| `PORT` | `17643` | Service/container listen port |
|
|
40
|
+
| `VALIDATION_WORKERS` | `2` | Runtime validation pool; Compose currently explicitly sets `2` |
|
|
41
|
+
| `API_TOKEN` | Unset | Optional bearer authentication for `/v1/*`; supply through deployment configuration |
|
|
42
|
+
| `ASSET_DIR`, `WEB_DIR` | Image paths | Bundled assets and UI; normally leave unchanged |
|
|
43
|
+
|
|
44
|
+
`MAX_XML_MIB` must be a positive whole number within the implementation's supported byte range. Startup also requires enough heap to reserve one maximum-size upload. When raising the XML limit, provision heap/container memory accordingly.
|
|
45
|
+
|
|
46
|
+
Change the host port:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
CDA_VALIDATOR_PORT=17644 docker compose up -d
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Point browsers and clients to the new address. The CLI accepts `CDA_VALIDATOR_URL`; the Node client accepts `baseUrl`.
|
|
53
|
+
|
|
54
|
+
## Bounded queue and memory
|
|
55
|
+
|
|
56
|
+
The default service admits **six requests total**, across upload, waiting, and validation stages. Two workers run validation. Streaming JSON decoding avoids retaining a serialized body of up to roughly 120 MiB alongside the decoded XML.
|
|
57
|
+
|
|
58
|
+
Uploads share a budget equal to **one quarter of the JVM's reported maximum heap**. Each decoder reserves conservatively for string growth, UTF-16 storage, and parser buffers. Small known-length requests reserve less; chunked requests reserve the maximum allowance. Admission and the decoded XML limit separately bound retained request documents.
|
|
59
|
+
|
|
60
|
+
When memory is busy, an admitted upload waits in a fair queue on its original HTTP request. There is no job polling or client retry required for that wait. Reservations are released after decoding or on malformed input, oversize input, or disconnect.
|
|
61
|
+
|
|
62
|
+
| Boundary | Behavior |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| Capacity available | Decode and validate |
|
|
65
|
+
| Upload memory busy | Wait fairly, at most 30 seconds |
|
|
66
|
+
| Total admitted request capacity full | HTTP 429 with `Retry-After: 2` |
|
|
67
|
+
| Upload queue wait expires | HTTP 503 |
|
|
68
|
+
| Validation deadline expires | HTTP 504; cooperative cancellation |
|
|
69
|
+
|
|
70
|
+
`GET /v1/profiles` exposes active byte limits, upload memory budget, maximum concurrent maximum-size uploads, total request capacity, and queue wait bound. Reports expose `uploadQueueWaitMs`. The UI explains capacity under **Service capacity and queue**.
|
|
71
|
+
|
|
72
|
+
## Increase concurrent large-upload capacity
|
|
73
|
+
|
|
74
|
+
Increase **both Java heap and container memory**:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
VALIDATOR_MEMORY_LIMIT=3g VALIDATOR_JAVA_OPTIONS=-Xmx2g docker compose up -d
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The image otherwise uses `-XX:MaxRAMPercentage=70`, so heap sizing follows the container memory limit. Leave room outside the heap for native memory, threads, and the JVM. More heap permits more concurrent large uploads; it does not independently guarantee faster rule execution. CPU, worker count, and document complexity also matter.
|
|
81
|
+
|
|
82
|
+
To change the worker count, use a Compose override or your deployment manifest; the checked-in Compose file sets it explicitly. Scale stateless replicas behind a gateway when appropriate.
|
|
83
|
+
|
|
84
|
+
## Other operational limits
|
|
85
|
+
|
|
86
|
+
| Limit | Default |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| Decoded UTF-8 XML | 20 MiB = 20,971,520 bytes |
|
|
89
|
+
| Serialized JSON | 6 × active XML byte limit + 64 KiB |
|
|
90
|
+
| Element depth | 128 |
|
|
91
|
+
| Elements | 100,000 |
|
|
92
|
+
| Attributes per element | 256 |
|
|
93
|
+
| Findings | 2,000; truncation is explicit |
|
|
94
|
+
| Finding message | 4,000 characters; truncation is explicit |
|
|
95
|
+
| Upload memory queue wait | 30 seconds |
|
|
96
|
+
| Total HTTP upload/read window | 65 seconds |
|
|
97
|
+
| Validation/worker wait deadline | 30 seconds after decoding |
|
|
98
|
+
| Node client's default timeout | 110 seconds |
|
|
99
|
+
|
|
100
|
+
These are distinct boundaries. A document below the byte limit can still exceed structural complexity limits. JSON accepts only `xml`, `profile`, and `includeWarnings`; profile IDs are limited to 128 UTF-8 bytes. Unknown and duplicate fields are rejected.
|
|
101
|
+
|
|
102
|
+
## Shared deployments
|
|
103
|
+
|
|
104
|
+
Use an authenticated HTTPS gateway, access controls, and deliberate logging/retention policies. The local loopback configuration is not a public hosted service.
|
|
105
|
+
|
|
106
|
+
For example, a Compose override can pass an `API_TOKEN` supplied by your deployment environment:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
# compose.auth.yaml
|
|
110
|
+
services:
|
|
111
|
+
validator:
|
|
112
|
+
environment:
|
|
113
|
+
API_TOKEN: "${API_TOKEN:?Supply API_TOKEN through your deployment environment}"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
docker compose -f compose.yaml -f compose.auth.yaml up -d
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Provide the token through your secret-management process. Clients send `Authorization: Bearer TOKEN`; the UI accepts a token under **Service authentication**. Health and static UI routes remain available. Cross-origin validation submissions are rejected.
|
|
121
|
+
|
|
122
|
+
The container runs as UID/GID `10001`, with a read-only root, temporary filesystem, dropped capabilities, no-new-privileges, and CPU/memory/PID limits. DTDs and external entities are forbidden. Runtime resource resolution is restricted to the bundled trusted assets/compiler resources. Users cannot upload executable Schematron or request arbitrary server paths/URLs.
|
|
123
|
+
|
|
124
|
+
The application does not persist XML/reports or log submitted content, filenames, or findings. Reports can contain document values; client applications and proxies must handle them appropriately. The service does not use a database or a patient-document/result cache.
|
|
125
|
+
|
|
126
|
+
Cancellation is cooperative. Deployments needing guaranteed per-document hard termination require separately supervised, process-isolated workers; that capability is not implemented here.
|