Merge branch 'migration-vanilia' of https://github.com/dikstub-rssa/simrs-be into feat/functional-position-100

This commit is contained in:
vanilia
2025-10-24 12:19:48 +07:00
23 changed files with 164 additions and 70 deletions
@@ -0,0 +1,12 @@
-- Modify "Doctor" table
ALTER TABLE "public"."Doctor" ADD COLUMN "Code" character varying(20) NULL, ADD CONSTRAINT "uni_Doctor_Code" UNIQUE ("Code");
-- Modify "Laborant" table
ALTER TABLE "public"."Laborant" ADD COLUMN "Code" character varying(20) NULL, ADD CONSTRAINT "uni_Laborant_Code" UNIQUE ("Code");
-- Modify "Midwife" table
ALTER TABLE "public"."Midwife" ADD COLUMN "Code" character varying(20) NULL, ADD CONSTRAINT "uni_Midwife_Code" UNIQUE ("Code");
-- Modify "Nurse" table
ALTER TABLE "public"."Nurse" ADD COLUMN "Code" character varying(20) NULL, ADD CONSTRAINT "uni_Nurse_Code" UNIQUE ("Code");
-- Modify "Nutritionist" table
ALTER TABLE "public"."Nutritionist" ADD COLUMN "Code" character varying(20) NULL, ADD CONSTRAINT "uni_Nutritionist_Code" UNIQUE ("Code");
-- Modify "Pharmacist" table
ALTER TABLE "public"."Pharmacist" ADD COLUMN "Code" character varying(20) NULL, ADD CONSTRAINT "uni_Pharmacist_Code" UNIQUE ("Code");
+3 -2
View File
@@ -1,4 +1,4 @@
h1:JmnFn6HtgFEjn6R7vQ/qii2smCP5Ye2B2JgnKEpkkLs=
h1:fAJxBGCfoMXYDjYBlq6RITZ/dXbqiYtQWwupcBMLHV0=
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
@@ -55,4 +55,5 @@ h1:JmnFn6HtgFEjn6R7vQ/qii2smCP5Ye2B2JgnKEpkkLs=
20251020062553.sql h1:Iw7hulcm5iRQlfW+ygA4iTPxLqkxx6h9vXMXEwUAHKs=
20251021041042.sql h1:wMgSivBV2A0NDcsLmKGIp0kMcVh2IODSG9b4dgzCaOM=
20251021075552.sql h1:8gfSMAglflNO6L0sSzxFNEubYN8/O4thT7OQT+WH+3M=
20251023044432.sql h1:nax2UtrrEp7vE3uFbUbsExTPCvFr5Hv44NEPPTXTMtA=
20251023044432.sql h1:MkvajJs3bfk9+wHvQ43/ccAluJEBARm1gWr1u92ccLA=
20251024034832.sql h1:x3s3VEVYLOSKLAFxJGb2+c1FyTMMvPE+9k4Ew7rKQaI=
@@ -0,0 +1,18 @@
package base
import (
ecore "simrs-vx/internal/domain/base-entities/core"
)
type Basic struct {
ecore.SmallMain // adjust this according to the needs
Division_Id *uint16 `json:"division_id"`
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
}
func (Basic) TableName() string {
return "DivisionPosition"
}
@@ -1,18 +1,13 @@
package divisionposition
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ed "simrs-vx/internal/domain/main-entities/division"
eb "simrs-vx/internal/domain/main-entities/division-position/base"
ee "simrs-vx/internal/domain/main-entities/employee"
)
type DivisionPosition struct {
ecore.SmallMain // adjust this according to the needs
Division_Id *uint16 `json:"division_id"`
Division *ed.Division `json:"division" gorm:"foreignKey:Division_Id;references:Id"`
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
eb.Basic
Division *ed.Division `json:"division" gorm:"foreignKey:Division_Id;references:Id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
}
@@ -2,13 +2,15 @@ package division
import (
ecore "simrs-vx/internal/domain/base-entities/core"
edpb "simrs-vx/internal/domain/main-entities/division-position/base"
)
type Division struct {
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Parent_Id *uint16 `json:"parent_id"`
Parent *Division `json:"parent" gorm:"foreignKey:Parent_Id;references:Id"`
Childrens []Division `json:"childrens" gorm:"foreignKey:Parent_Id"` // may need references to self
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Parent_Id *uint16 `json:"parent_id"`
Parent *Division `json:"parent" gorm:"foreignKey:Parent_Id;references:Id"`
Childrens []Division `json:"childrens" gorm:"foreignKey:Parent_Id"` // may need references to self
DivisionPositions []edpb.Basic `json:"divisionPositions,omitempty" gorm:"foreignKey:Division_Id;references:Id"`
}
@@ -10,6 +10,7 @@ import (
type Doctor struct {
ecore.Main // adjust this according to the needs
Code *string `json:"code" gorm:"unique;size:20"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
IHS_Number *string `json:"ihs_number" gorm:"unique;size:20"`
@@ -0,0 +1,20 @@
package base
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
)
type Basic struct {
ecore.SmallMain // adjust this according to the needs
Installation_Id *uint16 `json:"installation_id" gorm:"not null"`
Code string `json:"code" gorm:"unique;size:10;not null"`
Name string `json:"name" gorm:"size:30;not null"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
}
func (Basic) TableName() string {
return "InstallationPosition"
}
@@ -1,18 +1,11 @@
package installation_position
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
ei "simrs-vx/internal/domain/main-entities/installation"
eib "simrs-vx/internal/domain/main-entities/installation-position/base"
)
type InstallationPosition struct {
ecore.SmallMain // adjust this according to the needs
Installation_Id *uint16 `json:"installation_id" gorm:"not null"`
Installation *ei.Installation `json:"installation,omitempty" gorm:"foreignKey:Installation_Id;references:Id"`
Code string `json:"code" gorm:"unique;size:10;not null"`
Name string `json:"name" gorm:"size:30;not null"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
eib.Basic // adjust this according to the needs
Installation *ei.Installation `json:"installation,omitempty" gorm:"foreignKey:Installation_Id;references:Id"`
}
@@ -2,12 +2,14 @@ package installation
import (
ecore "simrs-vx/internal/domain/base-entities/core"
eipb "simrs-vx/internal/domain/main-entities/installation-position/base"
ere "simrs-vx/internal/domain/references/encounter"
)
type Installation struct {
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code" gorm:"size:10"`
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code" gorm:"size:10"`
InstallationPositions []eipb.Basic `json:"installationPositions,omitempty" gorm:"foreignKey:Installation_Id;references:Id"`
}
@@ -7,6 +7,7 @@ import (
type Laborant struct {
ecore.Main // adjust this according to the needs
Code *string `json:"code" gorm:"unique;size:20"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
IHS_Number *string `json:"ihs_number" gorm:"unique;size:20"`
@@ -7,6 +7,7 @@ import (
type Midwife struct {
ecore.Main // adjust this according to the needs
Code *string `json:"code" gorm:"unique;size:20"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
IHS_Number *string `json:"ihs_number" gorm:"unique;size:20"`
@@ -9,6 +9,7 @@ import (
type Nurse struct {
ecore.Main // adjust this according to the needs
Code *string `json:"code" gorm:"unique;size:20"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
IHS_Number *string `json:"ihs_number" gorm:"unique;size:20"`
@@ -7,6 +7,7 @@ import (
type Nutritionist struct {
ecore.Main // adjust this according to the needs
Code *string `json:"code" gorm:"unique;size:20"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
IHS_Number *string `json:"ihs_number" gorm:"unique;size:20"`
@@ -7,6 +7,7 @@ import (
type Pharmacist struct {
ecore.Main // adjust this according to the needs
Code *string `json:"code" gorm:"unique;size:20"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
IHS_Number *string `json:"ihs_number" gorm:"unique;size:20"`
@@ -0,0 +1,20 @@
package base
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
)
type Basic struct {
ecore.SmallMain // adjust this according to the needs
Specialist_Id *uint16 `json:"specialist_id" gorm:"not null"`
Code string `json:"code" gorm:"unique;size:10;not null"`
Name string `json:"name" gorm:"size:30;not null"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
}
func (Basic) TableName() string {
return "SpecialistPosition"
}
@@ -1,18 +1,11 @@
package specialist_position
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
es "simrs-vx/internal/domain/main-entities/specialist"
esb "simrs-vx/internal/domain/main-entities/specialist-position/base"
)
type SpecialistPosition struct {
ecore.SmallMain // adjust this according to the needs
Specialist_Id *uint16 `json:"specialist_id" gorm:"not null"`
Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id;references:Id"`
Code string `json:"code" gorm:"unique;size:10;not null"`
Name string `json:"name" gorm:"size:30;not null"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
esb.Basic
Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id;references:Id"`
}
@@ -2,13 +2,15 @@ package specialist
import (
ecore "simrs-vx/internal/domain/base-entities/core"
eub "simrs-vx/internal/domain/main-entities/specialist-position/base"
eu "simrs-vx/internal/domain/main-entities/unit"
)
type Specialist struct {
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Unit_Id *uint16 `json:"unit_id"`
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id"`
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Unit_Id *uint16 `json:"unit_id"`
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id"`
SpecialistPositions []eub.Basic `json:"specialistPositions,omitempty" gorm:"foreignKey:Specialist_Id;references:Id"`
}
@@ -0,0 +1,20 @@
package base
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
)
type Basic struct {
ecore.SmallMain // adjust this according to the needs
Subspecialist_Id *uint16 `json:"subspecialist_id" gorm:"not null"`
Code string `json:"code" gorm:"unique;size:10;not null"`
Name string `json:"name" gorm:"size:30;not null"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
}
func (Basic) TableName() string {
return "SubspecialistPosition"
}
@@ -1,18 +1,11 @@
package subspecialist_position
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
es "simrs-vx/internal/domain/main-entities/subspecialist"
esb "simrs-vx/internal/domain/main-entities/subspecialist-position/base"
)
type SubspecialistPosition struct {
ecore.SmallMain // adjust this according to the needs
Subspecialist_Id *uint16 `json:"subspecialist_id" gorm:"not null"`
Subspecialist *es.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Id;references:Id"`
Code string `json:"code" gorm:"unique;size:10;not null"`
Name string `json:"name" gorm:"size:30;not null"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
esb.Basic
Subspecialist *es.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Id;references:Id"`
}
@@ -3,12 +3,14 @@ package subspecialist
import (
ecore "simrs-vx/internal/domain/base-entities/core"
es "simrs-vx/internal/domain/main-entities/specialist"
espb "simrs-vx/internal/domain/main-entities/subspecialist-position/base"
)
type Subspecialist struct {
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Specialist_Id *uint16 `json:"specialist_id"`
Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id"`
ecore.SmallMain // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Specialist_Id *uint16 `json:"specialist_id"`
Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id"`
SubspecialistPositions []espb.Basic `json:"subspecialistPositions,omitempty" gorm:"foreignKey:Subspecialist_Id;references:Id"`
}
@@ -0,0 +1,18 @@
package base
import (
ecore "simrs-vx/internal/domain/base-entities/core"
)
type Basic struct {
ecore.SmallMain // adjust this according to the needs
Unit_Id *uint16 `json:"unit_id" gorm:"not null"`
Code string `json:"code" gorm:"unique;size:10;not null"`
Name string `json:"name" gorm:"size:30;not null"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
}
func (Basic) TableName() string {
return "UnitPosition"
}
@@ -1,18 +1,13 @@
package unit_position
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
eu "simrs-vx/internal/domain/main-entities/unit"
eub "simrs-vx/internal/domain/main-entities/unit-position/base"
)
type UnitPosition struct {
ecore.SmallMain // adjust this according to the needs
Unit_Id *uint16 `json:"unit_id" gorm:"not null"`
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id;references:Id"`
Code string `json:"code" gorm:"unique;size:10;not null"`
Name string `json:"name" gorm:"size:30;not null"`
HeadStatus bool `json:"headStatus"`
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
eub.Basic
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id;references:Id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
}
@@ -3,6 +3,7 @@ package unit
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ei "simrs-vx/internal/domain/main-entities/installation"
eub "simrs-vx/internal/domain/main-entities/unit-position/base"
ero "simrs-vx/internal/domain/references/organization"
)
@@ -13,4 +14,5 @@ type Unit struct {
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Type_Code *ero.UnitTypeCode `json:"type_code"`
UnitPositions []eub.Basic `json:"unitPositions,omitempty" gorm:"foreignKey:Unit_Id;references:Id"`
}