factories

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package factories builds normalized *types.ResourceEnvelope values for MVP resource types using a small options API.

Factories return errors on invalid shapes (for example empty id or missing patient reference) so tests fail fast without panics. Successful builds always route through types.JSONCodec.ParseJSON for canonical JSON and hashing.

Supported builders:

  • NewPatient(...PatientOption)
  • NewAppointment(...AppointmentOption)
  • NewObservation(...ObservationOption)

Prefer fixtures for stable named scenarios; use factories when tests need parameterized ids, references, status, or timestamps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAppointment

func NewAppointment(opts ...AppointmentOption) (*types.ResourceEnvelope, error)

NewAppointment builds a normalized Appointment envelope.

func NewObservation

func NewObservation(opts ...ObservationOption) (*types.ResourceEnvelope, error)

NewObservation builds a normalized Observation envelope.

func NewPatient

func NewPatient(opts ...PatientOption) (*types.ResourceEnvelope, error)

NewPatient builds a normalized Patient envelope. Invalid shapes return an error.

Types

type AppointmentOption

type AppointmentOption func(*appointmentConfig)

AppointmentOption configures Appointment factory output.

func WithAppointmentID

func WithAppointmentID(id string) AppointmentOption

WithAppointmentID sets the appointment id.

func WithAppointmentMeta

func WithAppointmentMeta(meta map[string]any) AppointmentOption

WithAppointmentMeta adds arbitrary FHIR meta fields.

func WithAppointmentStatus

func WithAppointmentStatus(status string) AppointmentOption

WithAppointmentStatus sets the appointment status.

func WithDescription

func WithDescription(desc string) AppointmentOption

WithDescription sets the appointment description.

func WithPatientReference

func WithPatientReference(patientID string) AppointmentOption

WithPatientReference sets the participant patient reference id.

func WithStart

func WithStart(start string) AppointmentOption

WithStart sets the appointment start time (ISO-8601).

type ObservationOption

type ObservationOption func(*observationConfig)

ObservationOption configures Observation factory output.

func WithCodeText

func WithCodeText(code string) ObservationOption

WithCodeText sets the observation code text.

func WithObservationID

func WithObservationID(id string) ObservationOption

WithObservationID sets the observation id.

func WithObservationMeta

func WithObservationMeta(meta map[string]any) ObservationOption

WithObservationMeta adds arbitrary FHIR meta fields.

func WithObservationStatus

func WithObservationStatus(status string) ObservationOption

WithObservationStatus sets the observation status.

func WithQuantityValue

func WithQuantityValue(value float64, unit string) ObservationOption

WithQuantityValue sets the valueQuantity value and unit.

func WithSubjectReference

func WithSubjectReference(patientID string) ObservationOption

WithSubjectReference sets the subject patient reference id.

type PatientOption

type PatientOption func(*patientConfig)

PatientOption configures Patient factory output.

func WithFamilyName

func WithFamilyName(family string) PatientOption

WithFamilyName sets the family name.

func WithGender

func WithGender(gender string) PatientOption

WithGender sets the patient gender.

func WithGivenName

func WithGivenName(given string) PatientOption

WithGivenName sets the given name.

func WithLastUpdated

func WithLastUpdated(t time.Time) PatientOption

WithLastUpdated sets the envelope last-updated timestamp.

func WithPatientID

func WithPatientID(id string) PatientOption

WithPatientID sets the patient id.

func WithPatientMeta

func WithPatientMeta(meta map[string]any) PatientOption

WithPatientMeta adds arbitrary FHIR meta fields. WithVersionID and WithLastUpdated take precedence for their respective reserved fields.

func WithTelecom

func WithTelecom(value string) PatientOption

WithTelecom sets a phone telecom value.

func WithVersionID

func WithVersionID(versionID string) PatientOption

WithVersionID sets the envelope version id.

Jump to

Keyboard shortcuts

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