domain
go
import "github.com/prescriptoo/prescriptoo-api/services/organization/internal/domain"Package domain contains core business entities for the organization service.
Index
- Variables
- type Member
- type MemberRole
- type MemberStatus
- type Organization
- type OrganizationProfile
- type OrganizationProfilePermission
- type OrganizationProfileRole
- type OrganizationStatus
- type Team
Variables
go
var (
// ErrOrganizationNotFound indicates that an organization does not exist.
ErrOrganizationNotFound = errors.New("organization not found")
// ErrOrganizationAlreadyExists indicates that the organization slug is already in use.
ErrOrganizationAlreadyExists = errors.New("organization with this slug already exists")
// ErrInvalidOrganization indicates invalid organization data or a lifecycle change.
ErrInvalidOrganization = errors.New("invalid organization data")
// ErrMemberNotFound indicates that an organization membership does not exist.
ErrMemberNotFound = errors.New("member not found")
// ErrMemberAlreadyExists indicates that a user already belongs to the organization.
ErrMemberAlreadyExists = errors.New("user is already a member of this organization")
// ErrTeamNotFound indicates that an organization team does not exist.
ErrTeamNotFound = errors.New("team not found")
// ErrProtectedMember indicates that an administrator membership cannot be removed.
ErrProtectedMember = errors.New("organization administrator membership is protected")
)go
var (
// ErrUnauthorized indicates missing or invalid identity credentials.
ErrUnauthorized = errors.New("organization authentication required")
// ErrForbidden indicates an inactive identity, membership or organization.
ErrForbidden = errors.New("active organization membership required")
// ErrUnavailable indicates that an organization dependency is unavailable.
ErrUnavailable = errors.New("organization service unavailable")
)type Member
Member represents a user's membership in an organization.
go
type Member struct {
ID string `json:"id"`
UserID string `json:"user_id"`
OrganizationID string `json:"organization_id"`
TeamID *string `json:"team_id,omitempty"`
Role MemberRole `json:"role"`
Status MemberStatus `json:"status"`
IsActiveContext bool `json:"is_active_context"`
JoinedAt time.Time `json:"joined_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}type MemberRole
MemberRole represents a user's role within an organization.
go
type MemberRole stringgo
const (
// RoleOrgAdmin identifies an organization administrator.
RoleOrgAdmin MemberRole = "admin"
// RoleManager identifies an organization manager.
RoleManager MemberRole = "manager"
// RoleDoctor identifies a doctor member.
RoleDoctor MemberRole = "doctor"
// RoleStaff identifies a staff member.
RoleStaff MemberRole = "staff"
)type MemberStatus
MemberStatus represents the state of a membership.
go
type MemberStatus stringgo
const (
// MemberStatusActive marks an active membership.
MemberStatusActive MemberStatus = "active"
// MemberStatusInactive marks an inactive membership.
MemberStatusInactive MemberStatus = "inactive"
// MemberStatusPending marks a membership awaiting acceptance.
MemberStatusPending MemberStatus = "pending"
)type Organization
Organization represents a medical organization/clinic entity.
go
type Organization struct {
Type *string `json:"type"`
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Description string `json:"description"`
Phone string `json:"phone"`
Email string `json:"email"`
Address string `json:"address"`
Status OrganizationStatus `json:"status"`
SubscriptionID *string `json:"subscription_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}type OrganizationProfile
OrganizationProfile contains the caller's identity, membership and scoped grants.
go
type OrganizationProfile struct {
Identity types.IdentityAccount
Profile Member
Organization Organization
Roles []OrganizationProfileRole
Permissions []OrganizationProfilePermission
}type OrganizationProfilePermission
OrganizationProfilePermission contains effective decisions after direct overrides.
go
type OrganizationProfilePermission struct {
Permission string
Own, Any bool
}type OrganizationProfileRole
OrganizationProfileRole describes an assigned organization role.
go
type OrganizationProfileRole struct {
ID, Name, Slug, Description string
Protected bool
Version int64
}type OrganizationStatus
OrganizationStatus represents the state of an organization.
go
type OrganizationStatus stringgo
const (
// OrgStatusActive marks an active organization.
OrgStatusActive OrganizationStatus = "active"
// OrgStatusSuspended marks a suspended organization.
OrgStatusSuspended OrganizationStatus = "suspended"
// OrgStatusDeleted marks an organization as deleted.
OrgStatusDeleted OrganizationStatus = "deleted"
)type Team
Team represents a grouping within an organization.
go
type Team struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Name string `json:"name"`
Description string `json:"description"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}Generated by gomarkdoc