Part of the ZarishSphere Platform - A No-Code FHIR Healthcare Data Management System
The Zarish FHIR Server is a Go-based implementation of the HL7 FHIR (Fast Healthcare Interoperability Resources) standard. It provides RESTful APIs for managing healthcare data including patients, observations, medications, and other FHIR resources.
- Language: Go 1.23+
- Web Framework: Gin
- Database ORM: GORM
- Database: PostgreSQL
- Search Engine: Elasticsearch (optional)
- Authentication: Keycloak integration
- Containerization: Docker
Before you begin, ensure you have the following installed:
- Go: Version 1.23 or higher (Download Go)
- PostgreSQL: Version 14 or higher (Download PostgreSQL)
- Docker (optional): For containerized deployment (Download Docker)
- Git: For version control (Download Git)
- Code Editor: VS Code with Go extension recommended
go version # Should show go1.23 or higher
psql --version # Should show PostgreSQL 14.x or higher
docker --version # Should show Docker version 20.x or higher
git --version # Should show git version 2.x.x# Navigate to your desired directory
cd ~/Desktop
# Clone the repository
git clone https://github.com/ZarishSphere-Platform/zarish-fhir-server.git
# Navigate into the project
cd zarish-fhir-server# Download and install all Go modules
go mod download
# Verify dependencies
go mod tidy# Connect to PostgreSQL
psql -U postgres
# Create database
CREATE DATABASE zarish_fhir;
# Create user (optional)
CREATE USER zarish WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE zarish_fhir TO zarish;
# Exit psql
\q# Run PostgreSQL in Docker
docker run --name zarish-postgres \
-e POSTGRES_DB=zarish_fhir \
-e POSTGRES_USER=zarish \
-e POSTGRES_PASSWORD=your_password \
-p 5432:5432 \
-d postgres:14Create a .env file in the project root:
# Create the environment file
touch .envAdd the following configuration:
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_USER=zarish
DB_PASSWORD=your_password
DB_NAME=zarish_fhir
DB_SSLMODE=disable
# Server Configuration
SERVER_PORT=8081
SERVER_HOST=0.0.0.0
# Keycloak Configuration
KEYCLOAK_URL=http://localhost:8080
KEYCLOAK_REALM=zarish
KEYCLOAK_CLIENT_ID=zarish-fhir-server
KEYCLOAK_CLIENT_SECRET=your_client_secret
# Elasticsearch (optional)
ELASTICSEARCH_URL=http://localhost:9200
ELASTICSEARCH_ENABLED=false# The application will automatically create tables on first run
# Or you can run migrations manually if implemented
go run cmd/server/main.go migrate# Run the server
go run cmd/server/main.go
# Or build and run
go build -o zarish-fhir-server cmd/server/main.go
./zarish-fhir-serverThe server will start at http://localhost:8081
# Check server health
curl http://localhost:8081/health
# Get FHIR metadata
curl http://localhost:8081/fhir/metadata
# Create a patient (example)
curl -X POST http://localhost:8081/fhir/Patient \
-H "Content-Type: application/fhir+json" \
-d '{
"resourceType": "Patient",
"name": [{"family": "Doe", "given": ["John"]}],
"gender": "male"
}'| Command | Description |
|---|---|
go run cmd/server/main.go |
Start development server |
go build -o zarish-fhir-server cmd/server/main.go |
Build production binary |
go test ./... |
Run all tests |
go mod tidy |
Clean up dependencies |
go fmt ./... |
Format code |
go vet ./... |
Run Go vet for code analysis |
zarish-fhir-server/
βββ cmd/
β βββ server/
β βββ main.go # Application entry point
βββ internal/
β βββ api/ # HTTP handlers and routes
β βββ auth/ # Authentication middleware
β βββ database/ # Database connection and migrations
β βββ models/ # FHIR resource models
β βββ search/ # Search functionality
βββ Dockerfile # Docker configuration
βββ go.mod # Go module dependencies
βββ go.sum # Dependency checksums
βββ README.md # This file
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run tests with verbose output
go test -v ./...Use tools like:
- curl: Command-line HTTP client
- Postman: GUI for API testing
- Insomnia: Alternative to Postman
# Build the image
docker build -t zarish-fhir-server .
# Run the container
docker run -p 8081:8081 \
-e DB_HOST=host.docker.internal \
-e DB_PORT=5432 \
-e DB_USER=zarish \
-e DB_PASSWORD=your_password \
-e DB_NAME=zarish_fhir \
zarish-fhir-serverSee the zarish-fhir-infra repository for complete Docker Compose setup.
The server currently supports the following FHIR resources:
- Patient: Patient demographics and information
- Observation: Clinical observations and measurements
- Medication: Medication information
- MedicationRequest: Medication prescriptions
- Condition: Patient conditions and diagnoses
- Encounter: Patient encounters and visits
- Practitioner: Healthcare practitioners
- Organization: Healthcare organizations
The server supports FHIR search parameters:
# Search patients by name
GET /fhir/Patient?name=John
# Search observations by patient
GET /fhir/Observation?patient=Patient/123
# Search with multiple parameters
GET /fhir/Patient?name=John&gender=male# Check PostgreSQL is running
pg_isready -h localhost -p 5432
# Check database exists
psql -U postgres -l | grep zarish_fhir
# Test connection
psql -U zarish -d zarish_fhir -h localhost# Find process using port 8081
lsof -i :8081
# Kill the process
kill -9 <PID>
# Or change the port in .env
SERVER_PORT=8082# Clear Go module cache
go clean -modcache
# Re-download modules
go mod download- Create a feature branch
- Make your changes
- Write/update tests
- Ensure all tests pass
- Submit a pull request
This project is part of the ZarishSphere Platform.
- Check Issues
- Create a new issue with details
- Include error logs and steps to reproduce
- zarish-frontend-shell - Frontend Application
- zarish-terminology-server - Terminology Server
- zarish-fhir-infra - Infrastructure & Deployment
- zarish-fhir-data - FHIR Data Resources