feat (crud): add installation, unit

This commit is contained in:
dpurbosakti
2025-08-20 13:40:25 +07:00
parent 14cba14822
commit 4c25bdf8db
23 changed files with 1595 additions and 8 deletions
@@ -0,0 +1,69 @@
package installation
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ere "simrs-vx/internal/domain/references/encounter"
)
type CreateDto struct {
Code string `json:"code"`
Name string `json:"name"`
EncounterClass_Code ere.EncounterClass `json:"encounterClass_code"`
}
type ReadListDto struct {
Code string `json:"code"`
Name string `json:"name"`
EncounterClass_Code ere.EncounterClass `json:"encounterClass_code"`
Page int `json:"page"`
PageSize int `json:"page_size"`
NoPagination int `json:"no_pagination"`
}
type ReadDetailDto struct {
Id uint16 `json:"id"`
Code string `json:"code"`
Name string `json:"name"`
EncounterClass_Code ere.EncounterClass `json:"encounterClass_code"`
}
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.SmallMain
Code string `json:"code"`
Name string `json:"name"`
EncounterClass_Code ere.EncounterClass `json:"encounterClass_code"`
}
func (i Installation) ToResponse() ResponseDto {
resp := ResponseDto{
Code: i.Code,
Name: i.Name,
EncounterClass_Code: i.EncounterClass_Code,
}
resp.SmallMain = i.SmallMain
return resp
}
func ToResponseList(users []Installation) []ResponseDto {
resp := make([]ResponseDto, len(users))
for i, u := range users {
resp[i] = u.ToResponse()
}
return resp
}
@@ -0,0 +1,13 @@
package installation
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ere "simrs-vx/internal/domain/references/encounter"
)
type Installation struct {
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"size:10"`
Name string `json:"name" gorm:"size:50"`
EncounterClass_Code ere.EncounterClass `json:"encounterClass_code" gorm:"size:10"`
}
+68
View File
@@ -0,0 +1,68 @@
package unit
import (
ecore "simrs-vx/internal/domain/base-entities/core"
)
type CreateDto struct {
Installation_Id *uint16 `json:"installation_id"`
Code string `json:"code"`
Name string `json:"name"`
}
type ReadListDto struct {
Installation_Id *uint16 `json:"installation_id"`
Code string `json:"code"`
Name string `json:"name"`
Page int `json:"page"`
PageSize int `json:"page_size"`
NoPagination int `json:"no_pagination"`
}
type ReadDetailDto struct {
Installation_Id *uint16 `json:"installation_id"`
Id uint16 `json:"id"`
Code string `json:"code"`
Name string `json:"name"`
}
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.SmallMain
Installation_Id *uint16 `json:"installation_id"`
Code string `json:"code"`
Name string `json:"name"`
}
func (u Unit) ToResponse() ResponseDto {
resp := ResponseDto{
Installation_Id: u.Installation_Id,
Code: u.Code,
Name: u.Name,
}
resp.SmallMain = u.SmallMain
return resp
}
func ToResponseList(users []Unit) []ResponseDto {
resp := make([]ResponseDto, len(users))
for i, u := range users {
resp[i] = u.ToResponse()
}
return resp
}
@@ -0,0 +1,14 @@
package unit
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ei "simrs-vx/internal/domain/main-entities/installation"
)
type Unit struct {
ecore.SmallMain // adjust this according to the needs
Installation_Id *uint16 `json:"installation_id"`
Installation *ei.Installation `json:"installation" gorm:"foreignKey:Installation_Id"`
Code string `json:"code" gorm:"size:10"`
Name string `json:"name" gorm:"size:50"`
}
@@ -28,7 +28,7 @@ const (
func (ec EncounterClass) Code() string {
switch ec {
case ECAmbulatory:
case ECAmbulatory, ECOutpatient:
return "AMB"
case ECInpatient:
return "IMP"