fhir

command module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 2 Imported by: 0

README

FHIR R5 Generator

A Go code generator for FHIR R5 resources and types. Generates type-safe Go models from official FHIR StructureDefinitions.

Overview

This generator reads FHIR R5 specification files and generates complete Go struct definitions for all resources and complex types defined in the specification. Each generated model includes JSON/BSON tags and validation methods.

Generated Models

Generated models are located in the r5/ directory. The generator creates one Go file per resource/type with:

  • Struct definitions matching FHIR specification
  • JSON and BSON tags for serialization
  • Validate() methods for field validation
  • Proper handling of required fields, cardinality, patterns, and constraints

Usage

Generating Models

Run the generator to create all FHIR R5 models:

go run generate.go

This will:

  1. Load StructureDefinitions from spec/profiles-types.json and spec/profiles-resources.json
  2. Generate Go models for all resources and types
  3. Write output files to r5/ directory
Using Generated Models

Import the generated models in your code:

import "fhir/r5"

// Use generated types
patient := &r5.Patient{
    ID: stringPtr("example"),
    // ... other fields
}

// Validate the resource
if err := patient.Validate(); err != nil {
    // handle validation error
}

// Marshal to JSON
data, err := json.Marshal(patient)

Requirements

  • Go 1.25 or later
  • FHIR R5 specification files in spec/ directory

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
tools

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL