diff --git a/cmd/main-migration/migrations/20251106144745.sql b/cmd/main-migration/migrations/20251106144745.sql new file mode 100644 index 00000000..4e10ec66 --- /dev/null +++ b/cmd/main-migration/migrations/20251106144745.sql @@ -0,0 +1,26 @@ +-- Create "AuthPartner" table +CREATE TABLE "public"."AuthPartner" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Code" character varying(50) NULL, + "Name" character varying(100) NULL, + "SecretKey" character varying(255) NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_AuthPartner_Code" UNIQUE ("Code"), + CONSTRAINT "uni_AuthPartner_Name" UNIQUE ("Name") +); +-- Create "ExtUser" table +CREATE TABLE "public"."ExtUser" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Name" character varying(100) NULL, + "AuthPartner_Code" character varying(30) NULL, + "User_Name" character varying(50) NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_ExtUser_AuthPartner" FOREIGN KEY ("AuthPartner_Code") REFERENCES "public"."AuthPartner" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_ExtUser_User" FOREIGN KEY ("User_Name") REFERENCES "public"."User" ("Name") ON UPDATE NO ACTION ON DELETE NO ACTION +); diff --git a/cmd/main-migration/migrations/20251107012049.sql b/cmd/main-migration/migrations/20251107012049.sql new file mode 100644 index 00000000..42718253 --- /dev/null +++ b/cmd/main-migration/migrations/20251107012049.sql @@ -0,0 +1,15 @@ +-- Create "UserFes" table +CREATE TABLE "public"."UserFes" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Name" character varying(100) NULL, + "AuthPartner_Code" character varying(30) NULL, + "User_Name" character varying(50) NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_UserFes_AuthPartner" FOREIGN KEY ("AuthPartner_Code") REFERENCES "public"."AuthPartner" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_UserFes_User" FOREIGN KEY ("User_Name") REFERENCES "public"."User" ("Name") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Drop "ExtUser" table +DROP TABLE "public"."ExtUser"; diff --git a/cmd/main-migration/migrations/20251107064812.sql b/cmd/main-migration/migrations/20251107064812.sql new file mode 100644 index 00000000..2e5c78cf --- /dev/null +++ b/cmd/main-migration/migrations/20251107064812.sql @@ -0,0 +1,2 @@ +-- Modify "Room" table +ALTER TABLE "public"."Room" ADD COLUMN "Infra_Coode" character varying(10) NULL, ADD COLUMN "Unit_Code" character varying(10) NULL, ADD COLUMN "Specialist_Code" character varying(10) NULL, ADD COLUMN "Subspecialist_Code" character varying(10) NULL; diff --git a/cmd/main-migration/migrations/20251107064937.sql b/cmd/main-migration/migrations/20251107064937.sql new file mode 100644 index 00000000..d1111390 --- /dev/null +++ b/cmd/main-migration/migrations/20251107064937.sql @@ -0,0 +1,2 @@ +-- Rename a column from "Infra_Coode" to "Infra_Code" +ALTER TABLE "public"."Room" RENAME COLUMN "Infra_Coode" TO "Infra_Code"; diff --git a/cmd/main-migration/migrations/20251107071420.sql b/cmd/main-migration/migrations/20251107071420.sql new file mode 100644 index 00000000..a9727884 --- /dev/null +++ b/cmd/main-migration/migrations/20251107071420.sql @@ -0,0 +1,6 @@ +-- Modify "Infra" table +ALTER TABLE "public"."Infra" ADD COLUMN "Parent_Code" character varying(10) NULL, ADD COLUMN "Item_Code" character varying(50) NULL; +-- Create index "idx_Infra_Code" to table: "Infra" +CREATE UNIQUE INDEX "idx_Infra_Code" ON "public"."Infra" ("Code"); +-- Modify "Room" table +ALTER TABLE "public"."Room" DROP CONSTRAINT "fk_Room_Specialist", DROP CONSTRAINT "fk_Room_Subspecialist", DROP CONSTRAINT "fk_Room_Unit", DROP COLUMN "Infra_Id", DROP COLUMN "Unit_Id", DROP COLUMN "Specialist_Id", DROP COLUMN "Subspecialist_Id", ADD CONSTRAINT "fk_Room_Specialist" FOREIGN KEY ("Specialist_Code") REFERENCES "public"."Specialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Room_Subspecialist" FOREIGN KEY ("Subspecialist_Code") REFERENCES "public"."Subspecialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Room_Unit" FOREIGN KEY ("Unit_Code") REFERENCES "public"."Unit" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/cmd/main-migration/migrations/20251107074318.sql b/cmd/main-migration/migrations/20251107074318.sql new file mode 100644 index 00000000..5156b74e --- /dev/null +++ b/cmd/main-migration/migrations/20251107074318.sql @@ -0,0 +1,4 @@ +-- Modify "Nurse" table +ALTER TABLE "public"."Nurse" DROP CONSTRAINT "fk_Nurse_Infra"; +-- Modify "Infra" table +ALTER TABLE "public"."Infra" DROP CONSTRAINT "uni_Infra_Code"; diff --git a/cmd/main-migration/migrations/20251107075050.sql b/cmd/main-migration/migrations/20251107075050.sql new file mode 100644 index 00000000..fee27fee --- /dev/null +++ b/cmd/main-migration/migrations/20251107075050.sql @@ -0,0 +1,4 @@ +-- Modify "Nurse" table +ALTER TABLE "public"."Nurse" ADD CONSTRAINT "fk_Nurse_Infra" FOREIGN KEY ("Infra_Code") REFERENCES "public"."Infra" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Modify "Room" table +ALTER TABLE "public"."Room" ADD CONSTRAINT "fk_Room_Infra" FOREIGN KEY ("Infra_Code") REFERENCES "public"."Infra" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/cmd/main-migration/migrations/20251107080604.sql b/cmd/main-migration/migrations/20251107080604.sql new file mode 100644 index 00000000..246be1fa --- /dev/null +++ b/cmd/main-migration/migrations/20251107080604.sql @@ -0,0 +1,2 @@ +-- Modify "Item" table +ALTER TABLE "public"."Item" ADD COLUMN "Infra_Code" character varying(10) NULL; diff --git a/cmd/main-migration/migrations/20251107081830.sql b/cmd/main-migration/migrations/20251107081830.sql new file mode 100644 index 00000000..a7490211 --- /dev/null +++ b/cmd/main-migration/migrations/20251107081830.sql @@ -0,0 +1,6 @@ +-- Modify "Device" table +ALTER TABLE "public"."Device" ADD COLUMN "Infra_Code" character varying(10) NULL, ADD COLUMN "Item_Code" character varying(50) NULL; +-- Modify "Material" table +ALTER TABLE "public"."Material" ADD COLUMN "Infra_Code" character varying(10) NULL, ADD COLUMN "Item_Code" character varying(50) NULL; +-- Modify "Medicine" table +ALTER TABLE "public"."Medicine" ADD COLUMN "Infra_Code" character varying(10) NULL, ADD COLUMN "Item_Code" character varying(50) NULL; diff --git a/cmd/main-migration/migrations/20251107091033.sql b/cmd/main-migration/migrations/20251107091033.sql new file mode 100644 index 00000000..dc0a8f60 --- /dev/null +++ b/cmd/main-migration/migrations/20251107091033.sql @@ -0,0 +1,4 @@ +-- Modify "Infra" table +ALTER TABLE "public"."Infra" ALTER COLUMN "Code" SET NOT NULL; +-- Modify "Item" table +ALTER TABLE "public"."Item" DROP COLUMN "Infra_Id"; diff --git a/cmd/main-migration/migrations/20251107091209.sql b/cmd/main-migration/migrations/20251107091209.sql new file mode 100644 index 00000000..d10ae684 --- /dev/null +++ b/cmd/main-migration/migrations/20251107091209.sql @@ -0,0 +1,2 @@ +-- Modify "Infra" table +ALTER TABLE "public"."Infra" DROP CONSTRAINT "fk_Infra_Childrens", DROP CONSTRAINT "fk_Infra_Item", DROP COLUMN "Parent_Id", ADD CONSTRAINT "fk_Infra_Childrens" FOREIGN KEY ("Parent_Code") REFERENCES "public"."Infra" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Infra_Item" FOREIGN KEY ("Item_Code") REFERENCES "public"."Item" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/cmd/main-migration/migrations/20251107091541.sql b/cmd/main-migration/migrations/20251107091541.sql new file mode 100644 index 00000000..a3445d0c --- /dev/null +++ b/cmd/main-migration/migrations/20251107091541.sql @@ -0,0 +1,2 @@ +-- Modify "Infra" table +ALTER TABLE "public"."Infra" DROP COLUMN "Item_Id"; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index dc9df4a2..30f9fd3c 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:Jut0rnI38bZU7g1hei5bIcYGzWrt4KxfWzasGJcbwi0= +h1:6umIsneejLUg0V9wUaB2HuCvEHD+2v/dwbxg+y23+wo= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -75,11 +75,23 @@ h1:Jut0rnI38bZU7g1hei5bIcYGzWrt4KxfWzasGJcbwi0= 20251106040137.sql h1:ppcqkVoT0o9jZcjI/TN7LuaPxXhJQhnIXEJtloP/46o= 20251106041333.sql h1:2JkxyelQ/EeB+boL5bfpnzefw32ttEGKvKchtQjWmAU= 20251106042006.sql h1:ruppYa1kAJQUU3ufQBbKGMcXrGbGJJiRPclT+dNc/YQ= -20251106050412.sql h1:MiEMJ1HCFYnalKuq3Z38xJeogfBAMqsTv2sG4EF8dDw= -20251106063418.sql h1:y3veDJPjKekOWLCZek/LgQwXPRhZtOppTfUXiqoL95s= -20251106071906.sql h1:/TUZA3XpMY23qEJXdkTwlzrNMvSSl6JJniPcgAttBaw= -20251106073157.sql h1:78txeibJ602DMD7huD618ZSMt6phSRzDNPTlo0PGyrc= -20251106074218.sql h1:8Xz7WywrtUnSxOHhlal53gG9rE7r86LFUt5zBFe/mIs= -20251106081846.sql h1:jp91Bf5bxGXMiUB1VIuN6y768vb2iWwow44WfCE5J5k= -20251106082844.sql h1:RHYzRO4G1fSWwf+xc/3QezZ/Iil67cZPIgNpNz3TNhQ= -20251106090021.sql h1:dFDk6mq+zjbYWmfWIrHf9DiKvvoXHjrr0++zssMTWP8= +20251106050412.sql h1:1002KYtHd8AwrQTMewbs/PPHDylHDghigE/3S7PVdMA= +20251106063418.sql h1:jPW/gBnbFl4RO39lQ0ZMDtYA6xbhyD6CgQupT50HmaY= +20251106071906.sql h1:leYGKxR3EQn794aOehf0sd/ZPmOnvBMZPy5/anGmRB4= +20251106073157.sql h1:KASMzjjjk5UB7Zj8lCRtM1utc4ZnDjlnpZbtTe3vONE= +20251106074218.sql h1:Z5q5deOvLaZDPhiVTN9st3/s56RepBa2YOyrMXBdj4A= +20251106081846.sql h1:P+VsWwhGt60adDIZuE/Aa38JVp/yX1rnsdpXpxASodw= +20251106082844.sql h1:Dmi5A8i9frQZvdXYPwc7f8CisZtBH8liSXq1rI6z1iM= +20251106090021.sql h1:4JwdKgO8T46YhyWVJUxpRIwudBDlG8QN1brSOYmgQ20= +20251106144745.sql h1:nqnQCzGrVJaq8ilOEOGXeRUL1dolj+OPWKuP8A92FRA= +20251107012049.sql h1:Pff4UqltGS3clSlGr0qq8CQM56L29wyxY0FC/N/YAhU= +20251107064812.sql h1:jjpcAi0B/geEOKWmmR6+1UhWMhjstWhWQcz9lUWrtTY= +20251107064937.sql h1:1nPu0THBf+YquFIJSE4pc1dA7r3EydH92cpp26ozysw= +20251107071420.sql h1:Q+e+OqjdiuK/sghDQ5NxjU+u2zYl+vh/eRBlUz9Idhg= +20251107074318.sql h1:VbOWMw2rClEWgMnDSejXPqXkFoQ4odVsHn3/UAEiCYA= +20251107075050.sql h1:ZZaKJEWXIJ94/0/2Gzzz+HXjmebEs5eP8iUIot26/c8= +20251107080604.sql h1:aq+tINa0ULCZlJcUK2jaeGh6rRH4jJz3e2NrK47m0Ec= +20251107081830.sql h1:Bl9kniyLWeMqd3nrvgCgiUpdcJWp8qX1F41JAM1WbiE= +20251107091033.sql h1:ETTCaAHBT6wipXrEGXIepxLMdD2LNzprPAp99+jnW0w= +20251107091209.sql h1:BUI9JlTzZxCdVHsrRbOye7m47AJEvXNhCaCVv/HzILs= +20251107091541.sql h1:/tW2uXv/o0Q2E4lQzlYNgEftvDqjf3c2AQpZ83Vb6zc= diff --git a/internal/domain/main-entities/auth-partner/dto.go b/internal/domain/main-entities/auth-partner/dto.go index 651ca4b7..2b1589fb 100644 --- a/internal/domain/main-entities/auth-partner/dto.go +++ b/internal/domain/main-entities/auth-partner/dto.go @@ -15,6 +15,7 @@ type ReadListDto struct { FilterDto Includes string `json:"includes"` Pagination ecore.Pagination + Sort string `json:"sort"` } type FilterDto struct { @@ -23,7 +24,9 @@ type FilterDto struct { } type ReadDetailDto struct { - Id uint16 `json:"id"` + Id *uint16 `json:"id"` + Code *string `json:"code"` + Includes string `json:"includes"` } type UpdateDto struct { diff --git a/internal/domain/main-entities/auth-partner/entity.go b/internal/domain/main-entities/auth-partner/entity.go index 3a8cf4e6..b4ad8e49 100644 --- a/internal/domain/main-entities/auth-partner/entity.go +++ b/internal/domain/main-entities/auth-partner/entity.go @@ -6,7 +6,7 @@ import ( type AuthPartner struct { ecore.Main // adjust this according to the needs - Code string `json:"code" gorm:"size:50"` - Name string `json:"name" gorm:"size:100"` + Code string `json:"code" gorm:"unique;size:50"` + Name string `json:"name" gorm:"unique;size:100"` SecretKey string `json:"secretKey" gorm:"size:255"` } diff --git a/internal/domain/main-entities/device/dto.go b/internal/domain/main-entities/device/dto.go index 1c874576..36e90a0c 100644 --- a/internal/domain/main-entities/device/dto.go +++ b/internal/domain/main-entities/device/dto.go @@ -8,11 +8,11 @@ import ( ) type CreateDto struct { - Code string `json:"code" validate:"maxLength=10"` - Name string `json:"name" validate:"maxLength=50"` - Uom_Code string `json:"uom_code" validate:"maxLength=10"` - Infra_Id *uint16 `json:"infra_id"` - Item_Id *uint `json:"item_id"` + Code string `json:"code" validate:"maxLength=10"` + Name string `json:"name" validate:"maxLength=50"` + Uom_Code string `json:"uom_code" validate:"maxLength=10"` + Infra_Code *string `json:"infra_code"` + Item_Code *string `json:"item_code"` } type ReadListDto struct { @@ -32,17 +32,18 @@ type FilterDto struct { } type ReadDetailDto struct { - Id uint16 `json:"id"` + Id *uint16 `json:"id"` Code *string `json:"code"` } type UpdateDto struct { - Id uint `json:"id"` + Id *uint `json:"id"` CreateDto } type DeleteDto struct { - Id uint `json:"id"` + Id *uint `json:"id"` + Code *string `json:"code"` } type MetaDto struct { diff --git a/internal/domain/main-entities/device/entity.go b/internal/domain/main-entities/device/entity.go index ca54c08d..c68b7c3e 100644 --- a/internal/domain/main-entities/device/entity.go +++ b/internal/domain/main-entities/device/entity.go @@ -14,7 +14,9 @@ type Device struct { Uom_Code string `json:"uom_code" gorm:"size:10"` Uom *eu.Uom `json:"uom,omitempty" gorm:"foreignKey:Uom_Code;references:Code"` Infra_Id *uint16 `json:"infra_id"` + Infra_Code *string `json:"infra_code" gorm:"size:10"` Infra *ein.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Id;references:Id"` Item_Id *uint `json:"item_id"` + Item_Code *string `json:"item_code" gorm:"size:50"` Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"` } diff --git a/internal/domain/main-entities/infra/dto.go b/internal/domain/main-entities/infra/dto.go index de566fad..dfe271e5 100644 --- a/internal/domain/main-entities/infra/dto.go +++ b/internal/domain/main-entities/infra/dto.go @@ -9,15 +9,15 @@ import ( ) type CreateDto struct { - Code string `json:"code" validate:"maxLength=10"` - Name string `json:"name" validate:"maxLength=50"` - InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code" validate:"maxLength=15"` - Parent_Id *uint16 `json:"parent_id"` - Item_Id *uint `json:"item_id"` - Unit_Id *uint16 `json:"unit_id"` - Specialist_Id *uint16 `json:"specialist_id"` - Subspecialist_Id *uint16 `json:"subspecialist_id"` - Infra_Id *uint16 `json:"-"` // for room + Code string `json:"code" validate:"maxLength=10"` + Name string `json:"name" validate:"maxLength=50"` + InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code" validate:"maxLength=15"` + Parent_Code *string `json:"parent_code"` + Item_Code *string `json:"-"` + Unit_Code *string `json:"unit_code"` + Specialist_Code *string `json:"specialist_code"` + Subspecialist_Code *string `json:"subspecialist_code"` + Infra_Code *string `json:"infra_code"` // for room } type ReadListDto struct { @@ -32,24 +32,25 @@ type FilterDto struct { Code string `json:"code"` Name string `json:"name"` InfraGroup_Code ero.InfraGroupCode `json:"infraGroup-code"` - Parent_Id *uint16 `json:"parent-id"` - Item_Id *uint `json:"item-id"` + Parent_Code *string `json:"parent-code"` + Item_Id *string `json:"item-code"` Search string `json:"search" gormhelper:"searchColumns=Code,Name"` } type ReadDetailDto struct { - Id uint16 `json:"id"` - Code *string `json:"code"` - Item_Id *uint `json:"item_id"` + Id *uint16 `json:"id"` + Code *string `json:"code"` + Item_Code *string `json:"item_code"` } type UpdateDto struct { - Id uint16 `json:"id"` + Id *uint16 `json:"id"` CreateDto } type DeleteDto struct { - Id uint16 `json:"id"` + Id *uint16 `json:"id"` + Code *string `json:"code"` } type MetaDto struct { @@ -63,10 +64,10 @@ type ResponseDto struct { Code string `json:"code"` Name string `json:"name"` InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code"` - Parent_Id *uint16 `json:"parent_id"` + Parent_Code *string `json:"parent_code"` Parent *Infra `json:"parent,omitempty"` Childrens []Infra `json:"childrens,omitempty"` - Item_Id *uint `json:"item_id"` + Item_Code *string `json:"item_code"` Item *ei.Item `json:"item,omitempty"` Rooms []erb.Basic `json:"rooms,omitempty"` } @@ -76,12 +77,12 @@ func (d Infra) ToResponse() ResponseDto { Code: d.Code, Name: d.Name, InfraGroup_Code: d.InfraGroup_Code, - Parent_Id: d.Parent_Id, - Parent: d.Parent, - Childrens: d.Childrens, - Item_Id: d.Item_Id, - Item: d.Item, - Rooms: d.Rooms, + Parent_Code: d.Parent_Code, + // Parent: d.Parent, + Childrens: d.Childrens, + Item_Code: d.Item_Code, + Item: d.Item, + Rooms: d.Rooms, } resp.SmallMain = d.SmallMain return resp diff --git a/internal/domain/main-entities/infra/entity.go b/internal/domain/main-entities/infra/entity.go index 3d8c6f99..51cc8eaa 100644 --- a/internal/domain/main-entities/infra/entity.go +++ b/internal/domain/main-entities/infra/entity.go @@ -3,6 +3,7 @@ package infra import ( ecore "simrs-vx/internal/domain/base-entities/core" ei "simrs-vx/internal/domain/main-entities/item" + erb "simrs-vx/internal/domain/main-entities/room/base" ero "simrs-vx/internal/domain/references/organization" @@ -10,13 +11,13 @@ import ( type Infra struct { ecore.SmallMain // adjust this according to the needs - Code string `json:"code" gorm:"unique;size:10"` + Code string `json:"code" gorm:"uniqueIndex;size:10;not null"` Name string `json:"name" gorm:"size:50"` InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code" gorm:"size:15"` - Parent_Id *uint16 `json:"parent_id"` - Parent *Infra `json:"parent" gorm:"foreignKey:Parent_Id;references:Id"` - Childrens []Infra `json:"childrens" gorm:"foreignKey:Parent_Id"` // may need references to self - Item_Id *uint `json:"item_id"` - Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"` - Rooms []erb.Basic `json:"rooms" gorm:"foreignKey:Infra_Id"` + Parent_Code *string `json:"parent_code" gorm:"size:10"` + Parent *Infra `json:"parent" gorm:"foreignKey:Parent_Code;references:Code"` + Childrens []Infra `json:"childrens" gorm:"foreignKey:Parent_Code;references:Code"` + Item_Code *string `json:"item_code" gorm:"size:50"` + Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Code;references:Code"` + Rooms []erb.Basic `json:"rooms" gorm:"foreignKey:Infra_Code;references:Code"` } diff --git a/internal/domain/main-entities/item/dto.go b/internal/domain/main-entities/item/dto.go index 22be4c1a..f20ce217 100644 --- a/internal/domain/main-entities/item/dto.go +++ b/internal/domain/main-entities/item/dto.go @@ -11,7 +11,7 @@ type CreateDto struct { Name string `json:"name" validate:"maxLength=100"` ItemGroup_Code ero.ItemGroupCode `json:"itemGroup_code" validate:"maxLength=10"` Uom_Code *string `json:"uom_code" validate:"maxLength=10"` - Infra_Id *uint16 `json:"infra_id"` + Infra_Code *string `json:"infra_code"` Stock *int `json:"stock"` } @@ -27,23 +27,24 @@ type FilterDto struct { Name string `json:"name"` ItemGroup_Code ero.ItemGroupCode `json:"itemGroup-code"` Uom_Code *string `json:"uom-code"` - Infra_Id *uint16 `json:"infra-id"` + Infra_Code *string `json:"infra-code"` Stock *int `json:"stock"` Search string `json:"search" gormhelper:"searchColumns=Code,Name"` } type ReadDetailDto struct { - Id uint16 `json:"id"` + Id *uint16 `json:"id"` Code *string `json:"code"` } type UpdateDto struct { - Id uint `json:"id"` + Id *uint `json:"id"` CreateDto } type DeleteDto struct { - Id uint `json:"id"` + Id *uint `json:"id"` + Code *string `json:"code"` } type MetaDto struct { @@ -59,7 +60,7 @@ type ResponseDto struct { ItemGroup_Code ero.ItemGroupCode `json:"itemGroup_code"` Uom_Code *string `json:"uom_code"` Uom *eu.Uom `json:"uom,omitempty"` - Infra_Id *uint16 `json:"infra_id"` + Infra_Code *string `json:"infra_code"` Stock *int `json:"stock"` } @@ -70,7 +71,7 @@ func (d Item) ToResponse() ResponseDto { ItemGroup_Code: d.ItemGroup_Code, Uom_Code: d.Uom_Code, Uom: d.Uom, - Infra_Id: d.Infra_Id, + Infra_Code: d.Infra_Code, Stock: d.Stock, } resp.Main = d.Main diff --git a/internal/domain/main-entities/item/entity.go b/internal/domain/main-entities/item/entity.go index e0ff4e21..fc721713 100644 --- a/internal/domain/main-entities/item/entity.go +++ b/internal/domain/main-entities/item/entity.go @@ -14,6 +14,6 @@ type Item struct { ItemGroup_Code ero.ItemGroupCode `json:"itemGroup_code" gorm:"size:15"` Uom_Code *string `json:"uom_code" gorm:"size:10"` Uom *eu.Uom `json:"uom,omitempty" gorm:"foreignKey:Uom_Code;references:Code"` - Infra_Id *uint16 `json:"infra_id"` + Infra_Code *string `json:"infra_code" gorm:"size:10"` Stock *int `json:"stock"` } diff --git a/internal/domain/main-entities/material/dto.go b/internal/domain/main-entities/material/dto.go index 18a93723..fbedbf43 100644 --- a/internal/domain/main-entities/material/dto.go +++ b/internal/domain/main-entities/material/dto.go @@ -8,12 +8,12 @@ import ( ) type CreateDto struct { - Code string `json:"code" validate:"maxLength=10"` - Name string `json:"name" validate:"maxLength=50"` - Uom_Code string `json:"uom_code" validate:"maxLength=10"` - Infra_Id *uint16 `json:"infra_id"` - Stock *int `json:"stock"` - Item_Id *uint `json:"item_id"` + Code string `json:"code" validate:"maxLength=10"` + Name string `json:"name" validate:"maxLength=50"` + Uom_Code string `json:"uom_code" validate:"maxLength=10"` + Infra_Code *string `json:"infra_code"` + Stock *int `json:"stock"` + Item_Code *string `json:"item_code"` } type ReadListDto struct { @@ -24,28 +24,29 @@ type ReadListDto struct { } type FilterDto struct { - Code string `json:"code"` - Name string `json:"name"` - Uom_Code string `json:"uom-code"` - Infra_Id *uint16 `json:"infra-id"` - Stock *int `json:"stock"` - Item_Id *uint `json:"item-id"` - Search string `json:"search" gormhelper:"searchColumns=Code,Name"` + Code string `json:"code"` + Name string `json:"name"` + Uom_Code string `json:"uom-code"` + Infra_Code *string `json:"infra-code"` + Stock *int `json:"stock"` + Item_Code *string `json:"item-code"` + Search string `json:"search" gormhelper:"searchColumns=Code,Name"` } type ReadDetailDto struct { - Id uint16 `json:"id"` + Id *uint16 `json:"id"` Code *string `json:"code"` Item_Id *uint `json:"item_id"` } type UpdateDto struct { - Id uint `json:"id"` + Id *uint `json:"id"` CreateDto } type DeleteDto struct { - Id uint `json:"id"` + Id *uint `json:"id"` + Code *string `json:"code"` } type MetaDto struct { @@ -56,28 +57,28 @@ type MetaDto struct { type ResponseDto struct { ecore.Main - Code string `json:"code"` - Name string `json:"name"` - Uom_Code string `json:"uom_code"` - Uom *eu.Uom `json:"uom,omitempty"` - Infra_Id *uint16 `json:"infra_id"` - Infra *ein.Infra `json:"infra,omitempty"` - Stock *int `json:"stock"` - Item_Id *uint `json:"item_id"` - Item *ei.Item `json:"item,omitempty"` + Code string `json:"code"` + Name string `json:"name"` + Uom_Code string `json:"uom_code"` + Uom *eu.Uom `json:"uom,omitempty"` + Infra_Code *string `json:"infra_code"` + Infra *ein.Infra `json:"infra,omitempty"` + Stock *int `json:"stock"` + Item_Code *string `json:"item_code"` + Item *ei.Item `json:"item,omitempty"` } func (d Material) ToResponse() ResponseDto { resp := ResponseDto{ - Code: d.Code, - Name: d.Name, - Uom_Code: d.Uom_Code, - Uom: d.Uom, - Infra_Id: d.Infra_Id, - Infra: d.Infra, - Stock: d.Stock, - Item_Id: d.Item_Id, - Item: d.Item, + Code: d.Code, + Name: d.Name, + Uom_Code: d.Uom_Code, + Uom: d.Uom, + Infra_Code: d.Infra_Code, + Infra: d.Infra, + Stock: d.Stock, + Item_Code: d.Item_Code, + Item: d.Item, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/material/entity.go b/internal/domain/main-entities/material/entity.go index cdfd8bfd..50e6907e 100644 --- a/internal/domain/main-entities/material/entity.go +++ b/internal/domain/main-entities/material/entity.go @@ -14,8 +14,10 @@ type Material struct { Uom_Code string `json:"uom_code" gorm:"size:10"` Uom *eu.Uom `json:"uom,omitempty" gorm:"foreignKey:Uom_Code;references:Code"` Infra_Id *uint16 `json:"infra_id"` + Infra_Code *string `json:"infra_code" gorm:"size:10"` Infra *ein.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Id;references:Id"` Stock *int `json:"stock"` Item_Id *uint `json:"item_id"` + Item_Code *string `json:"item_code" gorm:"size:50"` Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"` } diff --git a/internal/domain/main-entities/medicine/dto.go b/internal/domain/main-entities/medicine/dto.go index 82431fc1..945db1e5 100644 --- a/internal/domain/main-entities/medicine/dto.go +++ b/internal/domain/main-entities/medicine/dto.go @@ -16,9 +16,9 @@ type CreateDto struct { MedicineMethod_Code *string `json:"medicineMethod_code" validate:"maxLength=10"` Uom_Code *string `json:"uom_code" validate:"maxLength=10"` Dose uint8 `json:"dose"` - Infra_Id *uint16 `json:"infra_id"` + Infra_Code *string `json:"infra_code"` Stock *int `json:"stock"` - Item_Id *uint `json:"item_id"` + Item_Code *string `json:"item_code"` } type ReadListDto struct { @@ -35,25 +35,26 @@ type FilterDto struct { MedicineMethod_Code *string `json:"medicineMethod-code"` Uom_Code *string `json:"uom-code"` Dose uint8 `json:"dose"` - Infra_Id *uint16 `json:"infra-id"` + Infra_Code *string `json:"infra-code"` Stock *int `json:"stock"` - Item_Id *uint `json:"item-id"` + Item_Code *string `json:"item-code"` Search string `json:"search" gormhelper:"searchColumns=Code,Name"` } type ReadDetailDto struct { - Id uint16 `json:"id"` - Code *string `json:"code"` - Item_Id *uint `json:"item_id"` + Id *uint16 `json:"id"` + Code *string `json:"code"` + Item_Code *uint `json:"item_code"` } type UpdateDto struct { - Id uint `json:"id"` + Id *uint `json:"id"` CreateDto } type DeleteDto struct { - Id uint `json:"id"` + Id *uint `json:"id"` + Code *string `json:"code"` } type MetaDto struct { @@ -73,10 +74,10 @@ type ResponseDto struct { Uom_Code *string `json:"uom_code"` Uom *eu.Uom `json:"uom"` Dose uint8 `json:"dose"` - Infra_Id *uint16 `json:"infra_id"` + Infra_Code *string `json:"infra_code"` Infra *ein.Infra `json:"infra,omitempty"` Stock *int `json:"stock"` - Item_Id *uint `json:"item_id"` + Item_Code *string `json:"item_code"` Item *eit.Item `json:"item,omitempty"` } @@ -91,10 +92,10 @@ func (d Medicine) ToResponse() ResponseDto { Uom_Code: d.Uom_Code, Uom: d.Uom, Dose: d.Dose, - Infra_Id: d.Infra_Id, + Infra_Code: d.Infra_Code, Infra: d.Infra, Stock: d.Stock, - Item_Id: d.Item_Id, + Item_Code: d.Item_Code, Item: d.Item, } resp.Main = d.Main diff --git a/internal/domain/main-entities/medicine/entity.go b/internal/domain/main-entities/medicine/entity.go index d538f496..bbcfec78 100644 --- a/internal/domain/main-entities/medicine/entity.go +++ b/internal/domain/main-entities/medicine/entity.go @@ -21,8 +21,10 @@ type Medicine struct { Uom *eu.Uom `json:"uom" gorm:"foreignKey:Uom_Code;references:Code"` Dose uint8 `json:"dose"` Infra_Id *uint16 `json:"infra_id"` + Infra_Code *string `json:"infra_code" gorm:"size:10"` Infra *ein.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Id;references:Id"` Stock *int `json:"stock"` Item_Id *uint `json:"item_id"` + Item_Code *string `json:"item_code" gorm:"size:50"` Item *eit.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"` } diff --git a/internal/domain/main-entities/room/base/entity.go b/internal/domain/main-entities/room/base/entity.go index e45a441d..d5651ac9 100644 --- a/internal/domain/main-entities/room/base/entity.go +++ b/internal/domain/main-entities/room/base/entity.go @@ -8,14 +8,14 @@ import ( ) type Basic struct { - ecore.SmallMain // adjust this according to the needs - Infra_Id *uint16 `json:"infra_id"` - Unit_Id *uint16 `json:"unit_id"` - Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id"` - Specialist_Id *uint16 `json:"specialist_id"` - Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id"` - Subspecialist_Id *uint16 `json:"subspecialist_id"` - Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Id"` + ecore.SmallMain // adjust this according to the needs + Infra_Code *string `json:"infra_code" gorm:"size:10"` + Unit_Code *string `json:"unit_code" gorm:"size:10"` + Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Code;references:Code"` + Specialist_Code *string `json:"specialist_code" gorm:"size:10"` + Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Code;references:Code"` + Subspecialist_Code *string `json:"subspecialist_code" gorm:"size:10"` + Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Code;references:Code"` } func (Basic) TableName() string { diff --git a/internal/domain/main-entities/room/dto.go b/internal/domain/main-entities/room/dto.go index 0ca2e8d4..2ff41c3a 100644 --- a/internal/domain/main-entities/room/dto.go +++ b/internal/domain/main-entities/room/dto.go @@ -9,10 +9,10 @@ import ( ) type CreateDto struct { - Infra_Id *uint16 `json:"infra_id"` - Unit_Id *uint16 `json:"unit_id"` - Specialist_Id *uint16 `json:"specialist_id"` - Subspecialist_Id *uint16 `json:"subspecialist_id"` + Infra_Code *string `json:"infra_code"` + Unit_Code *string `json:"unit_code"` + Specialist_Code *string `json:"specialist_code"` + Subspecialist_Code *string `json:"subspecialist_code"` } type ReadListDto struct { @@ -22,10 +22,10 @@ type ReadListDto struct { } type FilterDto struct { - Infra_Id *uint16 `json:"infra-id"` - Unit_Id *uint16 `json:"unit-id"` - Specialist_Id *uint16 `json:"specialist-id"` - Subspecialist_Id *uint16 `json:"subspecialist-id"` + Infra_Code *string `json:"infra-code"` + Unit_Code *string `json:"unit-code"` + Specialist_Code *string `json:"specialist-code"` + Subspecialist_Code *string `json:"subspecialist-code"` } type ReadDetailDto struct { @@ -49,26 +49,26 @@ type MetaDto struct { type ResponseDto struct { ecore.SmallMain - Infra_Id *uint16 `json:"infra_id"` - Infra *ei.Infra `json:"infra,omitempty"` - Unit_Id *uint16 `json:"unit_id"` - Unit *eu.Unit `json:"unit,omitempty"` - Specialist_Id *uint16 `json:"specialist_id"` - Specialist *es.Specialist `json:"specialist,omitempty"` - Subspecialist_Id *uint16 `json:"subspecialist_id"` - Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty"` + Infra_Code *string `json:"infra_code"` + Infra *ei.Infra `json:"infra,omitempty"` + Unit_Code *string `json:"unit_code"` + Unit *eu.Unit `json:"unit,omitempty"` + Specialist_Code *string `json:"specialist_code"` + Specialist *es.Specialist `json:"specialist,omitempty"` + Subspecialist_Code *string `json:"subspecialist_code"` + Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty"` } func (d Room) ToResponse() ResponseDto { resp := ResponseDto{ - Infra_Id: d.Infra_Id, - Infra: d.Infra, - Unit_Id: d.Unit_Id, - Unit: d.Unit, - Specialist_Id: d.Specialist_Id, - Specialist: d.Specialist, - Subspecialist_Id: d.Subspecialist_Id, - Subspecialist: d.Subspecialist, + Infra_Code: d.Infra_Code, + Infra: d.Infra, + Unit_Code: d.Unit_Code, + Unit: d.Unit, + Specialist_Code: d.Specialist_Code, + Specialist: d.Specialist, + Subspecialist_Code: d.Subspecialist_Code, + Subspecialist: d.Subspecialist, } resp.SmallMain = d.SmallMain return resp diff --git a/internal/domain/main-entities/room/entity.go b/internal/domain/main-entities/room/entity.go index 346c7741..49fb8cc6 100644 --- a/internal/domain/main-entities/room/entity.go +++ b/internal/domain/main-entities/room/entity.go @@ -7,5 +7,5 @@ import ( type Room struct { ebase.Basic - Infra *ei.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Id"` + Infra *ei.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Code;references:Code"` } diff --git a/internal/domain/main-entities/ext-user/dto.go b/internal/domain/main-entities/user-fes/dto.go similarity index 62% rename from internal/domain/main-entities/ext-user/dto.go rename to internal/domain/main-entities/user-fes/dto.go index 4b434c55..6cb3636b 100644 --- a/internal/domain/main-entities/ext-user/dto.go +++ b/internal/domain/main-entities/user-fes/dto.go @@ -1,4 +1,5 @@ -package extuser +// FES = From External Source +package userfes import ( // internal - domain - main-entities @@ -16,16 +17,19 @@ type ReadListDto struct { FilterDto Includes string `json:"includes"` Pagination ecore.Pagination + Sort string `json:"sort"` } type FilterDto struct { Name *string `json:"name"` AuthPartner_Code *string `json:"authPartner_code"` User_Name *string `json:"user_name"` + Includes string `json:"includes"` } type ReadDetailDto struct { - Id uint `json:"id"` + Id uint `json:"id"` + Includes string `json:"includes"` } type UpdateDto struct { @@ -45,27 +49,27 @@ type MetaDto struct { type ResponseDto struct { ecore.Main - Name string `json:"name"` - AuthPartner_Code string `json:"authPartner_code"` - AuthPartner *eap.AuthPartner `json:"authPartner,omitempty"` - User_Name string `json:"user_name"` + Name string `json:"name"` + AuthPartner_Code string `json:"authPartner_code"` + AuthPartner *eap.AuthPartner `json:"authPartner,omitempty"` + User_Name string `json:"user_name"` } -func (d ExtUser) ToResponse() ResponseDto { +func (d UserFes) ToResponse() ResponseDto { resp := ResponseDto{ - Name: d.Name, - AuthPartner_Code: d.AuthPartner_Code, - AuthPartner: d.AuthPartner, - User_Name: d.User_Name, + Name: d.Name, + AuthPartner_Code: d.AuthPartner_Code, + AuthPartner: d.AuthPartner, + User_Name: d.User_Name, } resp.Main = d.Main return resp } -func ToResponseList(data []ExtUser) []ResponseDto { +func ToResponseList(data []UserFes) []ResponseDto { resp := make([]ResponseDto, len(data)) for i, u := range data { resp[i] = u.ToResponse() } return resp -} \ No newline at end of file +} diff --git a/internal/domain/main-entities/ext-user/entity.go b/internal/domain/main-entities/user-fes/entity.go similarity index 90% rename from internal/domain/main-entities/ext-user/entity.go rename to internal/domain/main-entities/user-fes/entity.go index ae293667..7356166c 100644 --- a/internal/domain/main-entities/ext-user/entity.go +++ b/internal/domain/main-entities/user-fes/entity.go @@ -1,4 +1,5 @@ -package extuser +// FES = From External Source +package userfes import ( ecore "simrs-vx/internal/domain/base-entities/core" @@ -6,7 +7,7 @@ import ( eau "simrs-vx/internal/domain/main-entities/user" ) -type ExtUser struct { +type UserFes struct { ecore.Main // adjust this according to the needs Name string `json:"name" gorm:"size:100"` AuthPartner_Code string `json:"authPartner_code" gorm:"size:30"` diff --git a/internal/domain/references/clinical/clinical.go b/internal/domain/references/clinical/clinical.go index 01d0461c..c5d949e2 100644 --- a/internal/domain/references/clinical/clinical.go +++ b/internal/domain/references/clinical/clinical.go @@ -25,6 +25,7 @@ type ( ) const ( + SCDetail SubjectCode = "detail" // Detail SCPrimaryComplain SubjectCode = "pri-complain" // Keluhan Utama SCSecComplain SubjectCode = "sec-complain" // Secondary Complaint SCCurrentDiseaseHistory SubjectCode = "cur-disea-hist" // Current Disease History @@ -35,6 +36,7 @@ const ( SCMedicationHistory SubjectCode = "med-hist" // Medication History SCBloodType SubjectCode = "blood-type" // Blood Type + Detail ObjectCode = "detail" // Detail OCConsciousnessLevel ObjectCode = "consc-level" // Tingkat Kesadaran OCConsciousnessLevelDet ObjectCode = "consc-level-det" // Detail Tingkat Kesadaran OCSystolicBloodPressure ObjectCode = "syst-bp" // Tekanan Darah Systolic @@ -64,6 +66,7 @@ const ( OCHeight ObjectCode = "height" // Tinggi Badan OCHeadToToe ObjectCode = "head-to-toe" // Kepala Sampai Kaki + ACDetail AssessmentCode = "detail" // Detail ACEarlyDiag AssessmentCode = "early-diag" // Diagnosis Awal ACLateDiag AssessmentCode = "late-diag" // Diagnosis Akhir ACSecDiag AssessmentCode = "sec-diag" // Diagnosis Sekunder @@ -194,7 +197,7 @@ type Soapi struct { // ---------------- SUBJECT ---------------- type SubjectSection struct { - Note string `json:"note,omitempty"` + Detail string `json:"detail,omitempty"` PrimComplain string `json:"prim-compl,omitempty"` SecComplainQ string `json:"sec-compl,omitempty"` PrimaryComplain string `json:"pri-complain,omitempty"` @@ -210,7 +213,7 @@ type SubjectSection struct { // ---------------- OBJECT ---------------- type ObjectSection struct { - Note string `json:"note,omitempty"` + Detail string `json:"detail,omitempty"` ConsciousnessLevel string `json:"consc-level,omitempty"` ConsciousnessLevelDet string `json:"consc-level-det,omitempty"` SystolicBloodPressure string `json:"syst-bp,omitempty"` @@ -243,9 +246,16 @@ type ObjectSection struct { // ---------------- ASSESSMENT ---------------- type AssessmentSection struct { - EarlyDiagnosis DiagnosisDetail `json:"early-diag,omitempty"` - LateDiagnosis DiagnosisDetail `json:"late-diag,omitempty"` - SecondaryDiag DiagnosisDetail `json:"sec-diag,omitempty"` + Detail string `json:"detail,omitempty"` + EarlyDiagnosis DiagnosisDetail `json:"early-diag,omitempty"` + LateDiagnosis DiagnosisDetail `json:"late-diag,omitempty"` + SecondaryDiag DiagnosisDetail `json:"sec-diag,omitempty"` + EarlyDiagnosisMed DiagnosisDetail `json:"early-med-diag,omitempty"` + LateDiagnosisMed DiagnosisDetail `json:"late-med-diag,omitempty"` + SecondaryDiagnosisMed DiagnosisDetail `json:"sec-med-diag,omitempty"` + EarlyDiagnosisFunc DiagnosisDetail `json:"early-func-diag,omitempty"` + LateDiagnosisFunc DiagnosisDetail `json:"late-func-diag,omitempty"` + SecondaryDiagnosisFunc DiagnosisDetail `json:"sec-func-diag,omitempty"` } // nested object {note, codes} diff --git a/internal/interface/main-handler/device/handler.go b/internal/interface/main-handler/device/handler.go index 1a3cb18d..c827f20f 100644 --- a/internal/interface/main-handler/device/handler.go +++ b/internal/interface/main-handler/device/handler.go @@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { } func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.ReadDetailDto{} - dto.Id = uint16(id) + dto.Code = &code res, err := u.ReadDetail(dto) rw.DataResponse(w, res, err) } func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } @@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { return } - dto.Id = uint(id) + dto.Code = code res, err := u.Update(dto) rw.DataResponse(w, res, err) } func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.DeleteDto{} - dto.Id = uint(id) + dto.Code = &code res, err := u.Delete(dto) rw.DataResponse(w, res, err) } diff --git a/internal/interface/main-handler/infra/handler.go b/internal/interface/main-handler/infra/handler.go index 71a8f1ec..fedccf48 100644 --- a/internal/interface/main-handler/infra/handler.go +++ b/internal/interface/main-handler/infra/handler.go @@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { } func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.ReadDetailDto{} - dto.Id = uint16(id) + dto.Code = &code res, err := u.ReadDetail(dto) rw.DataResponse(w, res, err) } func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } @@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { return } - dto.Id = uint16(id) + dto.Code = code res, err := u.Update(dto) rw.DataResponse(w, res, err) } func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.DeleteDto{} - dto.Id = uint16(id) + dto.Code = &code res, err := u.Delete(dto) rw.DataResponse(w, res, err) } diff --git a/internal/interface/main-handler/item/handler.go b/internal/interface/main-handler/item/handler.go index 124be7ef..a786e86b 100644 --- a/internal/interface/main-handler/item/handler.go +++ b/internal/interface/main-handler/item/handler.go @@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { } func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.ReadDetailDto{} - dto.Id = uint16(id) + dto.Code = &code res, err := u.ReadDetail(dto) rw.DataResponse(w, res, err) } func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } @@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { return } - dto.Id = uint(id) + dto.Code = code res, err := u.Update(dto) rw.DataResponse(w, res, err) } func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.DeleteDto{} - dto.Id = uint(id) + dto.Code = &code res, err := u.Delete(dto) rw.DataResponse(w, res, err) } diff --git a/internal/interface/main-handler/main-handler.go b/internal/interface/main-handler/main-handler.go index 925f9dc6..6d0548e9 100644 --- a/internal/interface/main-handler/main-handler.go +++ b/internal/interface/main-handler/main-handler.go @@ -36,7 +36,9 @@ import ( /******************** actor ********************/ + doctor "simrs-vx/internal/interface/main-handler/doctor" employee "simrs-vx/internal/interface/main-handler/employee" + nurse "simrs-vx/internal/interface/main-handler/nurse" nutritionist "simrs-vx/internal/interface/main-handler/nutritionist" patient "simrs-vx/internal/interface/main-handler/patient" person "simrs-vx/internal/interface/main-handler/person" @@ -267,6 +269,8 @@ func SetRoutes() http.Handler { hc.RegCrud(r, "/v1/person-contact", personcontact.O) hc.RegCrud(r, "/v1/person-insurance", personinsurance.O) hc.RegCrud(r, "/v1/employee", employee.O) + hc.RegCrudByCode(r, "/v1/doctor", doctor.O) + hc.RegCrudByCode(r, "/v1/nurse", nurse.O) hc.RegCrud(r, "/v1/nutritionist", nutritionist.O) hc.RegCrud(r, "/v1/pharmacist", pharmacist.O) hk.GroupRoutes("/v1/user", r, hk.MapHandlerFunc{ @@ -300,22 +304,22 @@ func SetRoutes() http.Handler { hc.RegCrudByCode(r, "/v1/subspecialist", subspecialist.O) hc.RegCrudByCode(r, "/v1/specialist-position", specialistposition.O) hc.RegCrudByCode(r, "/v1/subspecialist-position", subspecialistposition.O) + hc.RegCrudByCode(r, "/v1/infra", infra.O) hc.RegCrud(r, "/v1/pharmacy-company", pharmacycompany.O) hc.RegCrud(r, "/v1/diagnose-src", diagnosesrc.O) hc.RegCrud(r, "/v1/procedure-src", proceduresrc.O) hc.RegCrud(r, "/v1/uom", uom.O) - hc.RegCrud(r, "/v1/item", item.O) + hc.RegCrudByCode(r, "/v1/item", item.O) hc.RegCrud(r, "/v1/item-price", itemprice.O) - hc.RegCrud(r, "/v1/infra", infra.O) hc.RegCrud(r, "/v1/medicine-group", medicinegroup.O) hc.RegCrud(r, "/v1/medicine-method", medicinemethod.O) hc.RegCrud(r, "/v1/mcu-src-category", mcusrccategory.O) hc.RegCrud(r, "/v1/mcu-src", mcusrc.O) hc.RegCrud(r, "/v1/ethnic", ethnic.O) hc.RegCrud(r, "/v1/insurance-company", insurancecompany.O) - hc.RegCrud(r, "/v1/medicine", medicine.O) - hc.RegCrud(r, "/v1/device", device.O) - hc.RegCrud(r, "/v1/material", material.O) + hc.RegCrudByCode(r, "/v1/medicine", medicine.O) + hc.RegCrudByCode(r, "/v1/device", device.O) + hc.RegCrudByCode(r, "/v1/material", material.O) hc.RegCrud(r, "/v1/doctor-fee", doctorfee.O) hc.RegCrud(r, "/v1/medical-action-src", medicalactionsrc.O) hc.RegCrud(r, "/v1/medical-action-src-item", medicalactionsrcitem.O) diff --git a/internal/interface/main-handler/material/handler.go b/internal/interface/main-handler/material/handler.go index 2b152625..10de8a92 100644 --- a/internal/interface/main-handler/material/handler.go +++ b/internal/interface/main-handler/material/handler.go @@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { } func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.ReadDetailDto{} - dto.Id = uint16(id) + dto.Code = &code res, err := u.ReadDetail(dto) rw.DataResponse(w, res, err) } func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } @@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { return } - dto.Id = uint(id) + dto.Code = code res, err := u.Update(dto) rw.DataResponse(w, res, err) } func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.DeleteDto{} - dto.Id = uint(id) + dto.Code = &code res, err := u.Delete(dto) rw.DataResponse(w, res, err) } diff --git a/internal/interface/main-handler/medicine/handler.go b/internal/interface/main-handler/medicine/handler.go index 5a5b28e0..b6a3f185 100644 --- a/internal/interface/main-handler/medicine/handler.go +++ b/internal/interface/main-handler/medicine/handler.go @@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { } func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.ReadDetailDto{} - dto.Id = uint16(id) + dto.Code = &code res, err := u.ReadDetail(dto) rw.DataResponse(w, res, err) } func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } @@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { return } - dto.Id = uint(id) + dto.Code = code res, err := u.Update(dto) rw.DataResponse(w, res, err) } func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { + code := rw.ValidateString(w, "code", r.PathValue("code")) + if code == "" { return } dto := e.DeleteDto{} - dto.Id = uint(id) + dto.Code = &code res, err := u.Delete(dto) rw.DataResponse(w, res, err) } diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index af9fe034..f6c251c0 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -8,6 +8,7 @@ import ( antibioticinuse "simrs-vx/internal/domain/main-entities/antibiotic-in-use" antibioticsrccategory "simrs-vx/internal/domain/main-entities/antibiotic-src-category" appointment "simrs-vx/internal/domain/main-entities/appointment" + authpartner "simrs-vx/internal/domain/main-entities/auth-partner" chemo "simrs-vx/internal/domain/main-entities/chemo" chemoprotocol "simrs-vx/internal/domain/main-entities/chemo-protocol" consultation "simrs-vx/internal/domain/main-entities/consultation" @@ -92,6 +93,7 @@ import ( unitposition "simrs-vx/internal/domain/main-entities/unit-position" uom "simrs-vx/internal/domain/main-entities/uom" user "simrs-vx/internal/domain/main-entities/user" + userfes "simrs-vx/internal/domain/main-entities/user-fes" vehicle "simrs-vx/internal/domain/main-entities/vehicle" vehiclehist "simrs-vx/internal/domain/main-entities/vehicle-hist" village "simrs-vx/internal/domain/main-entities/village" @@ -105,7 +107,9 @@ import ( func getMainEntities() []any { return []any{ + &authpartner.AuthPartner{}, &user.User{}, + &userfes.UserFes{}, &division.Division{}, &divisionposition.DivisionPosition{}, &installation.Installation{}, diff --git a/internal/use-case/main-use-case/device/case.go b/internal/use-case/main-use-case/device/case.go index ff548a4b..126dff9f 100644 --- a/internal/use-case/main-use-case/device/case.go +++ b/internal/use-case/main-use-case/device/case.go @@ -169,7 +169,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { } func Update(input e.UpdateDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: &input.Code} var data *e.Device var err error @@ -225,7 +225,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { } func Delete(input e.DeleteDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: input.Code} var data *e.Device var err error diff --git a/internal/use-case/main-use-case/device/helper.go b/internal/use-case/main-use-case/device/helper.go index 08964464..21956cc5 100644 --- a/internal/use-case/main-use-case/device/helper.go +++ b/internal/use-case/main-use-case/device/helper.go @@ -30,8 +30,8 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Device) { data.Code = inputSrc.Code data.Name = inputSrc.Name data.Uom_Code = inputSrc.Uom_Code - data.Item_Id = inputSrc.Item_Id - data.Infra_Id = inputSrc.Infra_Id + data.Item_Code = inputSrc.Item_Code + data.Infra_Code = inputSrc.Infra_Code } func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error { @@ -40,13 +40,13 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error { Name: input.Name, ItemGroup_Code: ero.ITGCDevice, Uom_Code: &input.Uom_Code, - Infra_Id: input.Infra_Id, + Infra_Code: input.Infra_Code, } item, err := ui.CreateData(itemCreate, event, tx) if err != nil { return err } - input.Item_Id = &item.Id + input.Item_Code = &item.Code return nil } diff --git a/internal/use-case/main-use-case/device/lib.go b/internal/use-case/main-use-case/device/lib.go index 664db248..63c8cedb 100644 --- a/internal/use-case/main-use-case/device/lib.go +++ b/internal/use-case/main-use-case/device/lib.go @@ -81,6 +81,13 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e tx = dg.I } + if input.Code != nil { + tx = tx.Where("\"Code\" = ?", *input.Code) + } + if input.Id != nil { + tx = tx.Where("\"Id\" = ?", *input.Id) + } + if err := tx.First(&data, input.Id).Error; err != nil { if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil { return nil, processedErr diff --git a/internal/use-case/main-use-case/division/lib.go b/internal/use-case/main-use-case/division/lib.go index 62a10d5b..0b45ba11 100644 --- a/internal/use-case/main-use-case/division/lib.go +++ b/internal/use-case/main-use-case/division/lib.go @@ -52,7 +52,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Di EXISTS ( SELECT 1 FROM "Division" c - WHERE c."Parent_Id" = "Division"."Id" + WHERE c."Parent_Code" = "Division"."Code" ) `) } diff --git a/internal/use-case/main-use-case/infra/case.go b/internal/use-case/main-use-case/infra/case.go index 7c227e8b..4771f3cb 100644 --- a/internal/use-case/main-use-case/infra/case.go +++ b/internal/use-case/main-use-case/infra/case.go @@ -38,12 +38,12 @@ func Create(input e.CreateDto) (*d.Data, error) { } if input.InfraGroup_Code == ero.IFGCRoom { - if input.Parent_Id == nil { + if input.Parent_Code == nil { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ Code: "data-create-fail", - Detail: "parent_id is required", - Raw: errors.New("parent_id is required"), + Detail: "parent_code is required", + Raw: errors.New("parent_code is required"), } return pl.SetLogError(&event, input) @@ -59,7 +59,7 @@ func Create(input e.CreateDto) (*d.Data, error) { } if input.InfraGroup_Code == ero.IFGCRoom { - input.Infra_Id = &data.Id + input.Infra_Code = &data.Code if err := createRoom(&input, &event, tx); err != nil { return err } diff --git a/internal/use-case/main-use-case/infra/helper.go b/internal/use-case/main-use-case/infra/helper.go index 35388c85..81de5389 100644 --- a/internal/use-case/main-use-case/infra/helper.go +++ b/internal/use-case/main-use-case/infra/helper.go @@ -29,8 +29,8 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Infra) { data.Code = inputSrc.Code data.Name = inputSrc.Name data.InfraGroup_Code = inputSrc.InfraGroup_Code - data.Parent_Id = inputSrc.Parent_Id - data.Item_Id = inputSrc.Item_Id + data.Parent_Code = inputSrc.Parent_Code + data.Item_Code = inputSrc.Item_Code } func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error { @@ -42,23 +42,23 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error { tmp := "unit" return &tmp }(), - Infra_Id: input.Parent_Id, + Infra_Code: input.Parent_Code, } item, err := ui.CreateData(itemCreate, event, tx) if err != nil { return err } - input.Item_Id = &item.Id + input.Item_Code = &item.Code return nil } func createRoom(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error { roomCreate := er.CreateDto{ - Infra_Id: input.Infra_Id, - Unit_Id: input.Unit_Id, - Specialist_Id: input.Specialist_Id, - Subspecialist_Id: input.Subspecialist_Id, + Infra_Code: input.Infra_Code, + Unit_Code: input.Unit_Code, + Specialist_Code: input.Specialist_Code, + Subspecialist_Code: input.Subspecialist_Code, } _, err := ur.CreateData(roomCreate, event, tx) if err != nil { diff --git a/internal/use-case/main-use-case/infra/lib.go b/internal/use-case/main-use-case/infra/lib.go index 234104bb..5e0592c3 100644 --- a/internal/use-case/main-use-case/infra/lib.go +++ b/internal/use-case/main-use-case/infra/lib.go @@ -52,7 +52,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.In EXISTS ( SELECT 1 FROM "Infra" c - WHERE c."Parent_Id" = "Infra"."Id" + WHERE c."Parent_Code" = "Infra"."Code" ) `) } @@ -91,6 +91,13 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e tx = dg.I } + if input.Code != nil { + tx = tx.Where("\"Code\" = ?", *input.Code) + } + if input.Id != nil { + tx = tx.Where("\"Id\" = ?", *input.Id) + } + tx = tx.Preload("Parent"). Preload("Childrens"). Preload("Item"). @@ -99,7 +106,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e Preload("Rooms.Subspecialist"). Preload("Rooms.Unit") - if err := tx.First(&data, input.Id).Error; err != nil { + if err := tx.First(&data).Error; err != nil { if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil { return nil, processedErr } @@ -119,7 +126,7 @@ func UpdateData(input e.UpdateDto, data *e.Infra, event *pl.Event, dbx ...*gorm. } else { tx = dg.I } - data.Parent = nil + // data.Parent = nil data.Childrens = nil data.Item = nil data.Rooms = nil diff --git a/internal/use-case/main-use-case/item/case.go b/internal/use-case/main-use-case/item/case.go index 914d777f..58ce3213 100644 --- a/internal/use-case/main-use-case/item/case.go +++ b/internal/use-case/main-use-case/item/case.go @@ -166,7 +166,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { } func Update(input e.UpdateDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: &input.Code} var data *e.Item var err error @@ -222,7 +222,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { } func Delete(input e.DeleteDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: input.Code} var data *e.Item var err error diff --git a/internal/use-case/main-use-case/item/helper.go b/internal/use-case/main-use-case/item/helper.go index 0ebfcd37..6f7e0c57 100644 --- a/internal/use-case/main-use-case/item/helper.go +++ b/internal/use-case/main-use-case/item/helper.go @@ -21,6 +21,6 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Item) { data.Name = inputSrc.Name data.ItemGroup_Code = inputSrc.ItemGroup_Code data.Uom_Code = inputSrc.Uom_Code - data.Infra_Id = inputSrc.Infra_Id + data.Infra_Code = inputSrc.Infra_Code data.Stock = inputSrc.Stock } diff --git a/internal/use-case/main-use-case/material/case.go b/internal/use-case/main-use-case/material/case.go index 42346dc6..5f5cec55 100644 --- a/internal/use-case/main-use-case/material/case.go +++ b/internal/use-case/main-use-case/material/case.go @@ -169,7 +169,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { } func Update(input e.UpdateDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: &input.Code} var data *e.Material var err error @@ -225,7 +225,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { } func Delete(input e.DeleteDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: input.Code} var data *e.Material var err error diff --git a/internal/use-case/main-use-case/material/helper.go b/internal/use-case/main-use-case/material/helper.go index 9cfefe27..ee415107 100644 --- a/internal/use-case/main-use-case/material/helper.go +++ b/internal/use-case/main-use-case/material/helper.go @@ -30,8 +30,8 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Material) { data.Name = inputSrc.Name data.Uom_Code = inputSrc.Uom_Code data.Stock = inputSrc.Stock - data.Item_Id = inputSrc.Item_Id - data.Infra_Id = inputSrc.Infra_Id + data.Item_Code = inputSrc.Item_Code + data.Infra_Code = inputSrc.Infra_Code } func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error { @@ -40,7 +40,7 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error { Name: input.Name, ItemGroup_Code: ero.ITGCMaterial, Uom_Code: &input.Uom_Code, - Infra_Id: input.Infra_Id, + Infra_Code: input.Infra_Code, Stock: input.Stock, } item, err := ui.CreateData(itemCreate, event, tx) @@ -48,6 +48,6 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error { return err } - input.Item_Id = &item.Id + input.Item_Code = &item.Code return nil } diff --git a/internal/use-case/main-use-case/medicine/case.go b/internal/use-case/main-use-case/medicine/case.go index 5855d33c..3e5bee2d 100644 --- a/internal/use-case/main-use-case/medicine/case.go +++ b/internal/use-case/main-use-case/medicine/case.go @@ -169,7 +169,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { } func Update(input e.UpdateDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: &input.Code} var data *e.Medicine var err error @@ -225,7 +225,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { } func Delete(input e.DeleteDto) (*d.Data, error) { - rdDto := e.ReadDetailDto{Id: uint16(input.Id)} + rdDto := e.ReadDetailDto{Code: input.Code} var data *e.Medicine var err error diff --git a/internal/use-case/main-use-case/medicine/helper.go b/internal/use-case/main-use-case/medicine/helper.go index 388be819..1cf35762 100644 --- a/internal/use-case/main-use-case/medicine/helper.go +++ b/internal/use-case/main-use-case/medicine/helper.go @@ -33,9 +33,9 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Medicine) { data.MedicineMethod_Code = inputSrc.MedicineMethod_Code data.Uom_Code = inputSrc.Uom_Code data.Dose = inputSrc.Dose - data.Infra_Id = inputSrc.Infra_Id + data.Infra_Code = inputSrc.Infra_Code data.Stock = inputSrc.Stock - data.Item_Id = inputSrc.Item_Id + data.Item_Code = inputSrc.Item_Code } func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error { @@ -44,7 +44,7 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error { Name: input.Name, ItemGroup_Code: ero.ITGCMedicine, Uom_Code: input.Uom_Code, - Infra_Id: input.Infra_Id, + Infra_Code: input.Infra_Code, Stock: input.Stock, } item, err := ui.CreateData(itemCreate, event, tx) @@ -52,6 +52,6 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error { return err } - input.Item_Id = &item.Id + input.Item_Code = &item.Code return nil } diff --git a/internal/use-case/main-use-case/medicine/lib.go b/internal/use-case/main-use-case/medicine/lib.go index 3b9d2fa1..f9fccb2e 100644 --- a/internal/use-case/main-use-case/medicine/lib.go +++ b/internal/use-case/main-use-case/medicine/lib.go @@ -81,8 +81,15 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e tx = dg.I } + if input.Code != nil { + tx = tx.Where("\"Code\" = ?", *input.Code) + } + if input.Id != nil { + tx = tx.Where("\"Id\" = ?", *input.Id) + } + tx = tx.Preload("Item") - if err := tx.First(&data, input.Id).Error; err != nil { + if err := tx.First(&data).Error; err != nil { if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil { return nil, processedErr } diff --git a/internal/use-case/main-use-case/room/helper.go b/internal/use-case/main-use-case/room/helper.go index cc64e8c5..5e97a653 100644 --- a/internal/use-case/main-use-case/room/helper.go +++ b/internal/use-case/main-use-case/room/helper.go @@ -17,8 +17,8 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Room) { inputSrc = &inputTemp.CreateDto } - data.Infra_Id = inputSrc.Infra_Id - data.Unit_Id = inputSrc.Unit_Id - data.Specialist_Id = inputSrc.Specialist_Id - data.Subspecialist_Id = inputSrc.Subspecialist_Id + data.Infra_Code = inputSrc.Infra_Code + data.Unit_Code = inputSrc.Unit_Code + data.Specialist_Code = inputSrc.Specialist_Code + data.Subspecialist_Code = inputSrc.Subspecialist_Code }