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
Inspect output used wrong unmappedCodes field names (code/system/display);
derive real fields plus mappingType from embedded Task and surface taskId.
Skill's resolve curl used JSON body with code/display; endpoint expects
form-urlencoded resolvedCode/resolvedDisplay. LOINC lookup endpoint
/api/terminology/loinc does not exist; use ValueSet/$expand. CLAUDE.md:
loosen test:local to before-commit (not after-every-change) and promote
inspection scripts over raw file reads.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2. Look up the V2-to-FHIR IG mapping CSV in `specs/v2-to-fhir/mappings/segments/` → identify the HL7v2 source segment/field (e.g. `Coverage.period.start` ← IN1-12, `.end` ← IN1-13).
59
+
3. State the fix directly from the constraint + field identity. Only run `hl7v2-inspect --values` when multiple HL7v2 fields feed the same FHIR field and the specific trigger is unclear.
60
+
49
61
2. Suggest fixes in this order:
50
-
- Best: sender populates the missing field — explain what's needed
62
+
- Best: sender populates the missing field — explain what's needed; defer = park it out of active queue pending sender action:
63
+
```sh
64
+
curl -sf -X POST 'http://localhost:3000/defer/<id>'
65
+
```
51
66
- Workaround: add a preprocessor in`src/v2-to-fhir/preprocessor-registry.ts` + `config/hl7v2-to-fhir.json`
52
67
- Last resort: relax config (make a segment optional) — warn about the tradeoff
53
-
3. If no clear fix (needs sender coordination, client decision, spec clarification) → offer to defer.
68
+
3. If no clear fix (needs client decision, spec clarification) → defer as resolution (same command above).
54
69
4. **Wait for approval before implementing.** Then verify with `bun scripts/check-message-support.ts /tmp/hl7v2-<id>.hl7` before retrying.
55
70
71
+
#### Adding a preprocessor (recipe)
72
+
73
+
Three files, in order:
74
+
75
+
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.
78
+
56
79
### `code_mapping_error` — local code has no FHIR mapping
57
80
58
-
Inspect output lists each unmapped code with `mappingType`.
81
+
Inspect output lists each unmapped code with `localCode`, `localDisplay`, `localSystem`, `mappingType`, and `taskId`. Use the printed `taskId`for the resolve call.
59
82
60
-
1. For `observation-code-loinc`, search LOINC by display text:
83
+
1. For `observation-code-loinc`, search LOINC via Aidbox's ValueSet/$expand (the `/api/terminology/*` path does not exist):
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).
65
91
2. For `patient-class`, `obr-status`, `obx-status`, etc.: look up valid target values in `src/code-mapping/mapping-types.ts`.
66
92
3. Present suggestions with confidence: "High: `2823-3` → LOINC `2823-3` (Potassium)" vs "Needs review: `GLU` → `2345-7` (Glucose) — verify with lab".
67
-
4. If ambiguous / needs domain expertise → offer to defer.
68
-
5. After approval, resolve via the app API:
93
+
4. If ambiguous / needs domain expertise → defer = park it out of active queue pending sender action:
94
+
```sh
95
+
curl -sf -X POST 'http://localhost:3000/defer/<id>'
96
+
```
97
+
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:
69
98
```sh
70
-
curl -sf -X POST 'http://localhost:3000/api/mapping/tasks/<taskId>/resolve' \
Copy file name to clipboardExpand all lines: CLAUDE.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ Use `bun`/`bun install`/`bun run` instead of `node`/`npm`/`yarn`/`pnpm`. Unit te
31
31
32
32
## Testing rules
33
33
34
-
1.**Run `bun test:local` after any change.** Unit tests + the smoke subset of integration tests (~10s). CI runs the full `bun test:all`; don't also run it locally unless debugging a CI-only failure.
34
+
1.**Run `bun test:local`only before committing** — not after every change. Use `bun scripts/check-message-support.ts` or targeted `bun test <file>` to verify a specific fix. CI runs the full `bun test:all`; don't also run it locally unless debugging a CI-only failure.
35
35
2.**Smoke tests are tagged by name prefix.** A test (or `describe`) whose name starts with `smoke: ` is included in `test:smoke` via `--test-name-pattern "smoke: "`. Promote by prepending the prefix; demote by removing it. Keep the smoke set small and focused on one happy-path per major flow.
36
36
3.**Don't manually run `docker compose` for integration tests.** The test commands auto-start containers, wait for health, and run migrations. Integration tests use a separate test Aidbox on port 8888 via `docker-compose.test.yaml`.
37
37
@@ -51,6 +51,8 @@ If `profileConformance.implementationGuides` enables US Core (`hl7.fhir.us.core`
51
51
52
52
IMPORTANT: Read `.claude/code-style.md` before writing or modifying code.
53
53
54
+
**Prefer scripts over raw file reads:** Use project scripts for inspection and diagnosis — `scripts/errors/inspect-error.sh`, `scripts/hl7v2-inspect.sh`, `bun scripts/check-message-support.ts`, `bun scripts/hl7v2-ref-lookup.ts` — before reaching for `Read`/`Grep` on source files. Read source files only when you need the code pattern itself (e.g. to write a new function that matches existing style). When you do read multiple source files, fire them in parallel.
55
+
54
56
Tailwind v4 gotcha: Tailwind utilities are emitted inside cascade layers, while `DESIGN_SYSTEM_CSS` is plain unlayered CSS. Broad unlayered resets override utilities even when the utility selector looks more specific; e.g. `a { color: inherit; }` breaks legacy anchor tabs using `text-white` / `text-gray-*`. Scope resets to unclassed elements (`a:not([class])`) or put them in Tailwind's base layer.
0 commit comments