Ralph Fhir Loop

"Me fail English? That's unpossible!" - Ralph Wiggum This loop keeps running until all tests pass. It's unpossible to fail.

node-on-fhir 8 updated 27d ago
Claude CodeGeneric
View source ↗
---
allowedPrompts:
  # Test execution
  - tool: Bash
    prompt: "run nightwatch tests"
  - tool: Bash
    prompt: "run npm tests"

  # Server management
  - tool: Bash
    prompt: "start meteor server"
  - tool: Bash
    prompt: "kill meteor processes"
  - tool: Bash
    prompt: "check port status"
  - tool: Bash
    prompt: "check server health"

  # Log and file inspection
  - tool: Bash
    prompt: "check server logs"
  - tool: Bash
    prompt: "list files and directories"
  - tool: Bash
    prompt: "read file contents"
  - tool: Bash
    prompt: "search file contents"

  # Directory operations
  - tool: Bash
    prompt: "create directories"

  # Output and validation
  - tool: Bash
    prompt: "redirect output to file"
  - tool: Bash
    prompt: "validate syntax"

  # Browser
  - tool: Bash
    prompt: "open browser to localhost"

  # Git operations (read-only for status/log, write for staging)
  - tool: Bash
    prompt: "check git status"
  - tool: Bash
    prompt: "view git diff"
  - tool: Bash
    prompt: "view git log"
  - tool: Bash
    prompt: "stage files for commit"

  # HTTP/Download operations (for fetching HL7 schemas)
  - tool: Bash
    prompt: "fetch FHIR schema from HL7"
  - tool: Bash
    prompt: "download JSON schema"
  - tool: Bash
    prompt: "curl HTTP request"

  # npm operations
  - tool: Bash
    prompt: "check npm packages"
  - tool: Bash
    prompt: "run npm scripts"
---

# Ralph Wiggum FHIR Microservice Loop

> "Me fail English? That's unpossible!" - Ralph Wiggum
>
> This loop keeps running until all tests pass. It's unpossible to fail.

## Slash Command

/ralph-fhir-loop


## Pre-Approved Commands

The following bash commands are pre-approved and don't require confirmation:

```bash
# Run tests against running server (most common)
npx nightwatch tests/nightwatch/honeycomb/enable_autopublish/crud.{resources}.js --config nightwatch.conf.js

# Run tests with CircleCI config
npx nightwatch --config nightwatch.circle.conf.js tests/nightwatch/honeycomb/enable_autopublish/crud.{resources}.js

# Run tests with verbose output
npx nightwatch tests/nightwatch/honeycomb/enable_autopublish/crud.{resources}.js --config nightwatch.conf.js --verbose

# Start server with auto-login (background)
meteor npm run medical-home-autologin > /tmp/meteor-server.log 2>&1 &

# Wait for server ready
for i in {1..60}; do curl -s http://localhost:3000 > /dev/null 2>&1 && echo "Server ready" && break; sleep 2; done

# Check server logs (multiple variations)
tail -100 /tmp/meteor-server.log
tail -f /tmp/meteor-server.log
cat /tmp/meteor-server.log | tail -100

# View recent test screenshots
ls -la tests/nightwatch/screenshots/{resources}/

# Check if server is running
curl -s http://localhost:3000 > /dev/null && echo "Server running" || echo "Server not running"

# Kill stuck processes (ports 3000 and 8080)
pkill -f "meteor run" || true
lsof -i :3000 | grep LISTEN | awk '{print $2}' | xargs kill -9 2>/dev/null || true
lsof -i :8080 | grep LISTEN | awk '{print $2}' | xargs kill -9 2>/dev/null || true

# Create schema directories
mkdir -p imports/lib/schemas/R4B/JsonSchema

Overview

Automated loop to implement a complete FHIR R4B microservice for a single resource type. Run nightly, one resource at a time.


PHASE 1: STARTUP

Step 1.0: Pre-Flight Checklist

Before starting, clean up any existing processes:

# Kill existing Meteor processes
pkill -f "meteor run" || true

# Clear ports 3000 and 8080
lsof -i :3000 | grep LISTEN | awk '{print $2}' | xargs kill -9 2>/dev/null || true
lsof -i :8080 | grep LISTEN | awk '{print $2}' | xargs kill -9 2>/dev/null || true

Step 1.1: Interactive Prompts

Ask the user these questions using AskUserQuestion:

  1. Which FHIR resource type? (e.g., BodyStructure, AdverseEvent, Coverage)
  2. Ownership model?
    • patient-agnostic - No patient context needed (Medication, Organization, etc.)
    • patient-owned - Requires patient context (Observation, Condition, etc.)
    • clinician-mediated - Patient + practitioner context (MedicationRequest, ServiceRequest)
    • workflow - Multi-actor financial/admin (Claim, Coverage)
  3. Confirm key fields - Show fields from JSONSchema, let user confirm/modify

Step 1.2: Launch Background Services

CRITICAL: Use the correct server startup command:

# Start server with auto-login enabled (uses settings/settings.honeycomb.tdd.json)
meteor npm run medical-home-autologin > /tmp/meteor-server.log 2>&1 &

Wait for server to be ready:

for i in {1..60}; do
  if curl -s http://localhost:3000 > /dev/null 2>&1; then
    echo "Server ready after ${i} seconds!"
    break
  fi
  sleep 2
done

Settings File Note: The medical-home-autologin script uses settings/settings.honeycomb.tdd.json, NOT settings.honeycomb.localhost.json. Ensure new resources are enabled in the TDD settings file.


PHASE 2: SCHEMA

Step 2.1: Fetch JSONSchema from HL7

IMPORTANT: The direct .schema.json URL often returns StructureDefinition format, NOT JSONSchema. Use the .schema.json.html page instead.

# Create directory if needed
mkdir -p imports/lib/schemas/R4B/JsonSchema

# WRONG: This URL returns StructureDefinition (43,000+ tokens, wrong format)
# curl https://hl7.org/fhir/R4B/{resource}.schema.json

# CORRECT: Extract JSONSchema from the HTML page
# 1. Visit: https://hl7.org/fhir/R4B/{resource}.schema.json.html
# 2. Copy the JSON content from the code block
# 3. Save to: imports/lib/schemas/R4B/JsonSchema/{Resource}.json

Format Verification: Correct JSONSchema starts with:

{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "id": "http://hl7.org/fhir/json-schema/{Resource}",
  ...
}

Wrong format (StructureDefinition) starts with:

{
  "resourceType": "StructureDefinition",
  ...
}

Step 2.2: Analyze Schema

Read the downloaded JSONSchema and extract:

  • Required fields
  • Field types (string, bo

Maintain Ralph Fhir Loop?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Ralph Fhir Loop on getagentictools](https://getagentictools.com/loops/node-on-fhir-ralph-wiggum-fhir-microservice-loop?ref=badge)