postgres
import "github.com/prescriptoo/prescriptoo-api/services/doctor/internal/adapters/postgres"Package postgres implements doctor profile persistence.
Index
- func NewProfileRepository(db *pgxpool.Pool) ports.ProfileRepository
- type Catalogs
- func (r *Catalogs) Create(ctx context.Context, kind p.CatalogKind, values p.CatalogValues) (*p.CatalogEntry, error)
- func (r *Catalogs) Delete(ctx context.Context, kind p.CatalogKind, id string) error
- func (r *Catalogs) Get(ctx context.Context, kind p.CatalogKind, id string) (*p.CatalogEntry, error)
- func (r *Catalogs) List(ctx context.Context, kind p.CatalogKind, options p.CatalogListOptions) ([]p.CatalogEntry, error)
- func (r *Catalogs) Update(ctx context.Context, kind p.CatalogKind, id string, values p.CatalogValues) (*p.CatalogEntry, error)
- type FinalPrescriptionProfiles
- type PadSettings
- type PatientRepository
- func NewPatientRepository(db *pgxpool.Pool) *PatientRepository
- func (r *PatientRepository) Create(ctx context.Context, x *types.PatientProfile) error
- func (r *PatientRepository) FindRequest(ctx context.Context, user, org, key string) (string, string, error)
- func (r *PatientRepository) Get(ctx context.Context, id, org string, lock bool) (*types.PatientProfile, error)
- func (r *PatientRepository) List(ctx context.Context, q ports.ListQuery) (*ports.ListPage, error)
- func (r *PatientRepository) NextMRN(ctx context.Context, org string) (string, error)
- func (r *PatientRepository) SaveRequest(ctx context.Context, user, org, key, f, id string, now time.Time) error
- func (r *PatientRepository) Scope(ctx context.Context, id string) (ports.Scope, error)
- func (r *PatientRepository) Update(ctx context.Context, x *types.PatientProfile, expected int64) error
- type PatientUnitOfWork
- type ProfessionalSelections
- type ProfilePatches
- type Registration
func NewProfileRepository
func NewProfileRepository(db *pgxpool.Pool) ports.ProfileRepositoryNewProfileRepository constructs a PostgreSQL profile reader.
type Catalogs
Catalogs persists professional reference data owned by Doctor.
type Catalogs struct{ DB *pgxpool.Pool }func (*Catalogs) Create
func (r *Catalogs) Create(ctx context.Context, kind p.CatalogKind, values p.CatalogValues) (*p.CatalogEntry, error)Create validates and inserts a reference term.
func (*Catalogs) Delete
func (r *Catalogs) Delete(ctx context.Context, kind p.CatalogKind, id string) errorDelete removes an unreferenced term; foreign keys protect dependencies.
func (*Catalogs) Get
func (r *Catalogs) Get(ctx context.Context, kind p.CatalogKind, id string) (*p.CatalogEntry, error)Get loads one catalog entry.
func (*Catalogs) List
func (r *Catalogs) List(ctx context.Context, kind p.CatalogKind, options p.CatalogListOptions) ([]p.CatalogEntry, error)List returns entries in stable alphabetical order.
func (*Catalogs) Update
func (r *Catalogs) Update(ctx context.Context, kind p.CatalogKind, id string, values p.CatalogValues) (*p.CatalogEntry, error)Update replaces editable fields while preserving reference IDs.
type FinalPrescriptionProfiles
FinalPrescriptionProfiles exposes transaction-bound patient/profile checks to Prescription through shared ports.
type FinalPrescriptionProfiles struct{ DB *pgxpool.Pool }func (FinalPrescriptionProfiles) FinalPrescriptionPatientMRN
func (p FinalPrescriptionProfiles) FinalPrescriptionPatientMRN(ctx context.Context, tx pgx.Tx, id, org string) (string, error)FinalPrescriptionPatientMRN reads only an existing patient in the captured organization.
func (FinalPrescriptionProfiles) VerifyFinalDoctorSnapshot
func (p FinalPrescriptionProfiles) VerifyFinalDoctorSnapshot(ctx context.Context, tx pgx.Tx, s c.FinalDoctorSnapshot) errorVerifyFinalDoctorSnapshot locks the profile and compares its current professional display fields.
type PadSettings
PadSettings stores one account-scoped design per Doctor account.
type PadSettings struct{ DB *pgxpool.Pool }func (PadSettings) Get
func (r PadSettings) Get(ctx context.Context, userID string) (*domain.PadSettings, error)Get returns nil without an error when the account has no saved design.
func (PadSettings) Save
func (r PadSettings) Save(ctx context.Context, doctorID, userID string, expected *int64, resourceVersion int, value domain.PadSettingsValue) (*domain.PadSettings, error)Save uses one conditional statement, so concurrent writers cannot both win the same revision.
type PatientRepository
PatientRepository persists Patient-owned records and retry state.
type PatientRepository struct {
// contains filtered or unexported fields
}func NewPatientRepository
func NewPatientRepository(db *pgxpool.Pool) *PatientRepositoryNewPatientRepository creates a PostgreSQL patient repository and fails closed without a database.
func (*PatientRepository) Create
func (r *PatientRepository) Create(ctx context.Context, x *types.PatientProfile) errorCreate inserts a patient profile.
func (*PatientRepository) FindRequest
func (r *PatientRepository) FindRequest(ctx context.Context, user, org, key string) (string, string, error)FindRequest looks up a scoped create retry fingerprint and result.
func (*PatientRepository) Get
func (r *PatientRepository) Get(ctx context.Context, id, org string, lock bool) (*types.PatientProfile, error)Get reads a profile constrained to its authorized organization.
func (*PatientRepository) List
func (r *PatientRepository) List(ctx context.Context, q ports.ListQuery) (*ports.ListPage, error)List counts and queries authorized rows before applying the keyset boundary.
func (*PatientRepository) NextMRN
func (r *PatientRepository) NextMRN(ctx context.Context, org string) (string, error)NextMRN atomically allocates the next organization-local number.
func (*PatientRepository) SaveRequest
func (r *PatientRepository) SaveRequest(ctx context.Context, user, org, key, f, id string, now time.Time) errorSaveRequest records the committed create result in the business transaction.
func (*PatientRepository) Scope
func (r *PatientRepository) Scope(ctx context.Context, id string) (ports.Scope, error)Scope contains only the stored facts needed to establish patient access.
func (*PatientRepository) Update
func (r *PatientRepository) Update(ctx context.Context, x *types.PatientProfile, expected int64) errorUpdate persists an effective patch at the expected version.
type PatientUnitOfWork
PatientUnitOfWork commits patient business changes and provider effects atomically.
type PatientUnitOfWork struct{ DB *pgxpool.Pool }func (PatientUnitOfWork) WithinTransaction
func (w PatientUnitOfWork) WithinTransaction(ctx context.Context, fn func(ports.PatientTransaction) error) errorWithinTransaction runs patient persistence and provider effects on one transaction.
type ProfessionalSelections
ProfessionalSelections owns the atomic profile-to-catalog relationship write.
type ProfessionalSelections struct{ DB *pgxpool.Pool }func (ProfessionalSelections) ReplaceProfessionalSelections
func (r ProfessionalSelections) ReplaceProfessionalSelections(ctx context.Context, doctorID string, input usecase.ProfessionalSelections) errorReplaceProfessionalSelections serializes edits and atomically replaces relationships.
type ProfilePatches
ProfilePatches serializes partial edits with other professional selection writes.
type ProfilePatches struct{ DB *pgxpool.Pool }func (ProfilePatches) PatchProfile
func (r ProfilePatches) PatchProfile(ctx context.Context, doctorID, userID string, p usecase.PatchMyDoctorProfileParams) (*domain.Profile, error)PatchProfile preserves omissions against the locked current profile. A failed license or hierarchy constraint rolls back all supplied fields together.
type Registration
Registration coordinates one transaction using each service's owned capability.
type Registration struct {
DB *pgxpool.Pool
Identity identity.TransactionalRegistration
Invitations organization.DoctorInvitationRedeemer
}func (Registration) Register
func (r Registration) Register(ctx context.Context, input usecase.RegistrationParams) (*usecase.RegistrationResult, error)Register commits identity, profile, and optional invitation/affiliation together.
Generated by gomarkdoc