Skip to content

postgres ​

go
import "github.com/prescriptoo/prescriptoo-api/services/patient/internal/adapters/postgres"

Package postgres implements Patient-owned PostgreSQL persistence.

Index ​

type Repository ​

Repository persists Patient-owned records and retry state.

go
type Repository struct {
    // contains filtered or unexported fields
}

func New ​

go
func New(db *pgxpool.Pool) *Repository

New creates a PostgreSQL patient repository and fails closed without a database.

func (*Repository) Create ​

go
func (r *Repository) Create(ctx context.Context, x *domain.Profile) error

Create inserts a patient profile.

func (*Repository) FindRequest ​

go
func (r *Repository) FindRequest(ctx context.Context, user, org, key string) (string, string, error)

FindRequest looks up a scoped create retry fingerprint and result.

func (*Repository) Get ​

go
func (r *Repository) Get(ctx context.Context, id, org string, lock bool) (*domain.Profile, error)

Get reads a profile constrained to its authorized organization.

func (*Repository) List ​

go
func (r *Repository) List(ctx context.Context, q ports.ListQuery) (*ports.ListPage, error)

List counts and queries authorized rows before applying the keyset boundary.

func (*Repository) NextMRN ​

go
func (r *Repository) NextMRN(ctx context.Context, org string) (string, error)

NextMRN atomically allocates the next organization-local number.

func (*Repository) SaveRequest ​

go
func (r *Repository) SaveRequest(ctx context.Context, user, org, key, f, id string, now time.Time) error

SaveRequest records the committed create result in the business transaction.

func (*Repository) Scope ​

go
func (r *Repository) Scope(ctx context.Context, id string) (ports.Scope, error)

Scope contains only the stored facts needed to establish patient access.

func (*Repository) Update ​

go
func (r *Repository) Update(ctx context.Context, x *domain.Profile, expected int64) error

Update persists an effective patch at the expected version.

type UnitOfWork ​

UnitOfWork commits patient business changes and provider effects atomically.

go
type UnitOfWork struct{ DB *pgxpool.Pool }

func (UnitOfWork) WithinTransaction ​

go
func (w UnitOfWork) WithinTransaction(ctx context.Context, fn func(ports.Transaction) error) error

WithinTransaction runs patient persistence and provider effects on one transaction.

Generated by gomarkdoc

Documentation follows the source. Planned contracts are marked explicitly.