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 error-resolution flow: triage, defer/loinc/resolve wrappers, auto LOINC candidates, ready-to-run swap suggestion
- triage.sh: batch-classify active errors into suggested actions (auto-swap / fhir-422 / sender-missing / loinc-lookup / parsing-defer / aidbox-reject).
- defer.sh / loinc-search.sh / resolve-mapping.sh: wrap the curl + jq boilerplate previously inlined in the skill docs.
- inspect-error.sh: for per-1 constraint, emit ready-to-run wire-preprocessor.ts command; for observation-code-loinc tasks, auto-run ValueSet/\$expand on each localDisplay so the picker has LOINC candidates without another call.
- Skill docs updated to point at the new scripts.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: .claude/skills/check-errors/SKILL.md
+22-17Lines changed: 22 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,14 @@ Emits a markdown table of active errors plus a deferred-count reminder. If outpu
17
17
18
18
If the user asked specifically about deferred messages, use `scripts/errors/list-errors.sh --deferred`.
19
19
20
+
For a classified action plan across all active errors (recommended when there are ≥3):
21
+
22
+
```sh
23
+
scripts/errors/triage.sh
24
+
```
25
+
26
+
Prints each error with a suggested class (auto-swap / fhir-422 / sender-missing / loinc-lookup / parsing-defer / aidbox-reject / other) and next command. Read-only — user still approves each fix.
27
+
20
28
Ask: **"Which error would you like me to investigate?"** Skip `deferred` rows unless the user explicitly asks.
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
37
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.
38
+
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 `per-1` (reversed period) it also emits a **ready-to-run**`wire-preprocessor.ts` command — just copy/run it. For `code_mapping_error` with any `observation-code-loinc` task, peer OBX rows are dumped automatically AND LOINC candidates are fetched via ValueSet/$expand on each localDisplay — you usually have everything needed to pick the right LOINC without another call.
31
39
32
40
Pick the playbook below by the `Status` line from Step 2.
33
41
@@ -38,7 +46,7 @@ Pick the playbook below by the `Status` line from Step 2.
38
46
1. From the inspect overview, identify what's wrong: missing MSH, invalid encoding chars (MSH-1/2), truncated segments, wrong line endings, embedded binary.
39
47
2.**No code/config fix.** Sender must correct the message format. Defer = resolved on our side — do it:
40
48
```sh
41
-
curl -sf -X POST 'http://localhost:3000/defer/<id>'
49
+
scripts/errors/defer.sh <id>
42
50
```
43
51
3. Only mark for retry if the sender has already fixed and will resend with the same ID.
44
52
@@ -63,7 +71,7 @@ Do **not** run `hl7v2-inspect --values` unless the mapping is ambiguous. Diagnos
63
71
2. Suggest fixes in this order:
64
72
- Best: sender populates the missing field — explain what's needed; defer = park it out of active queue pending sender action:
65
73
```sh
66
-
curl -sf -X POST 'http://localhost:3000/defer/<id>'
74
+
scripts/errors/defer.sh <id>
67
75
```
68
76
- Workaround: add a preprocessor in`src/v2-to-fhir/preprocessor-registry.ts` + `config/hl7v2-to-fhir.json`
69
77
- Last resort: relax config (make a segment optional) — warn about the tradeoff
@@ -92,28 +100,21 @@ If a **new** preprocessor function is needed, write it manually first:
92
100
93
101
Inspect output lists each unmapped code with `localCode`, `localDisplay`, `localSystem`, `mappingType`, and `taskId`. Use the printed `taskId`for the resolve call.
94
102
95
-
1. For `observation-code-loinc`, search LOINC via Aidbox's ValueSet/$expand (the `/api/terminology/*` path does not exist):
103
+
1. For `observation-code-loinc`, `inspect-error.sh` already dumps LOINC candidates via ValueSet/$expand. For an ad-hoc search:
If the LOINC package is not loaded locally, `.expansion.contains` will be empty — fall back to domain knowledge and cite the LOINC concept by name (e.g. peer OBX codes in the same message, unit of measure, and specimen type).
107
+
If no matches, the LOINC package isn't loaded — fall back to domain knowledge and cite the LOINC concept by name (e.g. peer OBX codes in the same message, unit of measure, and specimen type).
103
108
2. For `patient-class`, `obr-status`, `obx-status`, etc.: look up valid target values in `src/code-mapping/mapping-types.ts`.
104
109
3. Present suggestions with confidence: "High: `2823-3` → LOINC `2823-3` (Potassium)" vs "Needs review: `GLU` → `2345-7` (Glucose) — verify with lab".
105
110
4. If ambiguous / needs domain expertise → defer = park it out of active queue pending sender action:
106
111
```sh
107
-
curl -sf -X POST 'http://localhost:3000/defer/<id>'
112
+
scripts/errors/defer.sh <id>
108
113
```
109
-
5. After approval, resolve via the app API. Endpoint expects **form-urlencoded** body with `resolvedCode` and `resolvedDisplay` (not JSON). A `302` redirect to `/unmapped-codes?saved=...&replayed=N` signals success:
114
+
5. After approval, resolve via the app API. Message is auto-requeued.
110
115
```sh
111
-
curl -s -X POST 'http://localhost:3000/api/mapping/tasks/<taskId>/resolve' \
echo"- Constraint \`per-1\`: period start must be <= end. Likely: sender reversed start/end fields. Candidate fix: \`swap-if-reversed\` preprocessor with params \`{ a, b }\` pointing at the two date fields."
104
+
SUGGEST_SWAP=1
104
105
;;
105
106
ref-1)
106
107
echo"- Constraint \`ref-1\`: SHALL have a contained resource or a reference (not both / need one). Likely: empty or dangling reference target."
0 commit comments