init push
This commit is contained in:
54
internal/domain/patient_data/model.go
Normal file
54
internal/domain/patient_data/model.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package patient_data
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
insurancepatientdata "wucher/internal/domain/insurance_patient_data"
|
||||
"wucher/internal/domain/opc"
|
||||
"wucher/internal/shared/pkg/uuidv7"
|
||||
)
|
||||
|
||||
const (
|
||||
GenderMale = "male"
|
||||
GenderFemale = "female"
|
||||
)
|
||||
|
||||
func IsValidGender(g string) bool {
|
||||
return g == GenderMale || g == GenderFemale
|
||||
}
|
||||
|
||||
type PatientData struct {
|
||||
ID []byte `gorm:"type:binary(16);primaryKey;column:id"`
|
||||
FamilyName string `gorm:"type:varchar(128);not null;column:family_name"`
|
||||
FirstName string `gorm:"type:varchar(128);not null;column:first_name"`
|
||||
OPCId []byte `gorm:"type:binary(16);index;column:opc_id"`
|
||||
BirthDate *time.Time `gorm:"type:date;column:birth_date"`
|
||||
Gender string `gorm:"type:varchar(16);not null;column:gender"`
|
||||
Street string `gorm:"type:varchar(255);column:street"`
|
||||
SVNR string `gorm:"type:varchar(64);column:svnr"`
|
||||
Email string `gorm:"type:varchar(191);column:email"`
|
||||
Phone string `gorm:"type:varchar(64);column:phone"`
|
||||
CoInsured bool `gorm:"type:tinyint(1);not null;default:0;column:co_insured"`
|
||||
InsurancePatientDataId []byte `gorm:"type:binary(16);index;column:insurance_patient_data_id"`
|
||||
|
||||
OPC *opc.Opc `gorm:"foreignKey:OPCId;references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
|
||||
InsurancePatientData *insurancepatientdata.InsurancePatientData `gorm:"foreignKey:InsurancePatientDataId;references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
|
||||
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
CreatedBy []byte `gorm:"type:binary(16);column:created_by"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at"`
|
||||
UpdatedBy []byte `gorm:"type:binary(16);column:updated_by"`
|
||||
DeletedAt *time.Time `gorm:"column:deleted_at"`
|
||||
DeletedBy []byte `gorm:"type:binary(16);column:deleted_by"`
|
||||
}
|
||||
|
||||
func (PatientData) TableName() string { return "patient_data" }
|
||||
|
||||
func (p *PatientData) BeforeCreate(tx *gorm.DB) error {
|
||||
if len(p.ID) == 0 {
|
||||
p.ID = uuidv7.MustBytes()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
11
internal/domain/patient_data/repository.go
Normal file
11
internal/domain/patient_data/repository.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package patient_data
|
||||
|
||||
import "context"
|
||||
|
||||
type Repository interface {
|
||||
Create(ctx context.Context, row *PatientData) error
|
||||
Update(ctx context.Context, row *PatientData) error
|
||||
Delete(ctx context.Context, id []byte, deletedBy []byte) error
|
||||
GetByID(ctx context.Context, id []byte) (*PatientData, error)
|
||||
List(ctx context.Context, filter, sort string, limit, offset int) ([]PatientData, int64, error)
|
||||
}
|
||||
11
internal/domain/patient_data/service.go
Normal file
11
internal/domain/patient_data/service.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package patient_data
|
||||
|
||||
import "context"
|
||||
|
||||
type Service interface {
|
||||
Create(ctx context.Context, row *PatientData) error
|
||||
Update(ctx context.Context, row *PatientData) error
|
||||
Delete(ctx context.Context, id []byte, deletedBy []byte) error
|
||||
GetByID(ctx context.Context, id []byte) (*PatientData, error)
|
||||
List(ctx context.Context, filter, sort string, limit, offset int) ([]PatientData, int64, error)
|
||||
}
|
||||
Reference in New Issue
Block a user