Skip to content

FHIR Models for Go

Type-safe Go structs for every FHIR R4, R4B, and R5 resource. 
Build, serialize, and integrate with fluent builders and JSON serialization.

Quick Start

Requires Go 1.23 or later.

Install the package for the FHIR version you need:

go get github.com/gofhir/models/r4/v2

Create a Patient resource and serialize it to JSON:

package main

import (
    "fmt"

    "github.com/gofhir/models/r4/v2"
)

func main() {
    patient := r4.NewPatientBuilder().
        SetId("example").
        SetActive(true).
        SetGender(r4.AdministrativeGenderMale).
        Build()

    data, _ := r4.Marshal(patient)
    fmt.Println(string(data))
}

Output:

{"resourceType":"Patient","id":"example","active":true,"gender":"male"}
Read the full guide