Files
simrsx-be/internal/domain/main-entities/mcu-order/dto.go
T
dpurbosakti 45d687c5ec wip
2025-09-15 14:07:30 +07:00

78 lines
1.9 KiB
Go

package mcuorder
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/doctor"
ee "simrs-vx/internal/domain/main-entities/encounter"
erc "simrs-vx/internal/domain/references/common"
)
type CreateDto struct {
Encounter_Id *uint `json:"encounter_id"`
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
Doctor_Id *uint `json:"doctor_id"`
}
type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Encounter_Id *uint `json:"encounter_id"`
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
Doctor_Id *uint `json:"doctor_id"`
Page int `json:"page"`
PageSize int `json:"page_size"`
NoPagination int `json:"no_pagination"`
}
type ReadDetailDto struct {
Id uint16 `json:"id"`
}
type UpdateDto struct {
Id uint16 `json:"id"`
CreateDto
}
type DeleteDto struct {
Id uint16 `json:"id"`
}
type MetaDto struct {
PageNumber int `json:"page_number"`
PageSize int `json:"page_size"`
Count int `json:"count"`
}
type ResponseDto struct {
ecore.Main
Encounter_Id *uint `json:"encounter_id"`
Encounter *ee.Encounter `json:"encounter,omitempty"`
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
Doctor_Id *uint `json:"doctor_id"`
Doctor *ed.Doctor `json:"doctor,omitempty"`
}
func (d McuOrder) ToResponse() ResponseDto {
resp := ResponseDto{
Encounter_Id: d.Encounter_Id,
Encounter: d.Encounter,
Status_Code: d.Status_Code,
Doctor_Id: d.Doctor_Id,
Doctor: d.Doctor,
}
resp.Main = d.Main
return resp
}
func ToResponseList(data []McuOrder) []ResponseDto {
resp := make([]ResponseDto, len(data))
for i, u := range data {
resp[i] = u.ToResponse()
}
return resp
}