Files
simrsx-be/internal/domain/main-entities/chemo-protocol/dto.go
T
2025-12-09 09:04:51 +07:00

125 lines
3.8 KiB
Go

package chemo_protocol
import (
eus "simrs-vx/internal/domain/main-entities/user"
pa "simrs-vx/internal/lib/auth"
// std
"time"
// internal - domain - references
erc "simrs-vx/internal/domain/references/common"
// internal - domain - main-entities
ecore "simrs-vx/internal/domain/base-entities/core"
ec "simrs-vx/internal/domain/main-entities/chemo"
ep "simrs-vx/internal/domain/main-entities/chemo-plan"
)
type CreateDto struct {
Encounter_Id *uint `json:"encounter_id" validate:"required"`
Chemo_Id *uint `json:"chemo_id" validate:"required"`
Patient_Weight *float32 `json:"patient_weight"`
Patient_Height *float32 `json:"patient_height"`
Diagnoses *string `json:"diagnoses" validate:"required"`
Interval *uint `json:"interval" validate:"required"`
Cycle *uint `json:"cycle" validate:"required"`
Series *uint16 `json:"series" validate:"required"`
StartDate *time.Time `json:"startDate"`
EndDate *time.Time `json:"endDate"`
Patient_Id *uint `json:"patient_id"`
ChemoPlans *[]ep.CreateDto `json:"chemoPlans" validate:"required"`
Id *uint `json:"-"`
Status_Code erc.DataVerifiedCode `json:"-"`
}
type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Pagination ecore.Pagination
}
type FilterDto struct {
Chemo_Id *uint `json:"chemo-id"`
Patient_Id *uint `json:"patient-id"`
}
type ReadDetailDto struct {
Id uint `json:"id"`
Includes string `json:"includes"`
}
type UpdateDto struct {
Id uint `json:"id"`
CreateDto
}
type DeleteDto struct {
Id uint `json:"id"`
}
type VerifyDto struct {
Id uint `json:"id"`
Status_Code erc.DataVerifiedCode `json:"-"`
pa.AuthInfo
}
type MetaDto struct {
PageNumber int `json:"page_number"`
PageSize int `json:"page_size"`
Count int `json:"count"`
}
type ResponseDto struct {
ecore.Main
Chemo_Id *uint `json:"chemo_id"`
Chemo *ec.Chemo `json:"chemo,omitempty"`
Patient_Weight *float32 `json:"patient_weight"`
Patient_Height *float32 `json:"patient_height"`
Diagnoses *string `json:"diagnoses"`
Interval *uint `json:"interval"`
Cycle *uint `json:"cycle"`
Series *uint16 `json:"series"`
StartDate *time.Time `json:"startDate"`
EndDate *time.Time `json:"endDate"`
Status_Code erc.DataVerifiedCode `json:"status_code"`
VerifiedAt *time.Time `json:"verifiedAt"`
VerifiedBy_User_Id *uint `json:"verifiedBy_user_id"`
VerifiedBy *eus.User `json:"verifiedBy,omitempty"`
ChemoPlans *[]ep.ChemoPlan `json:"chemoPlans,omitempty"`
Patient_Id *uint `json:"patient_id"`
}
func (d ChemoProtocol) ToResponse() ResponseDto {
resp := ResponseDto{
Chemo_Id: d.Chemo_Id,
Chemo: d.Chemo,
Patient_Weight: d.Patient_Weight,
Patient_Height: d.Patient_Height,
Diagnoses: d.Diagnoses,
Interval: d.Interval,
Cycle: d.Cycle,
Series: d.Series,
StartDate: d.StartDate,
EndDate: d.EndDate,
Status_Code: d.Status_Code,
VerifiedAt: d.VerifiedAt,
VerifiedBy_User_Id: d.VerifiedBy_User_Id,
VerifiedBy: d.VerifiedBy,
ChemoPlans: d.ChemoPlans,
Patient_Id: d.Patient_Id,
}
resp.Main = d.Main
return resp
}
func ToResponseList(data []ChemoProtocol) []ResponseDto {
resp := make([]ResponseDto, len(data))
for i, u := range data {
resp[i] = u.ToResponse()
}
return resp
}