add insurancecompany, ethnic, alter person

This commit is contained in:
dpurbosakti
2025-08-27 15:38:00 +07:00
parent c1d14f3770
commit 03fb2858d1
10 changed files with 215 additions and 7 deletions
@@ -0,0 +1,28 @@
-- Create "InsuranceCompany" table
CREATE TABLE "public"."InsuranceCompany" (
"Id" serial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Code" character varying(20) NULL,
"Name" character varying(50) NULL,
"Regency_Code" character varying(4) NULL,
"Address" character varying(100) NULL,
"PhoneNumber" character varying(20) NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "uni_InsuranceCompany_Code" UNIQUE ("Code"),
CONSTRAINT "fk_InsuranceCompany_Regency" FOREIGN KEY ("Regency_Code") REFERENCES "public"."Regency" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "Ethnic" table
CREATE TABLE "public"."Ethnic" (
"Id" serial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Code" character varying(20) NULL,
"Name" character varying(50) NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "uni_Ethnic_Code" UNIQUE ("Code")
);
-- Modify "Person" table
ALTER TABLE "public"."Person" ALTER COLUMN "Ethnic_Code" TYPE character varying(20), ADD CONSTRAINT "fk_Person_Ethnic" FOREIGN KEY ("Ethnic_Code") REFERENCES "public"."Ethnic" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
+3 -2
View File
@@ -1,4 +1,4 @@
h1:qhTYEMOwm8TQ+FgXjr/nbT0/T/oRb7pvnXTcQSa/V7w=
h1:yoZN1lVD6dE66V3FtMcVHtoRtFmu18Ltn5/loput+Ns=
20250825054027.sql h1:zRUeuuP4bDLf96Cb38D/l9ivBAQC745XRao0rxbzdVI=
20250825060522.sql h1:NiE1fVzydcg8Y8ytSHgt0DkkauQFveNXv42BoG5m+bI=
20250825102900.sql h1:OAUnj87Wz7mrHykX14idePckUmRYa5UH0LylYDL76RI=
@@ -6,4 +6,5 @@ h1:qhTYEMOwm8TQ+FgXjr/nbT0/T/oRb7pvnXTcQSa/V7w=
20250827015551.sql h1:Jq/RkXSWHEWuNigLunLzIrYgiyroSVD7J0waDMvdzvg=
20250827021904.sql h1:pgjwmQS1TxZ977a1tIXKq6pZnGauPrOUxLUTclV+fE4=
20250827024311.sql h1:eTlrQYcHa/jmb3qSZxgTB+7S4IXJ8B4yklUB36iZaDw=
20250827072230.sql h1:R5H47ODPcZeINYfzLE+VMQ+l000fLwXe70MQ4BxouGw=
20250827072230.sql h1:BfdTcToEYC8d30BS+1Su5Pz5Ecz8bh74F2j+Bh/r2BM=
20250827083322.sql h1:GhPTHNQGAP13Efly86U7baFFw4l3sz+QV3g3lzeIT9Y=
@@ -0,0 +1,63 @@
package ethnic
import (
ecore "simrs-vx/internal/domain/base-entities/core"
)
type CreateDto struct {
Code string `json:"code"`
Name string `json:"name"`
}
type ReadListDto struct {
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 {
Id uint16 `json:"id"`
Code string `json:"code"`
Name string `json:"name"`
}
type UpdateDto struct {
Id uint `json:"id"`
CreateDto
}
type DeleteDto struct {
Id uint `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"`
}
func (d Ethnic) ToResponse() ResponseDto {
resp := ResponseDto{
Code: d.Code,
Name: d.Name,
}
resp.SmallMain = d.SmallMain
return resp
}
func ToResponseList(data []Ethnic) []ResponseDto {
resp := make([]ResponseDto, len(data))
for i, u := range data {
resp[i] = u.ToResponse()
}
return resp
}
@@ -0,0 +1,11 @@
package ethnic
import (
ecore "simrs-vx/internal/domain/base-entities/core"
)
type Ethnic struct {
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:20"`
Name string `json:"name" gorm:"size:50"`
}
@@ -0,0 +1,81 @@
package insurancecompany
import (
ecore "simrs-vx/internal/domain/base-entities/core"
er "simrs-vx/internal/domain/main-entities/regency"
)
type CreateDto struct {
Code string `json:"code"`
Name string `json:"name"`
Regency_Code *string `json:"regency_code"`
Address string `json:"address"`
PhoneNumber string `json:"phoneNumber"`
}
type ReadListDto struct {
Code string `json:"code"`
Name string `json:"name"`
Regency_Code *string `json:"regency_code"`
Address string `json:"address"`
PhoneNumber string `json:"phoneNumber"`
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"`
Regency_Code *string `json:"regency_code"`
Address string `json:"address"`
PhoneNumber string `json:"phoneNumber"`
}
type UpdateDto struct {
Id uint `json:"id"`
CreateDto
}
type DeleteDto struct {
Id uint `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"`
Regency_Code *string `json:"regency_code"`
Regency *er.Regency `json:"regency,omitempty"`
Address string `json:"address"`
PhoneNumber string `json:"phoneNumber"`
}
func (d InsuranceCompany) ToResponse() ResponseDto {
resp := ResponseDto{
Code: d.Code,
Name: d.Name,
Regency_Code: d.Regency_Code,
Regency: d.Regency,
Address: d.Address,
PhoneNumber: d.PhoneNumber,
}
resp.SmallMain = d.SmallMain
return resp
}
func ToResponseList(data []InsuranceCompany) []ResponseDto {
resp := make([]ResponseDto, len(data))
for i, u := range data {
resp[i] = u.ToResponse()
}
return resp
}
@@ -0,0 +1,16 @@
package insurancecompany
import (
ecore "simrs-vx/internal/domain/base-entities/core"
er "simrs-vx/internal/domain/main-entities/regency"
)
type InsuranceCompany struct {
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:20"`
Name string `json:"name" gorm:"size:50"`
Regency_Code *string `json:"regency_code" gorm:"size:4"`
Regency *er.Regency `json:"regency,omitempty" gorm:"foreignKey:Regency_Code;references:Code"`
Address string `json:"address" gorm:"size:100"`
PhoneNumber string `json:"phoneNumber" gorm:"size:20"`
}
+6 -3
View File
@@ -2,6 +2,7 @@ package person
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/ethnic"
epa "simrs-vx/internal/domain/main-entities/person-address"
epc "simrs-vx/internal/domain/main-entities/person-contact"
erp "simrs-vx/internal/domain/references/person"
@@ -18,7 +19,7 @@ type CreateDto struct {
Education_Code *erp.EducationCode `json:"education_code"`
Ocupation_Code *erp.OcupationCode `json:"occupation_code"`
Ocupation_Name *string `json:"occupation_name"`
Ethnic_Code *erp.EthnicCode `json:"ethnic_code"`
Ethnic_Code *string `json:"ethnic_code"`
}
type ReadListDto struct {
@@ -38,7 +39,7 @@ type ReadDetailDto struct {
Education_Code *erp.EducationCode `json:"education_code"`
Ocupation_Code *erp.OcupationCode `json:"occupation_code"`
Ocupation_Name *string `json:"occupation_name"`
Ethnic_Code *erp.EthnicCode `json:"ethnic_code"`
Ethnic_Code *string `json:"ethnic_code"`
}
type UpdateDto struct {
@@ -67,7 +68,8 @@ type ResponseDto struct {
Education_Code *erp.EducationCode `json:"education_code"`
Ocupation_Code *erp.OcupationCode `json:"occupation_code"`
Ocupation_Name *string `json:"occupation_name"`
Ethnic_Code *erp.EthnicCode `json:"ethnic_code"`
Ethnic_Code *string `json:"ethnic_code"`
Ethnic *ee.Ethnic `json:"ethnic,omitempty"`
Addresses *[]epa.PersonAddress `json:"addresses,omitempty"`
Contacts *[]epc.PersonContact `json:"contacts,omitempty"`
}
@@ -84,6 +86,7 @@ func (d *Person) ToResponse() ResponseDto {
Ocupation_Code: d.Ocupation_Code,
Ocupation_Name: d.Ocupation_Name,
Ethnic_Code: d.Ethnic_Code,
Ethnic: d.Ethnic,
Addresses: d.Addresses,
Contacts: d.Contacts,
}
@@ -2,6 +2,7 @@ package person
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/ethnic"
epa "simrs-vx/internal/domain/main-entities/person-address"
epc "simrs-vx/internal/domain/main-entities/person-contact"
erp "simrs-vx/internal/domain/references/person"
@@ -20,7 +21,8 @@ type Person struct {
Education_Code *erp.EducationCode `json:"education_code" gorm:"size:10"`
Ocupation_Code *erp.OcupationCode `json:"occupation_code" gorm:"size:15"`
Ocupation_Name *string `json:"occupation_name" gorm:"size:50"`
Ethnic_Code *erp.EthnicCode `json:"ethnic_code" gorm:"size:15"`
Ethnic_Code *string `json:"ethnic_code" gorm:"size:20"`
Ethnic *ee.Ethnic `json:"ethnic,omitempty" gorm:"foreignKey:Ethnic_Code;references:Code"`
Addresses *[]epa.PersonAddress `json:"addresses" gorm:"foreignKey:Person_Id"`
Contacts *[]epc.PersonContact `json:"contacts" gorm:"foreignKey:Person_Id"`
}
@@ -11,7 +11,6 @@ type (
AgeGroupForMedicineCode string
RelativeCode string
ContactTypeCode string
EthnicCode string
)
const (
@@ -12,9 +12,11 @@ import (
divisionposition "simrs-vx/internal/domain/main-entities/division-position"
doctor "simrs-vx/internal/domain/main-entities/doctor"
employee "simrs-vx/internal/domain/main-entities/employee"
ethnic "simrs-vx/internal/domain/main-entities/ethnic"
infra "simrs-vx/internal/domain/main-entities/infra"
infragroup "simrs-vx/internal/domain/main-entities/infra-group"
installation "simrs-vx/internal/domain/main-entities/installation"
insurancecompany "simrs-vx/internal/domain/main-entities/insurance-company"
item "simrs-vx/internal/domain/main-entities/item"
itemgroup "simrs-vx/internal/domain/main-entities/item-group"
itemprice "simrs-vx/internal/domain/main-entities/item-price"
@@ -103,6 +105,8 @@ func GetEntities() []any {
&medicinemethod.MedicineMethod{},
&mcusrccategory.McuSrcCategory{},
&mcusrc.McuSrc{},
&ethnic.Ethnic{},
&insurancecompany.InsuranceCompany{},
}
}