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 ¶
- func NewAppointment(opts ...AppointmentOption) (*types.ResourceEnvelope, error)
- func NewObservation(opts ...ObservationOption) (*types.ResourceEnvelope, error)
- func NewPatient(opts ...PatientOption) (*types.ResourceEnvelope, error)
- type AppointmentOption
- func WithAppointmentID(id string) AppointmentOption
- func WithAppointmentMeta(meta map[string]any) AppointmentOption
- func WithAppointmentStatus(status string) AppointmentOption
- func WithDescription(desc string) AppointmentOption
- func WithPatientReference(patientID string) AppointmentOption
- func WithStart(start string) AppointmentOption
- type ObservationOption
- func WithCodeText(code string) ObservationOption
- func WithObservationID(id string) ObservationOption
- func WithObservationMeta(meta map[string]any) ObservationOption
- func WithObservationStatus(status string) ObservationOption
- func WithQuantityValue(value float64, unit string) ObservationOption
- func WithSubjectReference(patientID string) ObservationOption
- type PatientOption
- func WithFamilyName(family string) PatientOption
- func WithGender(gender string) PatientOption
- func WithGivenName(given string) PatientOption
- func WithLastUpdated(t time.Time) PatientOption
- func WithPatientID(id string) PatientOption
- func WithPatientMeta(meta map[string]any) PatientOption
- func WithTelecom(value string) PatientOption
- func WithVersionID(versionID string) PatientOption
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 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 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.