You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Speed up check-errors workflow: status/verify-retry/list-preprocessors/wire-preprocessor scripts, richer inspect-error
New scripts under scripts/errors/:
- status.sh: concise {id,status,type,error,sender} for a message.
- verify-retry.sh: chains check-message-support -> mark-for-retry -> reprocess -> status; aborts when verdict is not "supported".
- list-preprocessors.sh: lists registered preprocessor IDs with their JSDoc summary.
- wire-preprocessor.ts: idempotent scaffold that ensures the MessageTypeConfig.preprocess slot in src/v2-to-fhir/config.ts and appends the entry to config/hl7v2-to-fhir.json.
inspect-error.sh:
- For HTTP 422 conversion errors, also prints the current HL7v2 value of every candidate field so the fix is obvious without another --values call.
- For code_mapping_error with any observation-code-loinc task, dumps peer OBX rows (code, value, unit, reference range) to help pick the right LOINC from neighbors.
check-errors SKILL.md: points at the new scripts, collapses the post-fix step to a single command, and adds a script-reference table.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Emits: status, type, sender, full error, unmapped codes (if present), raw HL7v2 saved to `/tmp/hl7v2-<id>.hl7`, and an `hl7v2-inspect` overview for `parsing_error`/`conversion_error`. **You do not need to curl the resource yourself.**
29
29
30
+
For `HTTP 422` conversion errors the script also prints the **current values** of each candidate HL7v2 field, so you typically don't need an additional `hl7v2-inspect --field` call. For `code_mapping_error` with any `observation-code-loinc` task, peer OBX rows are dumped automatically — use them (code, unit, ref range) to pick the right LOINC.
31
+
30
32
Pick the playbook below by the `Status` line from Step 2.
31
33
32
34
## Step 3: Diagnose by status
@@ -70,11 +72,21 @@ Do **not** run `hl7v2-inspect --values` unless the mapping is ambiguous. Diagnos
70
72
71
73
#### Adding a preprocessor (recipe)
72
74
73
-
Three files, in order:
75
+
If the preprocessor **already exists** (check `scripts/errors/list-preprocessors.sh`), wire it in with one command — edits both config files atomically:
76
+
77
+
```sh
78
+
bun scripts/errors/wire-preprocessor.ts <msgType><SEG><FIELD><preprocessorId> [paramsJson]
79
+
80
+
# Example:
81
+
bun scripts/errors/wire-preprocessor.ts ADT-A01 IN1 12 swap-if-reversed '{"a":12,"b":13}'
82
+
```
83
+
84
+
Idempotent — re-running with the same args is a no-op. The script adds the missing slot to `MessageTypeConfig.preprocess.<SEG>`in`src/v2-to-fhir/config.ts` and the JSON entry under the matching message type.
85
+
86
+
If a **new** preprocessor functionis needed, write it manually first:
74
87
75
88
1. **`src/v2-to-fhir/preprocessor-registry.ts`** — add key + functionto`SEGMENT_PREPROCESSORS`. Function receives the whole segment; the field key in config is only a trigger guard (preprocessor runs when that field is present, except `fallback-rxa3-from-msh7` which runs even when absent).
76
-
2. **`src/v2-to-fhir/config.ts`** — add the field slot to `MessageTypeConfig.preprocess.<SEG>` (e.g. `IN1?: { "12"?: SegmentPreprocessorId[] }`).
77
-
3. **`config/hl7v2-to-fhir.json`** — add the entry under the relevant message type. Use the `Read` tool for this file — `bun -e` and `python3` fail on JSONC comments.
89
+
2. Then run `wire-preprocessor.ts` to wire it in.
78
90
79
91
### `code_mapping_error` — local code has no FHIR mapping
80
92
@@ -115,25 +127,22 @@ Inspect output lists each unmapped code with `localCode`, `localDisplay`, `local
115
127
116
128
## Step 4: After a fix
117
129
118
-
1. Verify locally:
119
-
```sh
120
-
bun scripts/check-message-support.ts /tmp/hl7v2-<id>.hl7
121
-
```
122
-
Only proceed when verdict is `supported` or `supported with caveats`.
123
-
2. Mark for retry (app endpoint, not Aidbox):
124
-
```sh
125
-
curl -sf -X POST 'http://localhost:3000/mark-for-retry/<id>'
126
-
```
127
-
3. Trigger reprocessing:
128
-
```sh
129
-
curl -sf -X POST 'http://localhost:3000/process-incoming-messages'
0 commit comments