domain
import "github.com/prescriptoo/prescriptoo-api/pkg/types/domain"Package domain contains shared clinical catalog models, value objects, inputs, errors and validation. It has no service/repository interfaces or transport, storage-driver, or service-package dependencies; those interfaces live in ports. Existing unrelated types remain in the root types package.
Index
- Constants
- Variables
- func Display(s string) string
- func Normalize(s string) string
- func ValidActor(a MutationActor) bool
- func ValidCategory(c HistoryCategory) bool
- func ValidID(s string) bool
- type CatalogChange
- type CatalogQuery
- type CatalogSnapshot
- type ChiefComplaint
- type ChiefComplaintPatch
- type ChiefComplaintValues
- type CreateChiefComplaintInput
- type CreateHistoryInput
- type DeleteInput
- type DeletionFilter
- type Field
- type FinalCanonicalProduct
- type FinalDoctorChamber
- type FinalDoctorEntry
- type FinalDoctorSnapshot
- type FinalPrescriptionActor
- type FinalPrescriptionListInput
- type FinalPrescriptionMetadata
- type FinalPrescriptionPage
- type FinalPrescriptionReadInput
- type FinalPrescriptionRecord
- type FinalPrescriptionSummary
- type FinalProductSnapshot
- type HistoryAttributes
- type HistoryCatalogQuery
- type HistoryCategory
- type HistoryPatch
- type HistorySuggestion
- type HistorySuggestionQuery
- type HistoryValues
- type Metadata
- type MutationActor
- type Page
- type PatchChiefComplaintInput
- type PatchHistoryInput
- type SaveFinalPrescriptionInput
- type ScopedSuggestionQuery
- type Status
- type SuggestionQuery
Constants
Supported history categories match the doctor editor's category identifiers.
const (
Medical HistoryCategory = "medical"
Surgical HistoryCategory = "surgical"
Medication HistoryCategory = "medication"
Allergy HistoryCategory = "allergy"
Family HistoryCategory = "family"
Social HistoryCategory = "social"
PresentIllness HistoryCategory = "present-illness"
Obstetric HistoryCategory = "obstetric"
Pediatric HistoryCategory = "pediatric"
Immunization HistoryCategory = "immunization"
AdverseReaction HistoryCategory = "adverse-reaction"
Other HistoryCategory = "other"
Active Status = "active"
Inactive Status = "inactive"
Live DeletionFilter = "live"
Deleted DeletionFilter = "deleted"
All DeletionFilter = "all"
AllergyDrug = "Drug"
AllergyFood = "Food"
AllergyOther = "Other"
AllergyUnspecified = "Unspecified"
// MutationLock serializes catalog writes and seed identity reservations.
MutationLock int64 = 726583947201
)Variables
Stable catalog errors are mapped to transport errors by Doctor and Admin.
var (
ErrInvalidInput = errors.New("invalid clinical suggestion input")
ErrNotFound = errors.New("clinical suggestion not found")
ErrConflict = errors.New("clinical suggestion identity or state conflicts")
ErrUnavailable = errors.New("clinical suggestion capability unavailable")
)var (
// ErrFinalPrescriptionInvalid rejects malformed commands and cursor/filter combinations.
ErrFinalPrescriptionInvalid = errors.New("invalid final prescription")
// ErrFinalPrescriptionNotFound hides inaccessible organizations, patients and records.
ErrFinalPrescriptionNotFound = errors.New("prescription resource not found")
// ErrFinalPrescriptionConflict requires explicit review of a changed identity or save request.
ErrFinalPrescriptionConflict = errors.New("prescription snapshot or idempotency conflict")
// ErrFinalPrescriptionProductConflict rejects unknown, inactive or mismatched canonical products.
ErrFinalPrescriptionProductConflict = errors.New("prescription product conflict")
// ErrFinalPrescriptionUnavailable indicates an unavailable real persistence or eligibility capability.
ErrFinalPrescriptionUnavailable = errors.New("prescription unavailable")
)func Display
func Display(s string) stringDisplay normalizes Unicode and whitespace while retaining original letter case.
func Normalize
func Normalize(s string) stringNormalize is the common seed, identity and search normalization, preserving Bengali marks.
func ValidActor
func ValidActor(a MutationActor) boolValidActor checks trusted attribution before any mutation, including a no-op.
func ValidCategory
func ValidCategory(c HistoryCategory) boolValidCategory reports whether a required category is supported.
func ValidID
func ValidID(s string) boolValidID requires the canonical UUID spelling used in paths and stored IDs.
type CatalogChange
CatalogChange records create/update/delete before-and-after domain snapshots. Actor attribution belongs to WithinMutation; request metadata comes from context.
type CatalogChange struct {
Entity string // chief-complaint | history-suggestion
Action string // create | update | delete
ID string
Before, After CatalogSnapshot
}type CatalogQuery
CatalogQuery selects a filter-bound management page.
type CatalogQuery struct {
// Search matches titles/aliases; Cursor binds continuation to the normalized filters.
Search, Cursor string
// Limit defaults to 20 and must be between 1 and 100.
Limit int
// Status controls Doctor eligibility independently of soft deletion.
Status Status
// Deletion selects live, deleted, or all terms for management reads.
Deletion DeletionFilter
}func PrepareCatalogQuery
func PrepareCatalogQuery(q CatalogQuery) (CatalogQuery, error)PrepareCatalogQuery applies management defaults and validates filter bounds.
type CatalogSnapshot
CatalogSnapshot contains exactly one resource type for a nonempty snapshot.
type CatalogSnapshot struct {
ChiefComplaint *ChiefComplaint
HistorySuggestion *HistorySuggestion
}type ChiefComplaint
ChiefComplaint is a catalog term with optional associated complaint choices.
type ChiefComplaint struct {
Metadata
// Title is the English display label, normalized for whitespace and Unicode.
Title string
// Aliases are searchable synonyms; Associated are optional related choices in display order.
Aliases, Associated []string
}func PrepareChiefComplaint
func PrepareChiefComplaint(v ChiefComplaint) (ChiefComplaint, error)PrepareChiefComplaint validates and normalizes content, initializing empty lists.
type ChiefComplaintPatch
ChiefComplaintPatch represents exactly the fields supplied by an editor.
type ChiefComplaintPatch struct {
// Title is the English display label, normalized for whitespace and Unicode.
Title Field[string]
// Aliases are searchable synonyms; Associated are optional related choices in display order.
Aliases, Associated Field[[]string]
// Status controls Doctor eligibility independently of soft deletion.
Status Field[Status]
// SortOrder ranks default suggestions in ascending order.
SortOrder Field[int]
}type ChiefComplaintValues
ChiefComplaintValues supplies validated create values after defaults.
type ChiefComplaintValues struct {
// Title is the English display label, normalized for whitespace and Unicode.
Title string
// Aliases are searchable synonyms; Associated are optional related choices in display order.
Aliases, Associated []string
// Status controls Doctor eligibility independently of soft deletion.
Status Status
// SortOrder ranks default suggestions in ascending order.
SortOrder int
}type CreateChiefComplaintInput
CreateChiefComplaintInput combines authorized attribution and new values.
type CreateChiefComplaintInput struct {
// Actor comes from the verified Admin principal, never an HTTP body.
Actor MutationActor
// Values contains editable creation fields after defaults.
Values ChiefComplaintValues
}type CreateHistoryInput
CreateHistoryInput combines authorized attribution and new history values.
type CreateHistoryInput struct {
// Actor comes from the verified Admin principal, never an HTTP body.
Actor MutationActor
// Values contains editable creation fields after defaults.
Values HistoryValues
}type DeleteInput
DeleteInput soft-deletes one term while retaining actor attribution.
type DeleteInput struct {
// Actor comes from the verified Admin principal, never an HTTP body.
Actor MutationActor
// ID is a stable server-assigned UUID; edits preserve it.
ID string
}type DeletionFilter
DeletionFilter controls visibility in administrator list queries.
type DeletionFilter string // live | deleted | alltype Field
Field retains PATCH presence independently of a value's zero value. HTTP mappers reject explicit null before constructing this domain value.
type Field[T any] struct {
// Present distinguishes an omitted patch field from an explicit zero or empty value.
Present bool
// Value replaces the stored field only when Present is true.
Value T
}type FinalCanonicalProduct
FinalCanonicalProduct archives resolved catalogue identity and update provenance.
type FinalCanonicalProduct struct {
ID, GenericID, BrandID, GenericName, BrandName, Strength, Form, Route, TherapeuticClassID, CatalogueVersion string
IngredientIDs []string
UpdatedAt time.Time
}type FinalDoctorChamber
FinalDoctorChamber preserves a submitted professional practice location.
type FinalDoctorChamber struct{ Name, Address, Hours string }type FinalDoctorEntry
FinalDoctorEntry is the identity and display snapshot of a professional catalogue selection.
type FinalDoctorEntry struct{ ID, Name string }type FinalDoctorSnapshot
FinalDoctorSnapshot is verified against current professional data before finalization.
type FinalDoctorSnapshot struct {
ID, UserID, Name, LicenseNumber string
Speciality FinalDoctorEntry
Qualifications []FinalDoctorEntry
Chambers []FinalDoctorChamber
}type FinalPrescriptionActor
FinalPrescriptionActor is constructed from the verified account/profile, never client identity.
type FinalPrescriptionActor struct{ UserID, DoctorID, Name string }type FinalPrescriptionListInput
FinalPrescriptionListInput selects authorized summaries with stable keyset pagination.
type FinalPrescriptionListInput struct {
Actor FinalPrescriptionActor
OrganizationID, PatientID, Search, DateFrom, DateTo, Cursor string
Limit int
}type FinalPrescriptionMetadata
FinalPrescriptionMetadata is immutable server-generated save metadata.
type FinalPrescriptionMetadata struct {
ID, OrganizationID, DoctorID string
PatientID *string
PrescriptionNumber string
Version int64
CreatedAt, FinalizedAt time.Time
}type FinalPrescriptionPage
FinalPrescriptionPage carries initialized summary rows and an opaque continuation.
type FinalPrescriptionPage struct {
Items []FinalPrescriptionSummary
NextCursor string
}type FinalPrescriptionReadInput
FinalPrescriptionReadInput selects a record in a captured organization and verified actor scope.
type FinalPrescriptionReadInput struct {
Actor FinalPrescriptionActor
OrganizationID, ID string
}type FinalPrescriptionRecord
FinalPrescriptionRecord retains the complete sanitized clinical and letterhead payload.
type FinalPrescriptionRecord struct {
FinalPrescriptionMetadata
Payload []byte
}type FinalPrescriptionSummary
FinalPrescriptionSummary omits the clinical payload when browsing saved records.
type FinalPrescriptionSummary struct {
FinalPrescriptionMetadata
PatientName, ConsultationDate string
}type FinalProductSnapshot
FinalProductSnapshot is an existing canonical product reference plus its submitted display snapshot.
type FinalProductSnapshot struct{ ID, GenericName, BrandName, Strength, Form, Route string }type HistoryAttributes
HistoryAttributes contains catalog classifications, not patient findings.
type HistoryAttributes struct {
// AllergyKind classifies allergy terms; an empty value carries no classification.
AllergyKind string // empty, Drug, Food, Other, or Unspecified
}type HistoryCatalogQuery
HistoryCatalogQuery optionally limits management results to one category.
type HistoryCatalogQuery struct {
CatalogQuery
// Category selects a history editor section; management queries may omit it.
Category HistoryCategory // empty means all categories
}type HistoryCategory
HistoryCategory identifies one of the twelve supported history sections.
type HistoryCategory stringfunc Categories
func Categories() []HistoryCategoryCategories returns an independent ordered list of supported categories.
type HistoryPatch
HistoryPatch is validated together with the current stored record.
type HistoryPatch struct {
// Category selects a history editor section; management queries may omit it.
Category Field[HistoryCategory]
// Title is the English display label, normalized for whitespace and Unicode.
Title Field[string]
// Aliases includes English/Bengali search terms and is initialized when empty.
Aliases Field[[]string]
// Attributes contains only catalog classifications, never patient observations.
Attributes Field[HistoryAttributes]
// Status controls Doctor eligibility independently of soft deletion.
Status Field[Status]
// SortOrder ranks default suggestions in ascending order.
SortOrder Field[int]
}type HistorySuggestion
HistorySuggestion is a history term scoped to one category.
type HistorySuggestion struct {
Metadata
// Category selects a history editor section; management queries may omit it.
Category HistoryCategory
// Title is the English display label, normalized for whitespace and Unicode.
Title string
// Aliases includes English/Bengali search terms and is initialized when empty.
Aliases []string
// Attributes contains only catalog classifications, never patient observations.
Attributes HistoryAttributes
}func PrepareHistory
func PrepareHistory(v HistorySuggestion) (HistorySuggestion, error)PrepareHistory validates a category and its catalog classifications together.
type HistorySuggestionQuery
HistorySuggestionQuery adds the required category filter.
type HistorySuggestionQuery struct {
SuggestionQuery
// Category selects a history editor section; management queries may omit it.
Category HistoryCategory
}type HistoryValues
HistoryValues supplies a category and compatible classifications.
type HistoryValues struct {
// Category selects a history editor section; management queries may omit it.
Category HistoryCategory
// Title is the English display label, normalized for whitespace and Unicode.
Title string
// Aliases includes English/Bengali search terms and is initialized when empty.
Aliases []string
// Attributes contains only catalog classifications, never patient observations.
Attributes HistoryAttributes
// Status controls Doctor eligibility independently of soft deletion.
Status Status
// SortOrder ranks default suggestions in ascending order.
SortOrder int
}type Metadata
Metadata contains catalog identity, lifecycle, and display priority.
type Metadata struct {
// ID is a stable server-assigned UUID; edits preserve it.
ID string
// Status controls Doctor eligibility independently of soft deletion.
Status Status
// SortOrder ranks default suggestions in ascending order.
SortOrder int
// CreatedAt and UpdatedAt record creation and the latest actual change in UTC.
CreatedAt, UpdatedAt time.Time
// DeletedAt is nil for a live term; deleted terms remain recoverable.
DeletedAt *time.Time
}type MutationActor
MutationActor identifies the authorized administrator for atomic audit. Admin derives it from verified identity/membership, never a request body.
type MutationActor struct {
// UserID identifies the authenticated active identity account.
UserID string
// MembershipID identifies its verified active platform-admin membership.
MembershipID string
// Name preserves the administrator display name for audit attribution.
Name string
}type Page
Page contains a bounded management page and an opaque continuation.
type Page[T any] struct {
// Items is initialized for an empty management page.
Items []T
// NextCursor is opaque and empty at the end of management results.
NextCursor string
}type PatchChiefComplaintInput
PatchChiefComplaintInput identifies the record and supplied edits.
type PatchChiefComplaintInput struct {
// Actor comes from the verified Admin principal, never an HTTP body.
Actor MutationActor
// ID is a stable server-assigned UUID; edits preserve it.
ID string
// Patch contains exactly the fields supplied by the editor.
Patch ChiefComplaintPatch
}type PatchHistoryInput
PatchHistoryInput identifies the history term and supplied edits.
type PatchHistoryInput struct {
// Actor comes from the verified Admin principal, never an HTTP body.
Actor MutationActor
// ID is a stable server-assigned UUID; edits preserve it.
ID string
// Patch contains exactly the fields supplied by the editor.
Patch HistoryPatch
}type SaveFinalPrescriptionInput
SaveFinalPrescriptionInput contains a validated detached document and the logical save identity.
type SaveFinalPrescriptionInput struct {
Actor FinalPrescriptionActor
OrganizationID, IdempotencyKey, RequestHash string
Doctor FinalDoctorSnapshot
PatientID *string
PatientName, ConsultationDate string
Payload []byte
Products []FinalProductSnapshot
}type ScopedSuggestionQuery
ScopedSuggestionQuery pages a Doctor catalogue using an actor/organization-bound scope.
type ScopedSuggestionQuery struct {
SuggestionQuery
Cursor string
Scope string
Category HistoryCategory
}type Status
Status controls eligibility for Doctor autocomplete results.
type Status string // active | inactivetype SuggestionQuery
SuggestionQuery selects a bounded autocomplete result without a cursor.
type SuggestionQuery struct {
// Search matches titles/aliases literally after shared normalization.
Search string
// Limit defaults to 20 and must be between 1 and 100.
Limit int
}func PrepareSuggestionQuery
func PrepareSuggestionQuery(q SuggestionQuery) (SuggestionQuery, error)PrepareSuggestionQuery validates bounds and normalizes a query before storage access.
Generated by gomarkdoc