add table person-relative, add fk personrelative into person

This commit is contained in:
dpurbosakti
2025-09-02 13:33:01 +07:00
parent e8a7123f30
commit 53f798ce29
7 changed files with 163 additions and 40 deletions
@@ -0,0 +1,20 @@
-- Create "PersonRelative" table
CREATE TABLE "public"."PersonRelative" (
"Id" bigserial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Person_Id" bigint NULL,
"Relationship_Code" character varying(100) NOT NULL,
"Name" character varying(100) NULL,
"Address" character varying(100) NULL,
"Village_Code" character varying(10) NULL,
"Gender_Code" character varying(10) NULL,
"PhoneNumber" character varying(30) NULL,
"Education_Code" character varying(10) NULL,
"Occupation_Code" character varying(10) NULL,
"Occupation_Name" character varying(50) NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "fk_PersonRelative_Village" FOREIGN KEY ("Village_Code") REFERENCES "public"."Village" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_Person_Relatives" FOREIGN KEY ("Person_Id") REFERENCES "public"."Person" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
+3 -2
View File
@@ -1,6 +1,7 @@
h1:1//2fu4kC38Dh7Uay7V1mN3umZje2BP/P7dxjdyRc4c=
h1:xLrXCY32L4rM4g9bNhReT/a49v6gwYzJSNnzwSmFFlc=
20250829081952.sql h1:YMsYq3uPsx70EjWSGfYnVRR5GV0q1fRGIszYZAWzXNo=
20250901073356.sql h1:jjd5TLs+Pyi0u3SrOM+aNTbHxSJboXgcOz/L4bkYx+c=
20250901080035.sql h1:LWa3X0NWjalVcxNbk5HaHj1Oqu60/AQabi0jBmCeQBI=
20250901105703.sql h1:2h2B/wOFM0826sBXQutTtq24C+5duLqi4zEFOdbPsCI=
20250902052320.sql h1:bnTbx2vkZ7jscOdgjL8G1cuKzZ7rMMsR+KawkX8w74g=
20250902052320.sql h1:+tWdeS4NorPj5WdKHMirBfP4EeS01wyyfdT03DBMmcI=
20250902063217.sql h1:ZDyL6lk12uFmboUCMfRTh5sfQ4wsC3bWSI+vAUFUiAA=
@@ -0,0 +1,61 @@
package personrelative
import (
ecore "simrs-vx/internal/domain/base-entities/core"
erp "simrs-vx/internal/domain/references/person"
)
type CreateDto struct {
Person_Id uint `json:"person_id"`
Type_Code erp.ContactTypeCode `json:"type_code"`
Value string `json:"value"`
}
type ReadListDto struct {
Page int `json:"page"`
PageSize int `json:"page_size"`
NoPagination int `json:"no_pagination"`
}
type ReadDetailDto struct {
Id uint `json:"id"`
Person_Id uint `json:"person_id"`
Type_Code erp.ContactTypeCode `json:"type_code"`
Value string `json:"value"`
}
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.Main
Person_Id uint `json:"person_id"`
Type_Code erp.ContactTypeCode `json:"type_code"`
Value string `json:"value"`
}
func (d *PersonRelative) ToResponse() ResponseDto {
resp := ResponseDto{}
resp.Main = d.Main
return resp
}
func ToResponseList(data []PersonRelative) []ResponseDto {
resp := make([]ResponseDto, len(data))
for i, u := range data {
resp[i] = u.ToResponse()
}
return resp
}
@@ -0,0 +1,22 @@
package personrelative
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ev "simrs-vx/internal/domain/main-entities/village"
erp "simrs-vx/internal/domain/references/person"
)
type PersonRelative struct {
ecore.Main // adjust this according to the needs
Person_Id uint `json:"person_id"`
Relationship_Code erp.RelationshipCode `json:"relationship_code" gorm:"not null;size:100"`
Name *string `json:"name" gorm:"size:100"`
Address *string `json:"address" gorm:"size:100"`
Village_Code *string `json:"village_code" gorm:"size:10"`
Village *ev.Village `json:"village,omitempty" gorm:"foreignKey:Village_Code;references:Code"`
Gender_Code *erp.GenderCode `json:"gender_code" gorm:"size:10"`
PhoneNumber *string `json:"phoneNumber" gorm:"size:30"`
Education_Code *erp.EducationCode `json:"education_code" gorm:"size:10"`
Occupation_Code *erp.OcupationCode `json:"occupation_code" gorm:"size:10"`
Occupation_Name *string `json:"occupation_name" gorm:"size:50"`
}
+22 -20
View File
@@ -6,30 +6,32 @@ import (
el "simrs-vx/internal/domain/main-entities/language"
epa "simrs-vx/internal/domain/main-entities/person-address"
epc "simrs-vx/internal/domain/main-entities/person-contact"
epr "simrs-vx/internal/domain/main-entities/person-relative"
erp "simrs-vx/internal/domain/references/person"
"time"
)
type Person struct {
ecore.Main // adjust this according to the needs
Name string `json:"name" gorm:"not null;size:150"`
FrontTitle *string `json:"frontTitle" gorm:"size:50"`
EndTitle *string `json:"endTitle" gorm:"size:50"`
BirthDate *time.Time `json:"birthDate,omitempty"`
BirthRegency_Code *string `json:"birthRegency_code" gorm:"size:4"`
Gender_Code *erp.GenderCode `json:"gender_code" gorm:"size:10"`
ResidentIdentityNumber *string `json:"residentIdentityNumber" gorm:"size:16"`
PassportNumber *string `json:"passportNumber" gorm:"size:20"`
DrivingLicenseNumber *string `json:"drivingLicenseNumber" gorm:"size:20"`
Religion_Code *erp.ReligionCode `json:"religion_code" gorm:"size:10"`
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 *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"`
Language_Code *string `json:"language_code" gorm:"size:10"`
Language *el.Language `json:"language,omitempty" gorm:"foreignKey:Language_Code;references:Code"`
ecore.Main // adjust this according to the needs
Name string `json:"name" gorm:"not null;size:150"`
FrontTitle *string `json:"frontTitle" gorm:"size:50"`
EndTitle *string `json:"endTitle" gorm:"size:50"`
BirthDate *time.Time `json:"birthDate,omitempty"`
BirthRegency_Code *string `json:"birthRegency_code" gorm:"size:4"`
Gender_Code *erp.GenderCode `json:"gender_code" gorm:"size:10"`
ResidentIdentityNumber *string `json:"residentIdentityNumber" gorm:"size:16"`
PassportNumber *string `json:"passportNumber" gorm:"size:20"`
DrivingLicenseNumber *string `json:"drivingLicenseNumber" gorm:"size:20"`
Religion_Code *erp.ReligionCode `json:"religion_code" gorm:"size:10"`
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 *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"`
Relatives *[]epr.PersonRelative `json:"relatives" gorm:"foreignKey:Person_Id"`
Language_Code *string `json:"language_code" gorm:"size:10"`
Language *el.Language `json:"language,omitempty" gorm:"foreignKey:Language_Code;references:Code"`
}
+33 -18
View File
@@ -11,6 +11,7 @@ type (
AgeGroupForMedicineCode string
RelativeCode string
ContactTypeCode string
RelationshipCode string
)
const (
@@ -18,9 +19,7 @@ const (
GCFemale GenderCode = "female"
GCNotStated GenderCode = "not-stated"
GCUnknown GenderCode = "unknown"
)
const (
BTCAPositive BloodTypeCode = "A+"
BTCANegative BloodTypeCode = "A-"
BTCBPositive BloodTypeCode = "B+"
@@ -29,25 +28,19 @@ const (
BTCABNegative BloodTypeCode = "AB-"
BTCOPositive BloodTypeCode = "O+"
BTCONegative BloodTypeCode = "O-"
)
const (
MSCBelumKawin MaritalStatusCode = "S"
MSCKawin MaritalStatusCode = "M"
MSCCeraiHidup MaritalStatusCode = "D"
MSCCeraiMati MaritalStatusCode = "W"
)
const (
RCIslam ReligionCode = "islam"
RCProtestan ReligionCode = "protestan"
RCKatolik ReligionCode = "katolik"
RCHindu ReligionCode = "hindu"
RCBudha ReligionCode = "budha"
RCKonghucu ReligionCode = "konghucu"
)
const (
ECTS EducationCode = "TS"
ECTK EducationCode = "TK"
ECSD EducationCode = "SD"
@@ -60,9 +53,7 @@ const (
ECS1 EducationCode = "S1"
ECS2 EducationCode = "S2"
ECS3 EducationCode = "S3"
)
const (
OCTidakBekerja OcupationCode = "tidak-bekerja"
OCPns OcupationCode = "pns"
OCTniPolisi OcupationCode = "polisi"
@@ -71,9 +62,7 @@ const (
OCWiraswasta OcupationCode = "wiraswasta"
OCKarySwasta OcupationCode = "kary-swasta"
OCLainlain OcupationCode = "lainnya"
)
const (
AGCEUnknown AgeGroupCode = "unkown"
AGCLTE5 AgeGroupCode = "LT5"
AGCEU19 AgeGroupCode = "UE19"
@@ -82,17 +71,13 @@ const (
AGCEU49 AgeGroupCode = "UE49"
AGCEU59 AgeGroupCode = "UE50"
AGCGE60 AgeGroupCode = "E60"
)
const (
AGMCNew AgeGroupForMedicineCode = "new-born"
AGMCInfant AgeGroupForMedicineCode = "infant"
AGMCToddler AgeGroupForMedicineCode = "toddler"
AGMCKid AgeGroupForMedicineCode = "kid"
AGMCAdult AgeGroupForMedicineCode = "adult"
)
const (
RCMSuami RelativeCode = "suami"
RCMIstri RelativeCode = "istri"
RCMAnak RelativeCode = "anak"
@@ -107,13 +92,23 @@ const (
RCMBibi RelativeCode = "bibi"
RCMPamanKakek RelativeCode = "kakek"
RCMPamanNenek RelativeCode = "nenek"
)
const (
CTPhone ContactTypeCode = "phone"
CTMPhone ContactTypeCode = "m-phone"
CTEmail ContactTypeCode = "email"
CTFax ContactTypeCode = "fax"
RCMother RelationshipCode = "mother" // Ibu
RCFather RelationshipCode = "father" // Ayah
RCUncle RelationshipCode = "uncle" // Paman
RCAunt RelationshipCode = "aunt" // Bibi
RCSibling RelationshipCode = "sibling" // Saudara
RCGdMother RelationshipCode = "gd-mother" // Nenek
RCGdFather RelationshipCode = "gd-father" // Kakek
RCChild RelationshipCode = "child" // Anak
RCNephew RelationshipCode = "nephew" // Keponakan
RCGdChild RelationshipCode = "gd-child" // Cucu
RCOther RelationshipCode = "other" // Lainnya
)
func GetGenderCodes() map[GenderCode]string {
@@ -239,6 +234,22 @@ func GetContactTypeCodes() map[ContactTypeCode]string {
}
}
func GetRelationshipCodes() map[RelationshipCode]string {
return map[RelationshipCode]string{
RCMother: "Ibu",
RCFather: "Ayah",
RCUncle: "Paman",
RCAunt: "Bibi",
RCSibling: "Saudara",
RCGdMother: "Nenek",
RCGdFather: "Kakek",
RCChild: "Anak",
RCNephew: "Keponakan",
RCGdChild: "Cucu",
RCOther: "Lainnya",
}
}
func (obj GenderCode) String() string {
return GetGenderCodes()[obj]
}
@@ -273,3 +284,7 @@ func (obj RelativeCode) String() string {
func (obj ContactTypeCode) String() string {
return GetContactTypeCodes()[obj]
}
func (obj RelationshipCode) String() string {
return GetRelationshipCodes()[obj]
}
@@ -36,6 +36,7 @@ import (
person "simrs-vx/internal/domain/main-entities/person"
personaddress "simrs-vx/internal/domain/main-entities/person-address"
personcontact "simrs-vx/internal/domain/main-entities/person-contact"
personrelative "simrs-vx/internal/domain/main-entities/person-relative"
pharmacist "simrs-vx/internal/domain/main-entities/pharmacist"
pharmacycompany "simrs-vx/internal/domain/main-entities/pharmacy-company"
practiceschedule "simrs-vx/internal/domain/main-entities/practice-schedule"
@@ -121,6 +122,7 @@ func GetEntities() []any {
&device.Device{},
&doctorfee.DoctorFee{},
&language.Language{},
&personrelative.PersonRelative{},
}
}