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
Copy file name to clipboardExpand all lines: .claude/skills/hl7v2-to-fhir-pipeline/SKILL.md
+86-41Lines changed: 86 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,69 +5,114 @@ description: Build a new HL7v2→FHIR message converter or extend an existing on
5
5
6
6
# HL7v2 → FHIR Converter Pipeline
7
7
8
-
Extend the HL7v2→FHIR conversion module per the user's request. You are the orchestrator; sub-agents and the `/plan` and `/work` skills do the heavy lifting.
8
+
Build or extend an HL7v2→FHIR converter. Four phases: **Setup → Requirements → Plan → Execute**.
9
9
10
-
If the request isn't about a new message converter, a new field mapping, or adapting existing conversion to new messages — return an error.
10
+
**One invocation = one phase.** Detect which phase is next from ticket state, run it, commit, stop. Do NOT re-invoke this skill — the user does that.
11
11
12
-
## Step 0 — Is it already supported?
12
+
If the request is not about a converter (new message, new field mapping, extending conversion), stop and say so.
13
13
14
-
Before creating a ticket, if the user supplies one or more example messages, run each through `message-lookup`:
14
+
---
15
+
16
+
## Step A — Detect which phase to run
17
+
18
+
The arg from the user names a message type or ticket slug (e.g. `ADT_A03`, `adt-a03-discharge`).
19
+
20
+
**A.1 — Find or choose the ticket folder.**
21
+
22
+
Search for an existing folder:
23
+
24
+
```sh
25
+
ls ai/tickets/converter-skill-tickets/ 2>/dev/null | grep -i <keyword>
26
+
```
27
+
28
+
`<keyword>` = a lowercase fragment of the arg (e.g. `a03` for `ADT_A03`).
29
+
30
+
- Match found → `TICKET_DIR=ai/tickets/converter-skill-tickets/<match>`. Go to A.2.
31
+
- No match → this is new work. `SLUG` = kebab-case descriptive name (e.g. `adt-a03-discharge`). `TICKET_DIR=ai/tickets/converter-skill-tickets/<SLUG>`. Run **Phase 1**.
32
+
33
+
**A.2 — Inspect ticket.md to pick the phase.**
15
34
16
35
```sh
17
-
bun scripts/check-message-support.ts <example-file>
- All examples report `supported — message converts cleanly` → tell the user "this is already supported" and stop. Do not open a ticket.
21
-
- All examples report `NOT supported — no converter registered` → proceed to Step 1; this is a new-converter case.
22
-
- Examples report `routed but data fails conversion` or `supported with caveats` → the converter exists but has gaps. Ask the user whether they want to extend the existing converter (this pipeline) or fix a specific error (`check-errors`).
41
+
|`# Requirements`|`# Implementation Plan`| Unchecked `- [ ]`| Run |
42
+
|---|---|---|---|
43
+
| 0 | 0 | — | Phase 2 |
44
+
| ≥1 | 0 | — | Phase 3 |
45
+
| ≥1 | ≥1 | ≥1 | Phase 4 |
46
+
| ≥1 | ≥1 | 0 | Ask user what they want next. Stop. |
47
+
48
+
---
49
+
50
+
## Rules (apply to every phase)
23
51
24
-
If the user supplies no example messages, skip Step 0.
52
+
- You talk to the user. Sub-agents, `/plan`, `/work` run silently — their output returns to you.
53
+
- Commit after each phase (ticket edits + new files).
54
+
-**De-identify example messages before saving them.** Change names, dates, and numeric IDs in any user-supplied message before writing it to `examples/` or a fixture. Never paste raw PHI.
25
55
26
-
## Rules
56
+
---
27
57
28
-
- You are the only thing that talks to the user. Sub-agents and `/plan`/`/work` delegates do not.
29
-
- If a sub-agent needs user input, resume it with the user's answer — don't re-prompt the sub-agent from scratch.
30
-
- Between steps, commit the ticket changes and move on. Don't summarize sub-agent output unless the user asks.
31
-
-**Never use user-provided example messages unchanged.** De-identify them (change names, dates, numeric IDs) before writing them into fixtures, docs, or the ticket.
58
+
## Phase 1 — Setup (new ticket)
59
+
60
+
1. Create the ticket folder: `mkdir -p $TICKET_DIR/examples`.
61
+
2. If the user supplied example messages, first pre-flight them:
62
+
```sh
63
+
bun scripts/check-message-support.ts <file>
64
+
```
65
+
If **all** report `supported — message converts cleanly`, delete the folder you just made and stop — no ticket needed. Tell the user it already works.
66
+
3. Write `$TICKET_DIR/ticket.md` with a `# Goal` section (2-4 sentences: what + why).
67
+
4. Populate `$TICKET_DIR/examples/`:
68
+
- User supplied messages → de-identify, one message per file.
69
+
- User has no examples → spawn an agent:
70
+
```
71
+
Agent({
72
+
description: "Generate HL7v2 examples",
73
+
subagent_type: "general-purpose",
74
+
prompt: "Generate 5 example <message-type> messages in $TICKET_DIR/examples/. 3 conforming to HL7v2 2.5, 2 conforming to HL7v2 2.8.2. Use the hl7v2-info skill. One message per file."
75
+
})
76
+
```
77
+
5. Commit (`git add $TICKET_DIR && git commit`).
78
+
6. Tell the user: "Ticket created at `$TICKET_DIR`. Invoke the skill again to run Phase 2 (requirements)." Stop.
32
79
33
-
## Pipeline
80
+
---
34
81
35
-
### Step 1 — Ticket setup
82
+
## Phase 2 — Requirements
36
83
37
-
- Create `ai/tickets/converter-skill-tickets/<ticket-name>/` (unless the user pointed to an existing folder).
38
-
- Create `ticket.md` with a `# Goal` section describing the request.
39
-
- Create an `examples/` subdirectory. Ask the user to put real example messages there. If they say they have none, spawn a sub-agent with this prompt to generate them:
84
+
Spawn the requirements agent. The prompt lives at `.claude/skills/hl7v2-to-fhir-pipeline/requirements-prompt.md` — read it, substitute `<the-ticket-name>` with the ticket slug, pass as prompt:
40
85
41
-
```
42
-
Generate 5 example <message-type> messages in ai/tickets/converter-skill-tickets/<ticket-name>/examples/:
43
-
- 3 conforming to HL7v2 2.5
44
-
- 2 conforming to HL7v2 2.8.2
45
-
Use the hl7v2-info skill. Each example in its own file.
- Record the `examples/` path in the ticket. Commit.
94
+
When the agent returns, commit the ticket changes. Tell the user: "Requirements added to `$TICKET_DIR/ticket.md`. Invoke the skill again to run Phase 3 (plan)." Stop.
49
95
50
-
### Step 2 — Requirements
96
+
---
51
97
52
-
Spawn a sub-agent with the prompt in `requirements-prompt.md`. It writes a `# Requirements` section into `ticket.md`. Commit.
98
+
## Phase 3 — Plan
53
99
54
-
### Step 3 — Plan
100
+
Invoke `/plan` via the Skill tool:
55
101
56
-
Call `/plan`. Point it at `ticket.md`. It explores the codebase, discusses the approach with the user, and appends `# Implementation Plan` to the ticket — leaving `# Requirements` intact. Commit.
`/plan` talks with the user and appends `# Implementation Plan` to `ticket.md`. When it returns, commit. Tell the user: "Plan ready. Invoke the skill again to run Phase 4 (execute)." Stop.
59
107
60
-
Call `/work`. It executes the plan one task at a time, with an independent review after each task.
108
+
---
61
109
62
-
When `/work` reports the final task complete and the user approves, the pipeline is done. Tell the user they can test the functionality in the UI.
110
+
## Phase 4 — Execute
63
111
64
-
## Resumption
112
+
Invoke `/work`:
65
113
66
-
If the user points to an existing ticket folder, detect current state and jump in:
| Has `# Requirements`, no `# Implementation Plan` | Step 3 |
72
-
| Has `# Implementation Plan` with unchecked tasks | Step 4 |
73
-
| All tasks checked | Ask the user what they want next |
118
+
`/work` runs tasks one at a time with review between each. When all tasks are checked off and the user has approved, tell them: "Converter ready. Test via the UI at http://localhost:3000." Stop.
Copy file name to clipboardExpand all lines: .claude/skills/work/SKILL.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,16 +17,22 @@ Execute a plan file at `ai/tickets/YYYY-MM-DD-*.md` produced by `/plan`. The fil
17
17
18
18
If the task is the last one and the user approves, move the plan file to `ai/tickets/completed/`.
19
19
20
-
## Review agent prompt
20
+
## Review agent spawn
21
+
22
+
Use the **Agent tool** (not the Skill tool — this is a sub-agent running `ai-review`, not you invoking it yourself). Substitute `[N]` and `[plan-file-path]`:
21
23
22
24
```
23
-
Use skill ai-review to review implementation of Task [N] from [plan-file-path]. Think hard. The changes are uncommitted. Return your review output; do not change any files.
25
+
Agent({
26
+
description: "Review Task [N]",
27
+
subagent_type: "general-purpose",
28
+
prompt: "Use skill ai-review to review implementation of Task [N] from [plan-file-path]. Think hard. The changes are uncommitted. Return your review output; do not change any files."
29
+
})
24
30
```
25
31
26
-
Replace `[N]` and `[plan-file-path]`. If the user specified codex for reviews, spawn it with:
32
+
If the user specified codex for reviews, instead run via the **Bash tool**:
Copy file name to clipboardExpand all lines: CLAUDE.md
-4Lines changed: 0 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,10 +98,6 @@ Referenced constantly when diagnosing errors. Full details: `docs/developer-guid
98
98
-`sending_error` — FHIR bundle submission to Aidbox failed; auto-retried 3 times
99
99
-`deferred` — manually set via `POST /defer/:id` when resolution needs external input; eligible for retry via `POST /mark-for-retry/:id`
100
100
101
-
## Known Sender Issues & Preprocessors
102
-
103
-
**swap-in1-date-fields** — Handles reversed IN1-12/IN1-13 (Plan Effective Date / Plan Expiration Date). Some senders send start >= end; preprocessor swaps them only when detected. Logs warning. Applied to ADT-A01 and ADT-A08. Masks sender error — escalate if persistent.
104
-
105
101
## US Core demographic extension runtime note
106
102
107
103
If `profileConformance.implementationGuides` enables US Core (`hl7.fhir.us.core`), PID-10/PID-22 mapping adds `us-core-race` / `us-core-ethnicity` on Patient. Aidbox must have the US Core package loaded and CodeSystem `urn:oid:2.16.840.1.113883.6.238` available (seeded in `init-bundle.json`), or Patient writes fail with terminology-binding errors.
"short": "Original as-sent Coverage.period.start before autoswap",
499
+
"definition": "Set when the IN1 Coverage converter detected reversed IN1-12/IN1-13 dates and autoswapped them to satisfy FHIR invariant per-1. Records the start value as originally received from the sender."
"short": "Original as-sent Coverage.period.end before autoswap",
540
+
"definition": "Set when the IN1 Coverage converter detected reversed IN1-12/IN1-13 dates and autoswapped them to satisfy FHIR invariant per-1. Records the end value as originally received from the sender."
0 commit comments