105 lines
3.0 KiB
Go
105 lines
3.0 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
"github.com/go-playground/validator/v10"
|
|
)
|
|
|
|
// BaseRequest contains common fields for all requests
|
|
type BaseRequest struct {
|
|
RequestID string `json:"request_id,omitempty"`
|
|
Timestamp time.Time `json:"timestamp,omitempty"`
|
|
}
|
|
|
|
// BaseResponse contains common fields for all responses
|
|
type BaseResponse struct {
|
|
Status string `json:"status"`
|
|
Message string `json:"message"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
RequestID string `json:"request_id,omitempty"`
|
|
}
|
|
|
|
// ErrorResponse represents an error response
|
|
type ErrorResponse struct {
|
|
Status string `json:"status"`
|
|
Message string `json:"message"`
|
|
RequestID string `json:"request_id,omitempty"`
|
|
}
|
|
|
|
// SuccessResponse represents a success response
|
|
type SuccessResponse struct {
|
|
Status string `json:"status"`
|
|
Message string `json:"message"`
|
|
RequestID string `json:"request_id,omitempty"`
|
|
}
|
|
|
|
// SearchData contains search results
|
|
type SearchData struct {
|
|
Results []interface{} `json:"results"`
|
|
Total int `json:"total"`
|
|
Limit int `json:"limit"`
|
|
Offset int `json:"offset"`
|
|
}
|
|
|
|
// Patient Models
|
|
// Generated at: 2025-09-07 17:42:51
|
|
|
|
// PatientCreateRequest represents a request to create a Patient
|
|
type PatientCreateRequest struct {
|
|
BaseRequest
|
|
// Add fields specific to Patient creation
|
|
Name string `json:"name" validate:"required"`
|
|
Description string `json:"description" validate:"omitempty"`
|
|
}
|
|
|
|
// PatientUpdateRequest represents a request to update a Patient
|
|
type PatientUpdateRequest struct {
|
|
BaseRequest
|
|
ID string `json:"id" validate:"required,uuid"`
|
|
Name string `json:"name" validate:"required"`
|
|
Description string `json:"description" validate:"omitempty"`
|
|
}
|
|
|
|
// PatientResponse represents a response for Patient operations
|
|
type PatientResponse struct {
|
|
BaseResponse
|
|
}
|
|
|
|
// PatientSearchResponse represents a response for Patient search
|
|
type PatientSearchResponse struct {
|
|
BaseResponse
|
|
Data SearchData `json:"data"`
|
|
}
|
|
|
|
// PatientData represents the data structure for Patient
|
|
type PatientData struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
|
}
|
|
|
|
// Validate validates the PatientCreateRequest
|
|
func (r *PatientCreateRequest) Validate() error {
|
|
validate := validator.New()
|
|
return validate.Struct(r)
|
|
}
|
|
|
|
// Validate validates the PatientUpdateRequest
|
|
func (r *PatientUpdateRequest) Validate() error {
|
|
validate := validator.New()
|
|
return validate.Struct(r)
|
|
}
|
|
|
|
// NewPatientData creates a new PatientData with default values
|
|
func NewPatientData(name, description string) *PatientData {
|
|
now := time.Now()
|
|
return &PatientData{
|
|
ID: "", // Will be set by the database
|
|
Name: name,
|
|
Description: description,
|
|
CreatedAt: now,
|
|
UpdatedAt: now,
|
|
}
|
|
} |