cda-schematron-validator 2.0.0-preview.2 → 2.0.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/README.md +39 -6
- package/docs/api.md +5 -4
- package/docs/architecture.md +6 -4
- package/docs/coverage.md +40 -22
- package/docs/deployment.md +18 -3
- package/docs/images/validation-findings.jpg +0 -0
- package/docs/images/validation-workspace.jpg +0 -0
- package/docs/legacy-api.md +19 -1
- package/docs/release-2.0.0.md +54 -0
- package/docs/release-2.0.1.md +24 -0
- package/docs/terminology.md +271 -30
- package/lib/getIgnored.js +2 -1
- package/lib/getSchematronMap.js +2 -2
- package/lib/includeExternalDocument.js +2 -2
- package/lib/initializeProcess.js +2 -2
- package/lib/parseXml.js +19 -0
- package/package.json +2 -1
- package/validator.d.ts +6 -1
package/README.md
CHANGED
|
@@ -14,10 +14,39 @@
|
|
|
14
14
|
|
|
15
15
|
</div>
|
|
16
16
|
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
*The browser workspace in version 2.0.0. The synthetic example intentionally contains errors; no real patient information is shown.*
|
|
20
|
+
|
|
21
|
+
<details>
|
|
22
|
+
<summary><strong>See the validation findings</strong></summary>
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
Findings include the validation stage, rule identifier where available, and links to the XML location. Completed stages mean the checks ran; inspect the report status and coverage before treating a document as valid.
|
|
27
|
+
|
|
28
|
+
</details>
|
|
29
|
+
|
|
17
30
|
---
|
|
18
31
|
|
|
19
32
|
> [!NOTE]
|
|
20
|
-
> **Version 2
|
|
33
|
+
> **Version 2.0.1.** The container provides the validation API and browser UI. npm retains legacy APIs plus a typed HTTP client and CLI (Node 22.12+). Install the stable package without a preview tag. The validation scope is pinned XSD/Schematron with reviewed supplements; full FHIR model validation and clinical certification are outside that scope. See [coverage](docs/coverage.md) and the [release notes](https://github.com/priyaranjan-tokachichu/cda-schematron-validator/releases/tag/v2.0.1).
|
|
34
|
+
|
|
35
|
+
The [2.0.1 patch](docs/release-2.0.1.md) fixes malformed-XML handling in the legacy APIs.
|
|
36
|
+
|
|
37
|
+
## Upgrade from version 1
|
|
38
|
+
|
|
39
|
+
Use **Node 22.12.0 or newer**, then explicitly select the latest stable release:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
node --version
|
|
43
|
+
npm install cda-schematron-validator@latest
|
|
44
|
+
npm ls cda-schematron-validator
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Commit the updated `package.json` and lockfile, then run your application's tests. A dependency range such as `^1.1.12` stays on version 1 with ordinary `npm update`; the explicit install above updates that range. Use `npm outdated` to check for newer releases.
|
|
48
|
+
|
|
49
|
+
The seven legacy JavaScript exports remain available, including synchronous and Promise-based validation. They run locally without Docker and remain a partial Schematron interpreter. Correctness fixes can change previously incorrect results. For the modern XSD/Schematron pipeline, run the separate container and use `createClient()` or the CLI; installing npm alone does not start the service. See the [migration guide](docs/legacy-api.md#upgrade-from-version-1), [release notes](docs/release-2.0.0.md) and [terminology setup](docs/terminology.md).
|
|
21
50
|
|
|
22
51
|
<table>
|
|
23
52
|
<tr>
|
|
@@ -30,6 +59,8 @@
|
|
|
30
59
|
</tr>
|
|
31
60
|
</table>
|
|
32
61
|
|
|
62
|
+
> **Runtime and terminology setup:** Patched Temurin 25.0.5.1+2 LTS addresses the November Java vulnerability on AMD64 and ARM64. New images built from this checkout exclude the mixed-license C-CDA 2.1 vocabulary. Install your authorized pinned copy before using that profile’s Schematron checks. C-CDA 5.0 uses operator-supplied expansions and grammar definitions; the doctor lists missing datasets. See [terminology setup](docs/terminology.md).
|
|
63
|
+
|
|
33
64
|
## Quick start
|
|
34
65
|
|
|
35
66
|
Install Docker with Compose, then:
|
|
@@ -87,13 +118,15 @@ The legacy API remains a partial Schematron interpreter. Use the service for CDA
|
|
|
87
118
|
|
|
88
119
|
| Profile | Official Schematron release | CDA schema |
|
|
89
120
|
| --- | --- | --- |
|
|
90
|
-
| **C-CDA 2.1** · `ccda-2.1` | `2025SEP`, with
|
|
121
|
+
| **C-CDA 2.1** · `ccda-2.1` | `2025SEP`, with authorized operator vocabulary | CDA R2 + SDTC `20260205_SDTC` |
|
|
91
122
|
| **C-CDA 5.0** · `ccda-5.0` · default | `2026JUL` | CDA R2 + SDTC `20260205_SDTC` |
|
|
92
123
|
|
|
93
124
|
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). [Coverage remediation and local terminology work](docs/coverage.md).
|
|
94
125
|
|
|
95
126
|
> [!IMPORTANT]
|
|
96
|
-
> **C-CDA 5.0
|
|
127
|
+
> **Coverage is explicit.** The original C-CDA 5.0 generation report is preserved, with reviewed replacement checks reported separately. Completion requires a supported document-level template and every applicable check to be determinate. Missing operator data—including NUBC discharge status—produces coverage findings where needed. The scope is pinned CDA XSD and C-CDA Schematron with supplements, not full FHIR StructureDefinition or clinical certification. [See the checks and evidence](docs/coverage.md).
|
|
128
|
+
|
|
129
|
+
**Operator** means you or the administrator running the validator. Terminology is installed separately from the public image. To enable C-CDA 2.1 Schematron, follow the [official vocabulary download and installation steps](docs/terminology.md#get-and-install-the-c-cda-21-vocabulary). See [what was verified locally and how to recreate it](docs/terminology.md#what-was-installed-and-validated-locally).
|
|
97
130
|
|
|
98
131
|
Neither profile certifies clinical accuracy or every terminology requirement. See [standards, provenance, and coverage](docs/architecture.md#standards-and-coverage).
|
|
99
132
|
|
|
@@ -117,7 +150,7 @@ curl http://localhost:17643/v1/validate \
|
|
|
117
150
|
|
|
118
151
|
| Report status | Meaning |
|
|
119
152
|
| --- | --- |
|
|
120
|
-
| `valid` | No errors; configured checks and document coverage completed without
|
|
153
|
+
| `valid` | No errors; configured checks and document coverage completed without unresolved effective coverage gaps or truncation |
|
|
121
154
|
| `invalid` | Errors found; inspect completeness separately |
|
|
122
155
|
| `incomplete` | No errors found, but execution or coverage is incomplete; this is not a pass |
|
|
123
156
|
|
|
@@ -130,7 +163,7 @@ curl http://localhost:17643/v1/validate \
|
|
|
130
163
|
Install the package into your Node project:
|
|
131
164
|
|
|
132
165
|
```sh
|
|
133
|
-
npm install cda-schematron-validator
|
|
166
|
+
npm install cda-schematron-validator
|
|
134
167
|
```
|
|
135
168
|
|
|
136
169
|
```javascript
|
|
@@ -202,7 +235,7 @@ For the complete HTML engineering report, start the service and open [localhost:
|
|
|
202
235
|
|
|
203
236
|
## Development
|
|
204
237
|
|
|
205
|
-
Local service development requires
|
|
238
|
+
Local service development requires JDK 25, Maven 3.9+, and Python 3.11+. Node is required for the JavaScript library and its tests.
|
|
206
239
|
|
|
207
240
|
```sh
|
|
208
241
|
npm ci --ignore-scripts
|
package/docs/api.md
CHANGED
|
@@ -53,9 +53,10 @@ This XML is intentionally minimal and will produce findings. Replace it with you
|
|
|
53
53
|
|
|
54
54
|
| Field | Interpretation |
|
|
55
55
|
| --- | --- |
|
|
56
|
+
| `validationScope` | Pinned XSD/Schematron pipeline with reviewed supplements; not full FHIR or clinical certification |
|
|
56
57
|
| `status` | `valid`, `invalid`, or `incomplete` |
|
|
57
58
|
| `executionComplete` | Whether the configured engine stages finished without truncation |
|
|
58
|
-
| `validationComplete` | Also requires supported document-level coverage
|
|
59
|
+
| `validationComplete` | Also requires supported document-level coverage, reviewed generator replacements, determinate applicable checks and no truncation |
|
|
59
60
|
| `truncated` | The finding limit was reached; the report is partial |
|
|
60
61
|
| `summary` | Errors, warnings, total findings, and fired rules |
|
|
61
62
|
| `findings` | Severity, stage, message, rule ID, assertion test, XPath/context, and available locations |
|
|
@@ -65,7 +66,7 @@ This XML is intentionally minimal and will produce findings. Replace it with you
|
|
|
65
66
|
| `durationMs` | Engine validation duration, separate from upload queue wait |
|
|
66
67
|
| `requestId`, `validatedAt` | Request identity and timestamp |
|
|
67
68
|
|
|
68
|
-
`invalid` can coexist with `validationComplete: false`: errors were found, and some coverage is missing. `incomplete` is never a pass. C-CDA 5.0
|
|
69
|
+
`invalid` can coexist with `validationComplete: false`: errors were found, and some coverage is missing. `incomplete` is never a pass. C-CDA 5.0 preserves its historical upstream conversion report and lists reviewed replacements in `effectiveCoverage`. Missing data affects document completion at applicable locations; the dataset inventory remains separate. A missing or unsupported root document template cannot be rescued by nested section/entry rules firing.
|
|
69
70
|
|
|
70
71
|
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
|
|
|
@@ -97,10 +98,10 @@ Admitted uploads queue fairly for up to 30 seconds while waiting for memory. Val
|
|
|
97
98
|
|
|
98
99
|
## Node client and CLI
|
|
99
100
|
|
|
100
|
-
Requires Node 22.12+. Install the version 2
|
|
101
|
+
Requires Node 22.12+. Install the stable version 2 package:
|
|
101
102
|
|
|
102
103
|
```sh
|
|
103
|
-
npm install cda-schematron-validator
|
|
104
|
+
npm install cda-schematron-validator
|
|
104
105
|
```
|
|
105
106
|
|
|
106
107
|
```javascript
|
package/docs/architecture.md
CHANGED
|
@@ -15,7 +15,7 @@ flowchart LR
|
|
|
15
15
|
G --> H[Findings and coverage report]
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Patched Eclipse Temurin 25.0.5.1+2 LTS 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. Reviewed local supplements run inside the compiled Schematron. An optional offline membership index answers exact code-system/code lookups from a checksum-pinned local pack; it does not perform terminology network calls or load whole patient documents into a shared cache. See [local terminology snapshots](terminology.md).
|
|
19
19
|
|
|
20
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
21
|
|
|
@@ -34,12 +34,14 @@ The pinned releases omit query binding and use XPath 1.0 coercions. Compilation
|
|
|
34
34
|
| Resource | Official release | Used for |
|
|
35
35
|
| --- | --- | --- |
|
|
36
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
|
|
37
|
+
| [HL7 C-CDA 2.1](https://github.com/HL7/CDA-ccda-2.1/releases/tag/2025SEP) | `2025SEP` | Full supplied Schematron; authorized operator vocabulary |
|
|
38
38
|
| [HL7 C-CDA 5.0](https://github.com/HL7/CDA-ccda/releases/tag/2026JUL) | `2026JUL` | Full supplied Schematron, bindings, and generation report |
|
|
39
39
|
|
|
40
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
41
|
|
|
42
|
-
C-CDA 5.0
|
|
42
|
+
The original C-CDA 5.0 generation report is preserved: 4 errors, 6 unhandled invariants and 28 non-loaded value-set entries. Reviewed supplements now account for those pinned omissions; new or changed reports require a new review. Completion is document-specific and still requires every applicable check to be determinate. Missing optional data that a document does not use does not force global incompleteness. See [coverage semantics and evidence](coverage.md).
|
|
43
|
+
|
|
44
|
+
Public images omit the mixed-license C-CDA 2.1 vocabulary. An authorized operator-supplied pinned copy restores that profile's Schematron execution; schema checks remain available without it.
|
|
43
45
|
|
|
44
46
|
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
47
|
|
|
@@ -53,7 +55,7 @@ The container is the primary service distribution. The npm package preserves leg
|
|
|
53
55
|
|
|
54
56
|
## Verification
|
|
55
57
|
|
|
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).
|
|
58
|
+
Current follow-up evidence is recorded in [coverage-progress.json](../reports/coverage-progress.json) and [reference-comparison.json](../reports/reference-comparison.json). Earlier preview evidence is retained 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
59
|
|
|
58
60
|
| Check | Coverage |
|
|
59
61
|
| --- | --- |
|
package/docs/coverage.md
CHANGED
|
@@ -1,26 +1,50 @@
|
|
|
1
|
-
# C-CDA 5.0 coverage
|
|
1
|
+
# C-CDA 5.0 validation coverage
|
|
2
2
|
|
|
3
|
-
[← Architecture](architecture.md) · [
|
|
3
|
+
[← Architecture](architecture.md) · [Operator setup](terminology.md) · [HL7 validation guidance](https://hl7.org/cda/us/ccda/5.0.0/validation.html)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The service validates the **pinned CDA XSD and C-CDA Schematron, with reviewed local supplements**. It does not implement general FHIR StructureDefinition validation or clinical certification. Every report states its `validationScope`.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Completion has a precise meaning
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- `executionComplete`: the configured engine stages finished without a failure.
|
|
10
|
+
- `validationComplete`: execution finished, a supported document-level template matched, findings were not truncated, the pinned generator omissions have reviewed replacements, and no applicable check was indeterminate.
|
|
11
|
+
- `status`: `valid` requires complete validation and no errors. An error makes the document `invalid`, even if coverage is also incomplete. No errors with incomplete coverage gives `incomplete`.
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
A completed invalid report is possible: all applicable checks ran and found errors. Completion describes the selected pipeline, not every possible CDA/FHIR or clinical constraint.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Missing data produces a coverage finding **where a document needs that data**, including preferred bindings when warnings are hidden. Unrelated absent optional bindings do not make every document incomplete. The dataset inventory remains separate: an installation without NUBC is not data-ready even if a document that never uses that binding completes.
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
## Reviewed replacements for the pinned generation report
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
The unchanged upstream report lists **4 generation errors, 6 unhandled invariants and 28 non-loaded value-set entries**. Entries overlap. `generationReport` and `generationCoverage` preserve this historical evidence. `effectiveCoverage` accounts for the replacements; the report SHA-256 must match the reviewed release. A new upstream report requires review and cannot automatically inherit completion.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
| Original omission | Implemented replacement |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| Person name `81-9371` | Reuse all 11 pinned patient-name assertions at the relevant name locations, including the permitted plain-text alternative. List-valued use/qualifier attributes are checked token by token. |
|
|
24
|
+
| Procedure `1198-8487`, `1198-8511` | Exact SNOMED CT Procedure membership and the original alternative code systems. Missing or indeterminate membership produces coverage findings. |
|
|
25
|
+
| Two procedure timestamps | Calendar and timezone comparisons with conservative handling of insufficient precision. Unknown comparisons remain coverage findings. |
|
|
26
|
+
| Location `shall-use-one-binding` | Three-set union: one known member establishes membership; all known nonmembers fail; an unresolved union is incomplete. |
|
|
27
|
+
| ActPriority expansion | Reviewed callback hierarchy and admission-urgency union from pinned HL7 terminology definitions. |
|
|
28
|
+
| Three CarePlanAct unions | Authoritative alternatives include the unprofiled base CDA Act or Observation, so no templateId is invented. 103 scoped assertions restore base-root cardinalities, fixed values, required bindings and II constraints, alongside XSD and narrower template rules. |
|
|
29
|
+
| Catalog binding omissions | Runtime checks at every recorded binding location. Required bindings are errors; preferred/extensible bindings retain warning severity. Missing data is always disclosed. |
|
|
20
30
|
|
|
21
|
-
|
|
31
|
+
CarePlan base checks are generated reproducibly from checksum-recorded CDA Core 2.0.3-sd, C-CDA 5.0.0 and HL7 Terminology 7.1.0 definitions. This is a scoped supplement, not a general `conformsTo()` implementation. See the embedded [model receipts](../service/src/main/resources/coverage/careplan-base.json).
|
|
22
32
|
|
|
23
|
-
##
|
|
33
|
+
## Terminology and conservative boundaries
|
|
34
|
+
|
|
35
|
+
The verified local operator pack contains **29 snapshots, 1,013,055 membership entries, 28 active indexes and two grammars**. It enables all six supplements and the catalog checks listed in current [verification evidence](../reports/coverage-progress.json). Data stays outside Git, npm and public images.
|
|
36
|
+
|
|
37
|
+
US Core condition and procedure sets are derived from the authorized UMLS 2026AB archive and LOINC Complete 2.83. SNOMED ancestry uses source-asserted AUI hierarchy paths, not UMLS concept similarity. The 62,110-member Procedure hierarchy exactly matches the independently acquired VSAC snapshot. US Core condition has 262,583 pairs; procedure has 274,743. Source editions are exposed, including **CDT 2025**, not an invented newer edition.
|
|
38
|
+
|
|
39
|
+
The only remaining absent canonical in that local inventory is **NUBC patient discharge status**. Operators must provide an authorized complete expansion; no scraped substitute is distributed. Missing applicable data prevents completion. See [setup](terminology.md).
|
|
40
|
+
|
|
41
|
+
Other explicit boundaries prevent false passes: unsupported SNOMED expressions, standalone CPT/HCPCS modifiers, mismatched declared code-system editions, ambiguous scalar vocabulary values, excessive grammar complexity, and unvalidated BCP 47 extension semantics are indeterminate. UCUM expressions use a pinned grammar; language tags use the November 18, 2026 IANA registry. Whole finite-code strings use exact membership, not substring matching.
|
|
42
|
+
|
|
43
|
+
## Independent checks
|
|
44
|
+
|
|
45
|
+
[Reference evidence](../reports/reference-comparison.json) records targeted comparisons against HL7 FHIR Validator 7.0.6, including negative CarePlan base constraints. Both validators run locally. Reference terminology is disabled, so this establishes neither terminology equivalence nor full-model equivalence. Broad FHIR slicing comparisons remain inconclusive without matching terminology and are recorded as such; they are not counted as passing comparisons.
|
|
46
|
+
|
|
47
|
+
## Historical conversion inventory
|
|
24
48
|
|
|
25
49
|
| Invariant | Template | Why omitted | Required fix and verification |
|
|
26
50
|
| --- | --- | --- | --- |
|
|
@@ -38,7 +62,7 @@ The optional [offline terminology adapter](terminology.md) restores `1198-8487`
|
|
|
38
62
|
- CarePlanAct: Profile http://hl7.org/cda/stds/core/StructureDefinition/Act does not have an identifier
|
|
39
63
|
- Failed to expand value set v3-ActPriority: Unable to expand dependent value set http://terminology.hl7.org/ValueSet/v3-ActPriorityCallback
|
|
40
64
|
|
|
41
|
-
|
|
65
|
+
The reviewed replacements above address this pinned report. Its original entries remain here for audit; they are not a claim that the omissions remain unimplemented.
|
|
42
66
|
|
|
43
67
|
## Terminology work
|
|
44
68
|
|
|
@@ -111,14 +135,8 @@ Locate the canonical value-set definition in the pinned guide/dependencies and o
|
|
|
111
135
|
|
|
112
136
|
- `http://hl7.org/cda/us/ccda/ValueSet/CMSPlaceOfServiceCodes`
|
|
113
137
|
|
|
114
|
-
##
|
|
115
|
-
|
|
116
|
-
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.
|
|
117
|
-
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.
|
|
118
|
-
3. Verify vocabulary completeness, provenance, permissions, and checksum. An unavailable external source remains an explicit unresolved gap.
|
|
119
|
-
4. Run both profiles, legacy compatibility, memory/concurrency tests, and compile/startup benchmarks.
|
|
120
|
-
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.
|
|
138
|
+
## Update and release policy
|
|
121
139
|
|
|
122
|
-
|
|
140
|
+
Preserve source identities, editions, checksums and the historical generator report when updating. Re-run positive/negative rules, legacy compatibility, encoded/decoded limits, constrained-heap concurrency and startup/performance checks. New omission categories must be reviewed before effective coverage can be complete.
|
|
123
141
|
|
|
124
|
-
Version 2 is
|
|
142
|
+
Version 2.0.0 is the stable line for this bounded validation pipeline. It does not claim full FHIR or clinical certification. Older integrations can explicitly select 1.1.12; immutable preview artifacts remain available under their versioned identifiers.
|
package/docs/deployment.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[← Project home](../README.md) · [API reference](api.md) · [Architecture](architecture.md)
|
|
4
4
|
|
|
5
|
+
Version 2.0.0 mounts operator terminology separately using `CDA_TERMINOLOGY_DIR` (Compose) or `TERMINOLOGY_DIR` (JVM). New public images omit the mixed-license C-CDA 2.1 vocabulary; install an authorized pinned copy using the [setup guide](terminology.md) before using that profile’s Schematron checks. Existing published preview.2 images are unchanged.
|
|
6
|
+
|
|
5
7
|
## Run locally
|
|
6
8
|
|
|
7
9
|
```sh
|
|
@@ -15,16 +17,27 @@ docker compose logs validator
|
|
|
15
17
|
docker compose down
|
|
16
18
|
```
|
|
17
19
|
|
|
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
|
|
20
|
+
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 versioned stable image is `ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.1`. Existing preview images do not acquire the new runtime pins automatically.
|
|
19
21
|
|
|
20
|
-
Run the
|
|
22
|
+
Run the versioned image directly:
|
|
21
23
|
|
|
22
24
|
```sh
|
|
23
25
|
docker run -d --name cda-validator --memory=1536m --cpus=2 \
|
|
24
26
|
--read-only --tmpfs /tmp:size=64m,noexec,nosuid \
|
|
25
27
|
--cap-drop=ALL --security-opt=no-new-privileges --pids-limit=128 \
|
|
26
28
|
-p 127.0.0.1:17643:17643 \
|
|
27
|
-
ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.
|
|
29
|
+
ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.1
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Patched Java runtime
|
|
33
|
+
|
|
34
|
+
Build and runtime images are digest-pinned to **Eclipse Temurin 25.0.5.1+2 LTS** on AMD64 and ARM64. This includes the November fix for [CVE-2026-114938](https://adoptium.net/es/news/2026/11/temurin-november-2026-cspu-java4shell). Java 27 is the newer feature line; its official image had mixed patch levels across architectures when reviewed. The selected LTS is the latest patched LTS for both supported targets, not a claim that 25 is the latest feature release.
|
|
35
|
+
|
|
36
|
+
`profiles/runtime.lock.json` records the exact versions and digests. CI checks the built runtime; the upstream watch flags a newer LTS release for review. `GET /v1/version` exposes the actual running JVM version and vendor. Published older previews do not acquire the fix automatically; rebuilding and releasing the pinned image is required. A local source build requires JDK 25.
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
python3 scripts/check-java-runtime.py --image cda-validator:coverage-followup
|
|
40
|
+
python3 scripts/check-java-runtime.py --upstream
|
|
28
41
|
```
|
|
29
42
|
|
|
30
43
|
## Configuration
|
|
@@ -81,6 +94,8 @@ The image otherwise uses `-XX:MaxRAMPercentage=70`, so heap sizing follows the c
|
|
|
81
94
|
|
|
82
95
|
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
96
|
|
|
97
|
+
The full local pack contains over one million membership entries. Startup estimates index memory before loading and fails clearly when the selected heap is too small. Keep at least the tested 1 GiB heap / 1.5 GiB container budget for that pack; raise both for larger packs or more concurrency.
|
|
98
|
+
|
|
84
99
|
## Other operational limits
|
|
85
100
|
|
|
86
101
|
| Limit | Default |
|
|
Binary file
|
|
Binary file
|
package/docs/legacy-api.md
CHANGED
|
@@ -7,6 +7,22 @@ The original JavaScript APIs remain local and retain their result shape and sync
|
|
|
7
7
|
> [!IMPORTANT]
|
|
8
8
|
> The legacy implementation is a **partial Schematron interpreter**, with no XSD validation. Installing the modern package does not turn `validate()` into the full service engine. Use `createClient()` for the modern pipeline.
|
|
9
9
|
|
|
10
|
+
## Upgrade from version 1
|
|
11
|
+
|
|
12
|
+
1. Use Node **22.12.0 or newer**. Check your local and CI runtimes with `node --version`.
|
|
13
|
+
2. Install the latest stable package explicitly:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install cda-schematron-validator@latest
|
|
17
|
+
npm ls cda-schematron-validator
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
3. Commit the updated `package.json` and lockfile, then run your application's tests. Existing `^1.x` dependency ranges and lockfiles do not automatically adopt the new major release through `npm update`.
|
|
21
|
+
4. Keep existing legacy calls if you need their synchronous/Promise result contracts. Review the [correctness fixes](#correctness-fixes-in-version-2), which can change previously incorrect validation results.
|
|
22
|
+
5. To use the modern engine, follow [the service migration steps](#move-to-the-modern-pipeline) and [terminology setup](terminology.md). The container is distributed separately; installing npm alone does not provide XSD validation or launch the service.
|
|
23
|
+
|
|
24
|
+
Older integrations that cannot meet the Node requirement can explicitly retain `cda-schematron-validator@1.1.12`. Legacy versions remain downloadable. If npm displays a legacy-version deprecation notice, use this guide to plan the upgrade; the notice does not change your installed dependencies. See the [2.0.0 release notes](release-2.0.0.md).
|
|
25
|
+
|
|
10
26
|
## Exports preserved
|
|
11
27
|
|
|
12
28
|
| Export | Behavior |
|
|
@@ -37,6 +53,8 @@ console.log(result.errorCount, result.errors);
|
|
|
37
53
|
|
|
38
54
|
Legacy calls accept XML/Schematron strings or file paths. `schematron` may be `null` when `options.parsedSchematronMap` is supplied. Unlike the modern service, legacy findings may include XML snippets.
|
|
39
55
|
|
|
56
|
+
**Since 2.0.1:** malformed document or Schematron XML throws a `SyntaxError` in `validate()` and rejects the async/batch Promises. DTD declarations are unsupported and rejected. Malformed external-resource XML is reported as an ignored check with a parsing error. The APIs no longer accept parser-repaired XML as an apparent pass. See the [patch release notes](release-2.0.1.md), including the boundary for caller-parsed DOMs.
|
|
57
|
+
|
|
40
58
|
## Results and options
|
|
41
59
|
|
|
42
60
|
Results retain `errorCount`, `warningCount`, `ignoredCount`, `errors`, `warnings`, and `ignored`. Ignored findings should be reviewed when assessing interpreter coverage; a zero error count does not establish full CDA conformance.
|
|
@@ -67,4 +85,4 @@ The modern service accepts installed profile IDs and XML text; it does not accep
|
|
|
67
85
|
|
|
68
86
|
## Release boundary
|
|
69
87
|
|
|
70
|
-
|
|
88
|
+
Version 2.0.0 preserves the seven legacy exports and adds the HTTP client and CLI. It requires Node 22.12+. Version `1.1.12` remains available for older integrations with an explicit version selection. Install the stable package without `@next`; preview builds remain separately versioned. The Java service is distributed separately as a container. Merging alone does not publish either artifact.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 2.0.0 stable release
|
|
2
|
+
|
|
3
|
+
Version 2.0.0 is the stable release line prepared in PR #53. The npm package is published under `latest`; container images use the immutable version tag `v2.0.0`. Earlier preview artifacts remain unchanged.
|
|
4
|
+
|
|
5
|
+
## What version 2 provides
|
|
6
|
+
|
|
7
|
+
A self-hosted container with a browser XML workspace and structured HTTP validation API; pinned CDA R2/SDTC, C-CDA 2.1 and C-CDA 5.0 resources; detailed findings, source provenance and explicit coverage; a Node/TypeScript HTTP client and CLI; and the seven existing in-process JavaScript exports.
|
|
8
|
+
|
|
9
|
+
The pipeline is **pinned XSD and Schematron with reviewed supplements**. It is not full FHIR StructureDefinition validation or clinical certification. See [coverage semantics](coverage.md).
|
|
10
|
+
|
|
11
|
+
## Changes after preview.2
|
|
12
|
+
|
|
13
|
+
- Replace the reviewed generator omissions with person-name, procedure, timestamp, location-union, CarePlan base-root and catalog binding checks. Preserve the historical report; changed reports require review.
|
|
14
|
+
- Evaluate completion per document. Missing applicable data and indeterminate checks remain explicit even when advisory warnings are hidden. Unused optional data does not force every document incomplete.
|
|
15
|
+
- Derive reviewed US Core condition/procedure indexes offline from authorized UMLS 2026AB and LOINC Complete 2.83. Keep source editions and provenance; never bundle the operator pack.
|
|
16
|
+
- Require authorized operator installation of the mixed-license C-CDA 2.1 vocabulary in new public images. Schema checks still run without it, while the Schematron stage reports setup required. This changes container setup, not the legacy JavaScript API contract.
|
|
17
|
+
- Use digest-pinned Temurin 25.0.5.1+2 LTS on AMD64 and ARM64, including the November CVE-2026-114938 fix. Expose the actual JVM version and check it in CI; watch upstream LTS releases.
|
|
18
|
+
- Keep the 20 MiB XML default, streaming JSON decoding, shared upload memory budget and bounded fair queue. Preserve input-revision checks against stale UI results.
|
|
19
|
+
- Use independent blue/slate interface styling and refresh the standalone HTML architecture report.
|
|
20
|
+
|
|
21
|
+
## Upgrade requirements
|
|
22
|
+
|
|
23
|
+
To upgrade from version 1, use Node **22.12.0 or newer** and explicitly install the latest stable package:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm install cda-schematron-validator@latest
|
|
27
|
+
npm ls cda-schematron-validator
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Commit the updated dependency manifest and lockfile, then run your application's tests. Ordinary `npm update` respects an existing `^1.x` range and does not adopt version 2. The [migration guide](legacy-api.md#upgrade-from-version-1) covers preserved APIs, correctness changes and the separate service setup. Legacy versions remain downloadable for integrations that need them. An npm deprecation notice encourages migration without changing installed dependencies.
|
|
31
|
+
|
|
32
|
+
The npm package requires **Node 22.12+**. Local service builds require **JDK 25**; running the container requires no host Java. Existing legacy calls keep their synchronous/Promise contracts but remain a partial Schematron interpreter without XSD validation.
|
|
33
|
+
|
|
34
|
+
**Operator** means the person or organization running the validator: you locally, or your administrator/IT team in a hosted deployment. **Operator-supplied terminology** means source-publisher vocabulary files that this administrator obtains and installs locally; it does not mean patient data. These files are separate from the public application image and npm package.
|
|
35
|
+
|
|
36
|
+
New containers need a read-only terminology volume. To enable C-CDA 2.1 Schematron, obtain the exact `voc.xml` from the [official HL7 2025SEP archive](https://github.com/HL7/CDA-ccda-2.1/releases/tag/2025SEP), verify and extract it with `python3 scripts/prepare-assets.py`, then install it with the image's `TerminologyTool install-legacy` command. The [step-by-step guide](terminology.md#get-and-install-the-c-cda-21-vocabulary) provides download, installation, startup and validation commands. C-CDA 2.1 XSD checks remain available before installation; the broader C-CDA 5.0 pack is not required to enable its Schematron stage.
|
|
37
|
+
|
|
38
|
+
CPT/ADA and other source rights are separate from the application license. Download availability, installation and checksum verification do not grant data rights; follow the applicable publisher terms. No data license is granted by installation.
|
|
39
|
+
|
|
40
|
+
The recorded local verification used the pinned C-CDA 2.1 vocabulary and a separate pack of **29 snapshots / 1,013,055 membership entries, 28 active indexes and two grammars**. The pack comprised 21 VSAC snapshots, four public HL7/CDC expansions, one HealthcareServiceLocation expansion and three LOINC/UMLS-derived sets. Sources included UMLS 2026AB, LOINC 2.83, UCUM 2.2 and the November 18, 2026 IANA registries. The files remain local and are not release downloads. The [reproduction guide](terminology.md#recreate-the-broader-local-terminology-setup) links the source publishers, reviewed VSAC counts/hashes, import commands and readiness checks.
|
|
41
|
+
|
|
42
|
+
This was **not all terminology**: NUBC discharge status was absent and remains administrator-supplied. An applicable missing NUBC check prevents completion. Unsupported expressions/modifiers, mismatched editions and indeterminate grammar/timestamp cases also remain incomplete.
|
|
43
|
+
|
|
44
|
+
## Verification
|
|
45
|
+
|
|
46
|
+
65 JavaScript, 45 Java and 17 Python tests pass. Both architecture builds and actual runtime versions are checked. Fifteen targeted synthetic probes agree with an independent HL7 FHIR validator; terminology was disabled in that reference run, so no full-model or terminology equivalence is claimed. A broader comparison is inconclusive without matching terminology.
|
|
47
|
+
|
|
48
|
+
Six concurrent maximum-size uploads complete in both framing modes with the full local pack on a 1 GiB heap. Health remains available and no retries are needed for admitted uploads. Current [evidence](../reports/coverage-progress.json), [image scan](../reports/security.json) and [HTML report](../reports/architecture.html) record the exact scope and results.
|
|
49
|
+
|
|
50
|
+
A [November 28, 2026 published-image smoke check](../reports/terminology-setup-verification.json) verifies the documented vocabulary install path: C-CDA 2.1 Schematron is skipped before installation and completes afterward (110 rules fired). C-CDA 5.0 also completes its configured pipeline with the local pack on the tested fixture. Both installed-data fixtures are invalid documents with completed coverage; this is not a claim that all documents or all terminology were validated.
|
|
51
|
+
|
|
52
|
+
## Release publication
|
|
53
|
+
|
|
54
|
+
Release publication merges the owner-authorized PR through GitHub, publishes versioned AMD64/ARM64 container artifacts from that commit, publishes npm 2.0.0 with the `latest` tag, then verifies public install, image startup and runtime metadata. Keep immutable preview artifacts intact. npm may require its separate per-publication authentication.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# 2.0.1 patch release
|
|
2
|
+
|
|
3
|
+
The legacy JavaScript APIs now reject malformed XML instead of repairing it and returning an apparent pass. In 2.0.0, `<root><item ok="yes"></root>` could produce a console warning while `validate()` and `validateAsync()` returned zero errors, warnings and ignored checks.
|
|
4
|
+
|
|
5
|
+
## Corrected behavior
|
|
6
|
+
|
|
7
|
+
- `validate()` throws a `SyntaxError` for malformed document or Schematron XML. `validateAsync()`, `validateFileListAsync()` and `validateFileObjectAsync()` reject their Promises.
|
|
8
|
+
- Document XML is checked even when a parsed Schematron map is supplied. Malformed Schematron is not cached.
|
|
9
|
+
- Malformed external vocabulary XML produces an ignored check with an explicit parsing error rather than a result based on a repaired resource. Review `ignoredCount` when using the partial legacy interpreter.
|
|
10
|
+
- DTD declarations are unsupported and rejected in legacy document, Schematron and external-resource XML. Predefined XML entities and character references remain supported.
|
|
11
|
+
- Well-formed inputs retain the existing result shape, synchronous/Promise contracts, namespace handling and finding locations. The modern service validation pipeline is unchanged; its version metadata is updated to 2.0.1.
|
|
12
|
+
|
|
13
|
+
## Upgrade
|
|
14
|
+
|
|
15
|
+
Use Node 22.12.0 or newer:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install cda-schematron-validator@latest
|
|
19
|
+
npm ls cda-schematron-validator
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Handle thrown/rejected parsing errors in legacy integrations. Callers supplying `parseSchematron()` with a DOM must ensure their own parser rejected malformed source; a repaired DOM cannot preserve evidence of every original syntax error.
|
|
23
|
+
|
|
24
|
+
The modern engine remains a separate container, tagged `ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.1`. [Terminology installation](terminology.md), coverage limits and the [version 1 migration guide](legacy-api.md#upgrade-from-version-1) still apply.
|
package/docs/terminology.md
CHANGED
|
@@ -1,21 +1,163 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Administrator-supplied terminology
|
|
2
2
|
|
|
3
3
|
[← Coverage inventory](coverage.md) · [Deployment](deployment.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Version 2.0.0 adds coverage and packaging changes after `2.0.0-preview.2`. Older published images are unchanged. New public images omit the entire mixed-license C-CDA 2.1 `voc.xml`, which contains CPT entries. The service can start and show the UI without it; C-CDA 2.1 schema checks run, and its Schematron stage explicitly reports setup required until an authorized pinned vocabulary is installed. The legacy npm API remains compatible and accepts caller-supplied validation resources.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Who is the operator?
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
**Operator** means the person or organization that runs this validator: you on a personal computer, or the administrator/IT team responsible for a hosted installation. **Operator-supplied terminology** means terminology files that the administrator obtains from the source publisher and installs in the local `terminology` folder. It does not mean patient data, a clinician entering codes, or a separate commercial operator service.
|
|
10
10
|
|
|
11
|
-
The
|
|
11
|
+
The application includes its validation rules and import/install tools. Public npm packages and final container images do not include the separately installed terminology pack. Download access and checksums do not establish permission to use or redistribute the underlying terminology; consult the applicable publisher terms for your deployment.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## What was installed and validated locally?
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
The recorded 2.0.0 verification used the pinned C-CDA 2.1 `voc.xml`, plus a local C-CDA 5.0 pack containing **29 snapshots / 1,013,055 membership entries**, **28 active indexes**, and **two grammars** (UCUM and language tags). The pack was assembled from 21 reviewed VSAC exports, four reviewed public HL7/CDC expansions, a HealthcareServiceLocation expansion, and three LOINC/UMLS-derived sets. Source editions include UMLS 2026AB, LOINC 2.83 and the editions listed [below](#prepare-us-core-condition-and-procedure-sets-from-umls).
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
This was **not every terminology set**: NUBC patient discharge status was not installed. The pinned XSD/Schematron stages and reviewed supplements were exercised with local data, including concurrent maximum-size uploads. Individual documents can complete when they do not need missing data; an applicable missing NUBC check, unsupported expression or other indeterminate check prevents completion. Successful engine execution or an HTTP 200 response is not evidence that a document is valid.
|
|
18
|
+
|
|
19
|
+
The recorded automated suite comprised 65 JavaScript, 45 Java and 17 Python tests. Fifteen targeted comparisons against HL7 FHIR Validator used **reference terminology disabled**; they do not prove complete terminology or StructureDefinition equivalence. See the dated [verification evidence](../reports/coverage-progress.json) and [reference comparison](../reports/reference-comparison.json). The local pack is not a downloadable project artifact.
|
|
20
|
+
|
|
21
|
+
A [November 28, 2026 smoke check](../reports/terminology-setup-verification.json) of the published image confirmed that C-CDA 2.1 Schematron is skipped without the vocabulary and completes after installation (110 rules fired on `test/VitalSigns.xml`). Both stages also completed for the C-CDA 5.0 fixture with the local pack. The fixtures reported `invalid` with `validationComplete: true`: all applicable checks completed and found document errors. These are execution checks, not passing-document or clinical certification claims.
|
|
22
|
+
|
|
23
|
+
## Choose your setup
|
|
24
|
+
|
|
25
|
+
| Goal | Data to install | Result |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| C-CDA 2.1 schema checks | No separate terminology | XSD runs; Schematron reports setup required until its vocabulary is installed. |
|
|
28
|
+
| C-CDA 2.1 XSD and Schematron | The exact pinned HL7 2025SEP `voc.xml` | Both stages can run; terminology coverage remains limited to that upstream snapshot. |
|
|
29
|
+
| Broader C-CDA 5.0 supplements and binding checks | The separate VSAC, HL7/CDC, LOINC/UMLS and grammar pack | Applicable installed checks run; missing NUBC or other required data still prevents completion. |
|
|
30
|
+
|
|
31
|
+
The 29-snapshot C-CDA 5.0 pack is **not a prerequisite** for enabling C-CDA 2.1 Schematron. Start with the next section for that profile.
|
|
32
|
+
|
|
33
|
+
## Get and install the C-CDA 2.1 vocabulary
|
|
34
|
+
|
|
35
|
+
Prerequisites: Git, Python 3 and Docker. No host Java or Node is needed for these commands. After reviewing the source terms applicable to your use, obtain the **2025SEP** archive from the [official HL7 release](https://github.com/HL7/CDA-ccda-2.1/releases/tag/2025SEP). It is named `CDAR2_IG_CCDA_CLINNOTES_R1_DSTU2.1_2025SEP.zip` and contains `voc.xml`. A direct publisher download is available from that release; do not substitute a newer or edited vocabulary for the pinned file.
|
|
36
|
+
|
|
37
|
+
The existing asset preparation command downloads the official pinned archives, checks their SHA-256 values against [the source lock](../profiles/sources.lock.json), and extracts the vocabulary locally:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
git clone https://github.com/priyaranjan-tokachichu/cda-schematron-validator.git
|
|
41
|
+
cd cda-schematron-validator
|
|
42
|
+
python3 scripts/prepare-assets.py
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The required file is now `service/assets/ccda-2.1/voc.xml`. This command prepares all three pinned validation-asset archives; it does **not** download the separate VSAC/UMLS/LOINC pack. The C-CDA 2.1 archive SHA-256 is `9c9a73294fbc4bea2c31e3650184609fa2d8894a848da6240c0916cd1e1c0d23`. If you download the ZIP manually, verify that checksum and extract its `voc.xml`, then use its absolute path in the input mount below.
|
|
46
|
+
|
|
47
|
+
Install into your own terminology folder using the published application image:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
IMAGE=ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.0
|
|
51
|
+
docker pull "$IMAGE"
|
|
52
|
+
mkdir -p terminology
|
|
53
|
+
docker run --rm --network none --entrypoint java \
|
|
54
|
+
--user "$(id -u):$(id -g)" \
|
|
55
|
+
-v "$PWD/terminology:/app/terminology" \
|
|
56
|
+
-v "$PWD/service/assets/ccda-2.1/voc.xml:/input/voc.xml:ro" \
|
|
57
|
+
"$IMAGE" -cp /app/app.jar org.cdavalidator.TerminologyTool \
|
|
58
|
+
install-legacy /input/voc.xml
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The installer checks the vocabulary checksum required by the image and writes `terminology/ccda-2.1-voc.xml`. An incorrect edition is rejected. The installation stays local; do not commit or publish the vocabulary or terminology folder.
|
|
62
|
+
|
|
63
|
+
Start the service with that folder mounted read-only:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
docker run --rm --read-only --tmpfs /tmp:size=64m,noexec,nosuid \
|
|
67
|
+
--memory=1536m -e JAVA_TOOL_OPTIONS=-Xmx1g \
|
|
68
|
+
-p 127.0.0.1:17643:17643 \
|
|
69
|
+
-v "$PWD/terminology:/app/terminology:ro" \
|
|
70
|
+
"$IMAGE"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Use an unused host port if 17643 is occupied, and use that same port in the following commands. In another terminal:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
curl --fail --silent --show-error http://127.0.0.1:17643/v1/profiles
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
For profile `ccda-2.1`, check `terminologySetup.ready: true`. The `ccda-5.0` inventory can still report missing datasets; installing the legacy vocabulary alone does not make the other profile data-ready. The existing `doctor` command [below](#mount-diagnose-and-run) checks both profiles and can therefore still exit with code 2.
|
|
80
|
+
|
|
81
|
+
Submit a local document with the C-CDA 2.1 profile (run from the repository folder):
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
python3 - <<'PYDOC' > /tmp/ccda-21-request.json
|
|
85
|
+
import json
|
|
86
|
+
from pathlib import Path
|
|
87
|
+
print(json.dumps({"xml": Path("test/VitalSigns.xml").read_text(),
|
|
88
|
+
"profile": "ccda-2.1", "includeWarnings": True}))
|
|
89
|
+
PYDOC
|
|
90
|
+
curl --fail --silent --show-error http://127.0.0.1:17643/v1/validate \
|
|
91
|
+
-H 'Content-Type: application/json' \
|
|
92
|
+
--data-binary @/tmp/ccda-21-request.json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`test/VitalSigns.xml` is a test fixture, not a guaranteed valid clinical document. Inspect `stages`, `executionComplete`, `validationComplete` and `status`; findings may be expected. Restart the service after changing terminology files.
|
|
96
|
+
|
|
97
|
+
## Recreate the broader local terminology setup
|
|
98
|
+
|
|
99
|
+
Use a checkout containing this guide and its checklists. Obtain restricted source downloads through your own publisher accounts; the project does not distribute the local pack or accept source terms for you.
|
|
100
|
+
|
|
101
|
+
| Component | Where to obtain it | Local preparation |
|
|
102
|
+
| --- | --- | --- |
|
|
103
|
+
| 21 VSAC snapshots | [NLM VSAC](https://vsac.nlm.nih.gov/); search each OID in the [reviewed checklist](../profiles/terminology-svs-checklist.json), select the reviewed expansion and export complete SVS XML | Use `import-svs.py` with that checklist as shown below. Include retired sets referenced by the pinned guide after review. |
|
|
104
|
+
| Four public HL7/CDC expansions and two grammars | Publisher URLs and hashes in [the terminology lock](../profiles/terminology-sources.lock.json) | `python3 scripts/prepare-public-terminology.py --download --grammars --output terminology` |
|
|
105
|
+
| HealthcareServiceLocation union | Obtain a complete FHIR expansion of `http://terminology.hl7.org/ValueSet/v3-HealthcareServiceLocation`, definition version `4.0.0`, from your configured terminology service | Import with the [location checklist](../profiles/terminology-location-checklist.json) and [explicit system mappings](../profiles/terminology-location-systems.json), as shown below. |
|
|
106
|
+
| LOINC document types | [LOINC Complete 2.83](https://loinc.org/downloads/) through your LOINC account | `python3 scripts/import-loinc.py --input /private/path/Loinc_2.83.zip --output terminology` |
|
|
107
|
+
| US Core condition and procedure sets | [NLM UMLS downloads](https://www.nlm.nih.gov/research/umls/licensedcontent/umlsknowledgesources.html): the full **2026AB distribution archive**, plus LOINC Complete 2.83 | Use `import-umls.py` [below](#prepare-us-core-condition-and-procedure-sets-from-umls). Do not substitute a precomputed subset or individual RRF download; archive hashes must match the lock. |
|
|
108
|
+
| NUBC discharge disposition | An authorized source providing the applicable complete, versioned expansion | Use the FHIR importer with your reviewed version, count and OID mappings. This dataset was **not** in the recorded local pack. |
|
|
109
|
+
|
|
110
|
+
For the VSAC export collection:
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
python3 scripts/import-svs.py \
|
|
114
|
+
--input-glob '/private/path/RetrieveMultipleValueSets*.xml' \
|
|
115
|
+
--expected profiles/terminology-svs-checklist.json \
|
|
116
|
+
--output terminology
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The checklist records the actual local counts, source hashes, normalized snapshot hashes and status. Its source-version label was `Latest` in those exports; it is **not an immutable release identifier**. A later export can differ. Counts alone do not establish identical membership: compare the imported snapshot hashes with the checklist for exact reproduction. Review changed editions/counts explicitly instead of editing the checklist merely to force an import to pass. No terminology codes or descriptions are included in these checklists.
|
|
120
|
+
|
|
121
|
+
For the 274-member HealthcareServiceLocation expansion:
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
python3 scripts/import-fhir-terminology.py \
|
|
125
|
+
--input /private/path/healthcare-location.json \
|
|
126
|
+
--expected profiles/terminology-location-checklist.json \
|
|
127
|
+
--systems profiles/terminology-location-systems.json \
|
|
128
|
+
--output terminology
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The two import commands preserve other installed expansions. The public-source preparation command uses the pinned source hashes; if a live grammar registry has changed and the pinned edition is unavailable, it stops rather than silently accepting newer bytes. Use a verified copy of that pinned edition or review and update the lock. After assembling the pack, mount it read-only, run `doctor`, and inspect each profile's missing-data inventory. A 29-snapshot count does not by itself prove matching membership or complete validation coverage.
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
## Licensing and source selection
|
|
136
|
+
|
|
137
|
+
The application’s MIT license does not license terminology data. A user’s CPT license does not automatically grant this project distribution rights. Giving the application away or adding a notice does not replace the required agreement. AMA’s [licensing guidance](https://www.ama-assn.org/practice-management/cpt/cpt-licensing-frequently-asked-questions-faqs) also covers CPT-dependent products, so user-supplied data is not a blanket licensing exemption for the application. No CPT distribution agreement has been established for this project.
|
|
138
|
+
|
|
139
|
+
[LOINC permits redistribution under conditions](https://loinc.org/kb/license), including notices and applicable third-party terms; it does not require every user to download their own copy. We support operator-supplied LOINC alongside other sources. The local UMLS 2026AB metadata identifies LOINC 2.83; the standalone [LOINC Complete distribution](https://loinc.org/downloads/) contains additional tables useful for producing reviewed expansions. This importer accepts complete FHIR expansions, rather than treating an entire source download as an already resolved value set.
|
|
140
|
+
|
|
141
|
+
Use authorized VSAC exports, source-system distributions, or complete FHIR expansions from an appropriately configured terminology service. Resolve licensing for the intended deployment. The software does not accept terms, create accounts or store terminology credentials. Never send clinical XML to obtain an expansion.
|
|
142
|
+
|
|
143
|
+
## Checks and data readiness
|
|
144
|
+
|
|
145
|
+
`GET /v1/profiles` exposes:
|
|
146
|
+
|
|
147
|
+
- `supplementalChecks`: person-name, procedure timestamp, procedure-membership and location-union checks, with coverage guards for unavailable data.
|
|
148
|
+
- `supplementalBindingChecks`: installed checks at the exact locations in the checksum-verified HL7 binding catalog. Required bindings produce errors; preferred and extensible bindings preserve the upstream warning severity.
|
|
149
|
+
- `terminologySetup`: exact missing and installed value-set canonicals, a data-readiness flag and the setup guide URL. Readiness is separate from full validation coverage.
|
|
150
|
+
- `terminologySnapshots` and `grammarDefinitions`: pinned editions, counts and hashes. Unknown or unimplemented canonicals remain inactive.
|
|
151
|
+
|
|
152
|
+
Code/system pairs use exact membership. Bindings on primitive code attributes use exact code membership. Each supplemental binding has a stable ID derived from its canonical, context and strength, and runs in a separate pattern so overlapping contexts cannot suppress another binding. The original HL7 assets and generation report remain unchanged except for the explicitly marked **public-image derivative** of the legacy vocabulary inventory.
|
|
153
|
+
|
|
154
|
+
All six supplements are installed even when datasets are absent. A known member of any location set satisfies the union; an unresolved union produces an explicit coverage finding. Date checks compare calendar fields and offsets; insufficient precision or timezone information produces an explicit coverage finding even when advisory warnings are hidden. It is never silently treated as a pass.
|
|
155
|
+
|
|
156
|
+
The historical generation report remains unchanged. Reviewed replacement checks are reported separately in `effectiveCoverage`; document completion also requires all applicable data and determinate checks. It does not assert full FHIR model conformance.
|
|
157
|
+
|
|
158
|
+
## Prepare SVS data
|
|
159
|
+
|
|
160
|
+
Prepare assets and export complete XML from an authorized [VSAC session](https://vsac.nlm.nih.gov/). Review counts and source editions. A retired set can still be referenced by a pinned guide: review that choice explicitly; its status remains visible in metadata.
|
|
19
161
|
|
|
20
162
|
```json
|
|
21
163
|
[
|
|
@@ -23,53 +165,152 @@ The person-name supplement separately reapplies the pinned patient-name constrai
|
|
|
23
165
|
]
|
|
24
166
|
```
|
|
25
167
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
3. Import the checked exports after preparing the standard assets:
|
|
168
|
+
The number above records one previously reviewed export, not a permanent count for future releases. Import your reviewed checklist:
|
|
29
169
|
|
|
30
170
|
```sh
|
|
31
171
|
npm run assets
|
|
32
172
|
python3 scripts/import-svs.py \
|
|
33
173
|
--input-glob '/private/path/RetrieveMultipleValueSets*.xml' \
|
|
34
174
|
--expected /private/path/expected-counts.json \
|
|
35
|
-
--output
|
|
175
|
+
--output terminology
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The SVS command imports the complete reviewed input collection and preserves other installed expansions and grammar configuration. Conflicting replacements require `--replace` after edition review. It rejects empty, duplicate, conflicting, partial, entity-bearing and count-mismatched exports. DTD rejection is performed by the XML parser and covers UTF-16. A failed import leaves the active manifest unchanged.
|
|
179
|
+
|
|
180
|
+
## Add complete FHIR expansions
|
|
181
|
+
|
|
182
|
+
Use `scripts/import-fhir-terminology.py` for other canonicals, including locally resolved US Core or source-specific expansions. Supply a reviewed checklist with the **ValueSet definition version** and complete count:
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
[
|
|
186
|
+
{ "canonical": "https://example.org/ValueSet/example", "version": "reviewed-edition", "expectedCount": 42 }
|
|
187
|
+
]
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Supply a separate reviewed map of FHIR system URIs to CDA OIDs. For example, LOINC’s URI is `http://loinc.org` and its CDA OID is `2.16.840.1.113883.6.1`. The tool never guesses an OID from a similar value-set identifier.
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
python3 scripts/import-fhir-terminology.py \
|
|
194
|
+
--input /private/path/complete-expansion.json \
|
|
195
|
+
--expected /private/path/reviewed-expansions.json \
|
|
196
|
+
--systems /private/path/system-oids.json \
|
|
197
|
+
--output terminology
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The importer requires `expansion.total` to match both the reviewed count and all imported unique pairs, offset zero, an exact definition version and explicit system mappings. Limited, abstract, duplicate, incomplete or conflicting data is rejected. Updates that replace an existing expansion require `--replace` after reviewing the new edition. Other installed entries and grammar configuration are preserved. Filenames are content-addressed and the manifest is replaced atomically.
|
|
201
|
+
|
|
202
|
+
Both importers operate offline. Counts and hashes detect corruption and incomplete imports; they do not independently prove source authenticity, correct licensing or semantic equivalence to another edition.
|
|
203
|
+
|
|
204
|
+
## Import LOINC document types
|
|
205
|
+
|
|
206
|
+
Download **LOINC Complete 2.83** from [LOINC](https://loinc.org/downloads/) using your own account and review its license. Then run:
|
|
207
|
+
|
|
208
|
+
```sh
|
|
209
|
+
python3 scripts/import-loinc.py --input /private/path/Loinc_2.83.zip --output terminology
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The importer accepts only the archive edition and SHA-256 pinned in `profiles/terminology-sources.lock.json`. It reads ZIP members without extracting them, selects all `SCALE_TYP=Doc` codes, and requires exact agreement with the primary `LP32888-7` SCALE part links. The reviewed release contains 112,405 table rows and 12,569 document-scale codes. The US Core 9.0.0 definition adds NullFlavor `UNK`, producing 12,570 exact membership pairs. No status filter is added. The normalized index contains identifiers only; the original archive stays local. New editions require source and count review before changing the lock. Existing datasets are preserved; conflicting replacements require `--replace`.
|
|
213
|
+
|
|
214
|
+
## Install UCUM and language grammars
|
|
215
|
+
|
|
216
|
+
Finite lists cannot cover all UCUM expressions or BCP 47 language tags. Download the [UCUM essence definition](https://github.com/FHIR/Ucum-java/blob/master/src/main/resources/ucum-essence.xml), the [IANA language-subtag registry](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) and the [IANA language extension registry](https://www.iana.org/assignments/language-tag-extensions-registry/language-tag-extensions-registry). Review their editions and SHA-256 hashes. Put the files in the terminology folder and add a `grammars` object to its manifest:
|
|
217
|
+
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"schemaVersion": 1,
|
|
221
|
+
"valueSets": [],
|
|
222
|
+
"grammars": {
|
|
223
|
+
"ucum": {
|
|
224
|
+
"file": "ucum-essence.xml",
|
|
225
|
+
"sha256": "REVIEWED_SHA256",
|
|
226
|
+
"version": "REVIEWED_UCUM_EDITION"
|
|
227
|
+
},
|
|
228
|
+
"language": {
|
|
229
|
+
"file": "language-subtag-registry.txt",
|
|
230
|
+
"sha256": "REVIEWED_SHA256",
|
|
231
|
+
"version": "REVIEWED_IANA_FILE_DATE",
|
|
232
|
+
"extensionsFile": "language-tag-extensions-registry.txt",
|
|
233
|
+
"extensionsSha256": "REVIEWED_SHA256"
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Preserve existing `valueSets` when editing the manifest. UCUM uses `org.fhir:ucum:1.0.10`; XML DTDs are prohibited before definition parsing. Language checks use strict BCP 47 syntax, the installed registered subtags, grandfathered/redundant tags, private-use ranges, extlang prefixes and registered extension singletons. Registered extension singletons do not prove the semantic validity of extension keys/types; tags containing such extensions produce indeterminate coverage. Private-use tags remain supported. Finite snapshots for these canonicals remain inactive and cannot satisfy grammar readiness.
|
|
240
|
+
|
|
241
|
+
## Install the authorized C-CDA 2.1 vocabulary
|
|
242
|
+
|
|
243
|
+
Obtain the pinned upstream `voc.xml` under terms covering your use. The installation tool verifies its expected SHA-256 from the application asset manifest and copies it to the operator folder. It does not grant or verify a license.
|
|
244
|
+
|
|
245
|
+
```sh
|
|
246
|
+
mkdir -p terminology
|
|
247
|
+
docker run --rm --entrypoint java \
|
|
248
|
+
--user "$(id -u):$(id -g)" \
|
|
249
|
+
-v "$PWD/terminology:/app/terminology" \
|
|
250
|
+
-v "/private/path/voc.xml:/input/voc.xml:ro" \
|
|
251
|
+
IMAGE -cp /app/app.jar org.cdavalidator.TerminologyTool \
|
|
252
|
+
install-legacy /input/voc.xml
|
|
36
253
|
```
|
|
37
254
|
|
|
38
|
-
|
|
255
|
+
Replace `IMAGE` with your selected application image. The folder may contain both this vocabulary and the C-CDA 5.0 pack. Incorrect editions and altered files are rejected. No schema or Schematron rules can be uploaded through these commands.
|
|
39
256
|
|
|
40
|
-
|
|
257
|
+
## Mount, diagnose and run
|
|
41
258
|
|
|
42
|
-
|
|
259
|
+
```sh
|
|
260
|
+
docker run --rm --entrypoint java \
|
|
261
|
+
-v "$PWD/terminology:/app/terminology:ro" \
|
|
262
|
+
IMAGE -cp /app/app.jar org.cdavalidator.TerminologyTool doctor
|
|
263
|
+
```
|
|
43
264
|
|
|
44
|
-
|
|
265
|
+
The doctor exits with code 2 while datasets are missing. A ready dataset inventory does not imply full profile conformance coverage. To start the service:
|
|
45
266
|
|
|
46
267
|
```sh
|
|
47
|
-
docker build -t cda-validator:coverage-review .
|
|
48
268
|
docker run -d --name cda-validator-coverage \
|
|
49
269
|
--memory=1536m --cpus=2 --pids-limit=128 \
|
|
50
270
|
--read-only --tmpfs /tmp:size=64m,noexec,nosuid \
|
|
51
271
|
--cap-drop=ALL --security-opt=no-new-privileges \
|
|
52
272
|
-e JAVA_TOOL_OPTIONS=-Xmx1g \
|
|
53
|
-
-p 127.0.0.1:
|
|
54
|
-
--mount "type=bind,source=$PWD/
|
|
55
|
-
|
|
273
|
+
-p 127.0.0.1:17645:17643 \
|
|
274
|
+
--mount "type=bind,source=$PWD/terminology,target=/app/terminology,readonly" \
|
|
275
|
+
IMAGE
|
|
56
276
|
```
|
|
57
277
|
|
|
58
|
-
|
|
278
|
+
Compose uses `${CDA_TERMINOLOGY_DIR:-./terminology}`. For a local JVM, set `TERMINOLOGY_DIR` to the operator directory. Restart to load changed data; the running engine uses immutable verified indexes. Existing applications on other ports remain untouched.
|
|
279
|
+
|
|
280
|
+
Paths must stay inside the operator folder. Snapshot files are bounded to 64 MiB and 1,250,000 total entries; each grammar file is bounded to 5 MiB and the legacy vocabulary to 150 MiB. Startup verifies checksums and counts. Raw exports, normalized indexes and local vocabularies are excluded from Git and the public build context.
|
|
59
281
|
|
|
60
|
-
|
|
282
|
+
For memory regression with an operator pack:
|
|
61
283
|
|
|
62
284
|
```sh
|
|
63
285
|
python3 scripts/check-upload-memory.py \
|
|
64
|
-
--image cda-validator:coverage-
|
|
65
|
-
--
|
|
66
|
-
--output .cache/upload-memory
|
|
286
|
+
--image cda-validator:coverage-followup \
|
|
287
|
+
--terminology-dir service/assets/terminology \
|
|
288
|
+
--output .cache/coverage-upload-memory.json
|
|
67
289
|
```
|
|
68
290
|
|
|
69
|
-
##
|
|
291
|
+
## Prepare US Core condition and procedure sets from UMLS
|
|
292
|
+
|
|
293
|
+
Download the licensed **UMLS 2026AB full archive** through your own UMLS access and **LOINC Complete 2.83** through LOINC. No credentials or license agreements are handled by the importer.
|
|
294
|
+
|
|
295
|
+
```sh
|
|
296
|
+
python3 scripts/import-umls.py \
|
|
297
|
+
--input /private/path/umls-2026AB-full.zip \
|
|
298
|
+
--loinc /private/path/Loinc_2.83.zip \
|
|
299
|
+
--output terminology
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
The archive, recipe and source-row counts are pinned in `profiles/umls-sources.lock.json`. Allow approximately 2.4 GB temporary disk space for the nested metadata archive; it is removed after import. The importer rejoins arbitrary gzip fragments before decoding complete RRF records. It derives SNOMED descendants from source-asserted MRHIER AUI paths and SCUI identifiers, never from shared UMLS CUIs. Before updating a pack it requires exact agreement with an installed independent Procedure snapshot, when present. No imported codes are distributed with the software.
|
|
303
|
+
|
|
304
|
+
The recipe includes full LOINC table identifiers, appropriate CPT/CDT/HCPCS clinical identifiers, ICD-10-CM/PCS and ICD-9-CM diagnosis/procedure identifiers with the authoritative CDA system OIDs. It excludes source headings, ranges and partial axes. Standalone CPT/HCPCS modifiers and unsupported SNOMED expressions are explicitly indeterminate. The recipe records exact source editions: SNOMED US September 2026, CPT 2026, **CDT 2025**, HCPCS 2026, ICD-10-CM/PCS 2027, ICD-9-CM 2014 and LOINC 2.83. These are the reviewed archive's editions; a new edition requires review rather than relabeling old data.
|
|
305
|
+
|
|
306
|
+
The two US Core 9.0.0 definitions yield **262,583 condition** and **274,743 procedure** membership pairs. The SNOMED Procedure subset has 62,110 pairs and exactly matches the independently obtained VSAC expansion. These counts are for this pinned recipe, not promises about future editions.
|
|
307
|
+
|
|
308
|
+
## Remaining dataset and coverage boundaries
|
|
309
|
+
|
|
310
|
+
The verified local pack contains **29 snapshots / 1,013,055 membership entries**, with 28 active indexes and two grammars. The one absent canonical is NUBC patient discharge disposition. No NUBC source was present in UMLS. Operators who need this check must supply an authorized, complete versioned expansion using the FHIR importer; no scraped discharge-status list is bundled. Until installed, any applicable binding yields incomplete coverage even when warnings are hidden.
|
|
70
311
|
|
|
71
|
-
|
|
312
|
+
`codeSystemEditions` records supported aliases. An explicit document `codeSystemVersion` that does not match the installed reviewed edition produces coverage findings rather than silently using a different edition. Absent version attributes use the disclosed installed edition. This does not guarantee that every other historical edition or code expression is supported.
|
|
72
313
|
|
|
73
|
-
|
|
314
|
+
CPT/ADA CDT and other source permissions still apply. Operator-supplied data is not a blanket exemption from product licensing; see the linked licensing guidance above. The codebase, npm archive and image omit raw and normalized operator data.
|
|
74
315
|
|
|
75
|
-
|
|
316
|
+
Targeted offline reference checks are described in [coverage evidence](coverage.md#independent-checks). Full FHIR StructureDefinition and clinical conformance are outside this service's stated validation scope.
|
package/lib/getIgnored.js
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
function getIgnored(assertionObject, assertionInfo, resultInfo) {
|
|
10
|
-
const { type, assertionId, test, simplifiedTest, description
|
|
10
|
+
const { type, assertionId, test, simplifiedTest, description } = assertionObject;
|
|
11
|
+
const errorMessage = assertionObject.results.errorMessage || assertionObject.errorMessage;
|
|
11
12
|
const { patternId, ruleId, context } = assertionInfo;
|
|
12
13
|
const { ignored } = resultInfo;
|
|
13
14
|
const obj = {
|
package/lib/getSchematronMap.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const parseXml = require('./parseXml');
|
|
2
2
|
const crypto = require('crypto');
|
|
3
3
|
const parseSchematron = require('./parseSchematron');
|
|
4
4
|
/**
|
|
@@ -22,7 +22,7 @@ function getSchematronMap(schematron, options = {}) {
|
|
|
22
22
|
}
|
|
23
23
|
// If not in cache
|
|
24
24
|
// Load schematron doc
|
|
25
|
-
const schematronDoc =
|
|
25
|
+
const schematronDoc = parseXml(schematron, 'Schematron XML');
|
|
26
26
|
// Parse schematron
|
|
27
27
|
if (Object.keys(options.parsedMap).length >= 32) {
|
|
28
28
|
delete options.parsedMap[Object.keys(options.parsedMap)[0]];
|
|
@@ -4,7 +4,7 @@ module.exports = modifyTest;
|
|
|
4
4
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const xpath = require('xpath');
|
|
7
|
-
const
|
|
7
|
+
const parseXml = require('./parseXml');
|
|
8
8
|
const path = require('path');
|
|
9
9
|
|
|
10
10
|
const loadedExternalDocuments = Object.create(null);
|
|
@@ -60,7 +60,7 @@ function modifyTest(test, resourceDir) {
|
|
|
60
60
|
catch (err) {
|
|
61
61
|
throw new Error('No such file \'' + filepath + '\'');
|
|
62
62
|
}
|
|
63
|
-
externalDoc =
|
|
63
|
+
externalDoc = parseXml(externalXml, 'external resource XML');
|
|
64
64
|
if (Object.keys(loadedExternalDocuments).length >= 32) {
|
|
65
65
|
delete loadedExternalDocuments[Object.keys(loadedExternalDocuments)[0]];
|
|
66
66
|
}
|
package/lib/initializeProcess.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const xpath = require('xpath');
|
|
2
|
-
const
|
|
2
|
+
const parseXml = require('./parseXml');
|
|
3
3
|
const checkIfFileOrPath = require('./checkIfFileOrPath');
|
|
4
4
|
const getSchematronMap = require('./getSchematronMap');
|
|
5
5
|
/**
|
|
@@ -16,7 +16,7 @@ function initializeProcess(xml, schematron, options) {
|
|
|
16
16
|
xml = checkIfFileOrPath(xml);
|
|
17
17
|
if (!options.parsedSchematronMap) schematron = checkIfFileOrPath(schematron);
|
|
18
18
|
// Load xml doc
|
|
19
|
-
options.xmlDoc =
|
|
19
|
+
options.xmlDoc = parseXml(xml, 'XML document');
|
|
20
20
|
// Allowing users to send a parsed schematron map if testing multiple xml files with the same schematron
|
|
21
21
|
options.schematronMap = getSchematronMap(schematron, options);
|
|
22
22
|
// Extract data from parsed schematron object
|
package/lib/parseXml.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { SaxesParser } = require('saxes');
|
|
4
|
+
const { DOMParser } = require('@xmldom/xmldom');
|
|
5
|
+
|
|
6
|
+
// xmldom can repair malformed input and only print a warning. Check the source
|
|
7
|
+
// before building the DOM so recovered documents cannot look like a clean pass.
|
|
8
|
+
module.exports = function parseXml(xml, label) {
|
|
9
|
+
try {
|
|
10
|
+
const parser = new SaxesParser({ xmlns: true });
|
|
11
|
+
parser.on('doctype', () => { throw new Error('DOCTYPE declarations are not supported'); });
|
|
12
|
+
parser.write(xml).close();
|
|
13
|
+
const fail = (message) => { throw new Error(message); };
|
|
14
|
+
return new DOMParser({ locator: {}, errorHandler: { warning: fail, error: fail, fatalError: fail } })
|
|
15
|
+
.parseFromString(xml, 'application/xml');
|
|
16
|
+
} catch (cause) {
|
|
17
|
+
throw new SyntaxError('Invalid ' + label + ': ' + cause.message, { cause });
|
|
18
|
+
}
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cda-schematron-validator",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Self-hosted CDA validation API and UI with pinned HL7 profiles, detailed findings, and a compatible legacy Schematron API.",
|
|
5
5
|
"main": "validator.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"homepage": "https://github.com/priyaranjan-tokachichu/cda-schematron-validator#readme",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@xmldom/xmldom": "0.8.15",
|
|
37
|
+
"saxes": "6.0.0",
|
|
37
38
|
"xpath": "0.0.36"
|
|
38
39
|
},
|
|
39
40
|
"directories": {
|
package/validator.d.ts
CHANGED
|
@@ -47,6 +47,10 @@ export interface Profile {
|
|
|
47
47
|
artifactChecksums: Record<string, string>;
|
|
48
48
|
generationCoverage?: Record<string, number>;
|
|
49
49
|
generationReport?: Record<string, unknown>;
|
|
50
|
+
effectiveCoverage?: {knownGeneratorGapsAddressed: boolean; unresolvedGeneratorEntries: string[]; scope: string; documentPolicy: string; carePlanReview: string; reviewedReplacements: string[]};
|
|
51
|
+
terminologySetup?: {ready: boolean; missingValueSets?: string[]; missingDatasets?: string[]; installedValueSets?: string[]; setupGuide: string; distribution?: string};
|
|
52
|
+
supplementalBindingChecks?: number;
|
|
53
|
+
carePlanBaseChecks?: {assertions: number; modelSha256: string; scope: string; sourceFiles: Record<string,string>};
|
|
50
54
|
terminologySnapshots?: Array<Record<string, unknown>>;
|
|
51
55
|
supplementalChecks?: Array<{ ruleId: string; method: string; scope: string }>;
|
|
52
56
|
}
|
|
@@ -68,6 +72,7 @@ export interface ValidationReport {
|
|
|
68
72
|
requestId: string;
|
|
69
73
|
status: 'valid' | 'invalid' | 'incomplete';
|
|
70
74
|
validationComplete: boolean;
|
|
75
|
+
validationScope?: string;
|
|
71
76
|
executionComplete: boolean;
|
|
72
77
|
truncated: boolean;
|
|
73
78
|
options: {includeWarnings: boolean};
|
|
@@ -84,6 +89,6 @@ export interface ValidationReport {
|
|
|
84
89
|
export interface Client {
|
|
85
90
|
validate(xml: string, options?: {profile?: string; includeWarnings?: boolean}): Promise<ValidationReport>;
|
|
86
91
|
profiles(): Promise<{profiles: Profile[]; sources: ValidationReport['sources']; limits?: {maxXmlBytes: number; maxRequestBytes: number; uploadMemoryBudgetBytes: number; maxConcurrentUploads: number; requestCapacity: number; uploadQueueWaitSeconds: number}}>;
|
|
87
|
-
version(): Promise<{version: string; engine: string}>;
|
|
92
|
+
version(): Promise<{version: string; engine: string; javaVersion?: string; javaRuntimeVersion?: string; javaVendor?: string}>;
|
|
88
93
|
}
|
|
89
94
|
export function createClient(options?: {baseUrl?: string; token?: string; timeoutMs?: number}): Client;
|