Skip to main content

Ghasi e-Prescribing Gateway Service — Local Dev Setup

Status: populated Owner: TBD Last updated: 2026-04-18 Companion: Service Template · 03 platform-services · 02 DDD

Prerequisites

  • Docker Desktop 4.x+
  • Node.js 22 LTS
  • pnpm 9+

docker-compose.yml

version: "3.9"
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: eprescribing_dev
POSTGRES_USER: eprescribing
POSTGRES_PASSWORD: dev_password
ports:
- "5435:5432"
volumes:
- eprescribing_pg_data:/var/lib/postgresql/data

nats:
image: nats:2.10-alpine
command: ["--jetstream", "--store_dir=/data"]
ports:
- "4223:4222"
- "8223:8222"
volumes:
- eprescribing_nats_data:/data

keycloak:
image: ghcr.io/ghasi/keycloak-dev:latest
ports:
- "8081:8080"
environment:
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: admin

volumes:
eprescribing_pg_data:
eprescribing_nats_data:

Environment Setup

cp .env.example .env

.env.example:

DATABASE_URL=postgres://eprescribing:dev_password@localhost:5435/eprescribing_dev
NATS_URL=nats://localhost:4223
KEYCLOAK_JWKS_URI=http://localhost:8081/realms/ghasi-dev/protocol/openid-connect/certs
PROVIDER_DIRECTORY_SERVICE_URL=http://localhost:3012
TERMINOLOGY_SERVICE_URL=http://localhost:3010
AUDIT_SERVICE_URL=http://localhost:3011
IG_VALIDATION_MODE=zod
EPRESCRIBING_MODULE_ENTITLEMENT=ehr.ghasi_eprescribing_gateway
SUBSCRIPTION_SIGNING_KEY_ARN=local-dev-key
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
PORT=3001

Start and Migrate

docker compose up -d
pnpm install
pnpm drizzle-kit migrate # creates gepgw_* tables
pnpm seed # seeds EHR and Pharmacy dev clients, one patient
pnpm dev # starts service with hot reload

Seed Data

pnpm seed creates:

  • Tenant: ten_dev_01 with ehr.ghasi_eprescribing_gateway entitlement
  • EHR backend client: svc_ehr_dev with ehr-backend persona
  • Pharmacy backend client: svc_pharm_dev with pharmacy-backend persona
  • Patient: pat_dev_01
  • Pharmacy organization: org_pharm_dev_01
  • Sample Subscription channel registered for each client

Common Commands

CommandPurpose
pnpm devStart with hot reload
pnpm testRun all tests
pnpm test:unitUnit tests
pnpm test:integrationIntegration tests (Docker required)
pnpm test:e2eE2E three-party tests
pnpm test:contractPact + FHIR golden fixtures
pnpm drizzle-kit generateGenerate migration from schema
pnpm drizzle-kit migrateApply pending migrations
pnpm lintESLint
pnpm typecheckTypeScript strict

Verify Service

# Health
curl http://localhost:3001/health/ready

# Create a MedicationRequest (EHR backend dev token)
curl -X POST http://localhost:3001/fhir/MedicationRequest \
-H "Authorization: Bearer <ehr-dev-token>" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/fhir+json" \
-d @test/fixtures/fhir/medication-request-valid.json

Simulating Three-Party Flow Locally

  1. Create MR as EHR client → captures mr_id and ETag.
  2. Check NATS: nats-cli sub eprescribing.medication_request.created.v1.
  3. Create MD as Pharmacy client referencing mr_id.
  4. Verify Subscription notification was delivered (inspect dev webhook endpoint or WireMock).