Files
simrsx-be/internal/domain/main-entities/inpatient/dto.go
T
dpurbosakti 255484c520 wip
2025-09-08 14:08:25 +07:00

79 lines
1.9 KiB
Go

package inpatient
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/encounter"
ei "simrs-vx/internal/domain/main-entities/infra"
ere "simrs-vx/internal/domain/references/encounter"
)
type CreateDto struct {
Encounter_Id *uint `json:"encounter_id"`
Class_Code ere.InpatientClassCode `json:"class_code" validate:"maxLength=10"`
Infra_Id *uint16 `json:"infra_id"`
}
type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Encounter_Id *uint `json:"encounter_id"`
Class_Code ere.InpatientClassCode `json:"class_code"`
Infra_Id *uint16 `json:"infra_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"`
Class_Code ere.InpatientClassCode `json:"class_code"`
Infra_Id *uint16 `json:"infra_id"`
Infra *ei.Infra `json:"infra,omitempty"`
}
func (d Inpatient) ToResponse() ResponseDto {
resp := ResponseDto{
Encounter_Id: d.Encounter_Id,
Encounter: d.Encounter,
Class_Code: d.Class_Code,
Infra_Id: d.Infra_Id,
Infra: d.Infra,
}
resp.Main = d.Main
return resp
}
func ToResponseList(data []Inpatient) []ResponseDto {
resp := make([]ResponseDto, len(data))
for i, u := range data {
resp[i] = u.ToResponse()
}
return resp
}