+66
-87
@@ -10,53 +10,6 @@ CREATE TABLE "public"."DiagnoseSrc" (
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_DiagnoseSrc_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "PharmacyCompany" table
|
||||
CREATE TABLE "public"."PharmacyCompany" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(20) NULL,
|
||||
"Name" character varying(100) NULL,
|
||||
"Regency_Code" character varying(4) NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_PharmacyCompany_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "McuSrc" table
|
||||
CREATE TABLE "public"."McuSrc" (
|
||||
"Id" serial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(20) NULL,
|
||||
"Name" character varying(50) NULL,
|
||||
"CheckupCategory_Code" character varying(20) NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_McuSrc_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "ItemGroup" table
|
||||
CREATE TABLE "public"."ItemGroup" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(50) NULL,
|
||||
"Name" character varying(100) NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_ItemGroup_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "McuSrcCategory" table
|
||||
CREATE TABLE "public"."McuSrcCategory" (
|
||||
"Id" serial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(20) NULL,
|
||||
"Name" character varying(50) NULL,
|
||||
"Scope_Code" character varying(10) NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_McuSrcCategory_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "Counter" table
|
||||
CREATE TABLE "public"."Counter" (
|
||||
"Id" serial NOT NULL,
|
||||
@@ -72,6 +25,53 @@ CREATE TABLE "public"."Counter" (
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_Counter_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "McuSrcCategory" table
|
||||
CREATE TABLE "public"."McuSrcCategory" (
|
||||
"Id" serial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(20) NULL,
|
||||
"Name" character varying(50) NULL,
|
||||
"Scope_Code" character varying(10) NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_McuSrcCategory_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "McuSrc" table
|
||||
CREATE TABLE "public"."McuSrc" (
|
||||
"Id" serial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(20) NULL,
|
||||
"Name" character varying(50) NULL,
|
||||
"CheckupCategory_Code" character varying(20) NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_McuSrc_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "Uom" table
|
||||
CREATE TABLE "public"."Uom" (
|
||||
"Id" serial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(10) NULL,
|
||||
"Name" character varying(50) NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_Uom_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "PharmacyCompany" table
|
||||
CREATE TABLE "public"."PharmacyCompany" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(20) NULL,
|
||||
"Name" character varying(100) NULL,
|
||||
"Regency_Code" character varying(4) NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_PharmacyCompany_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "User" table
|
||||
CREATE TABLE "public"."User" (
|
||||
"Id" bigserial NOT NULL,
|
||||
@@ -87,17 +87,6 @@ CREATE TABLE "public"."User" (
|
||||
"LastAllowdLogin" timestamptz NULL,
|
||||
PRIMARY KEY ("Id")
|
||||
);
|
||||
-- Create "Uom" table
|
||||
CREATE TABLE "public"."Uom" (
|
||||
"Id" serial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(10) NULL,
|
||||
"Name" character varying(50) NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_Uom_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "Item" table
|
||||
CREATE TABLE "public"."Item" (
|
||||
"Id" bigserial NOT NULL,
|
||||
@@ -112,9 +101,23 @@ CREATE TABLE "public"."Item" (
|
||||
"Stock" bigint NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_Item_Code" UNIQUE ("Code"),
|
||||
CONSTRAINT "fk_Item_ItemGroup" FOREIGN KEY ("ItemGroup_Code") REFERENCES "public"."ItemGroup" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_Item_Uom" FOREIGN KEY ("Uom_Code") REFERENCES "public"."Uom" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
-- Create "Infra" table
|
||||
CREATE TABLE "public"."Infra" (
|
||||
"Id" serial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(10) NULL,
|
||||
"Name" character varying(50) NULL,
|
||||
"InfraGroup_Code" character varying(10) NULL,
|
||||
"Parent_Id" smallint NULL,
|
||||
"Item_Id" bigint NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_Infra_Code" UNIQUE ("Code"),
|
||||
CONSTRAINT "fk_Infra_Item" FOREIGN KEY ("Item_Id") REFERENCES "public"."Item" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
-- Create "Device" table
|
||||
CREATE TABLE "public"."Device" (
|
||||
"Id" bigserial NOT NULL,
|
||||
@@ -124,9 +127,11 @@ CREATE TABLE "public"."Device" (
|
||||
"Code" character varying(10) NULL,
|
||||
"Name" character varying(50) NULL,
|
||||
"Uom_Code" character varying(10) NULL,
|
||||
"Infra_Id" integer NULL,
|
||||
"Item_Id" bigint NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_Device_Code" UNIQUE ("Code"),
|
||||
CONSTRAINT "fk_Device_Infra" FOREIGN KEY ("Infra_Id") REFERENCES "public"."Infra" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_Device_Item" FOREIGN KEY ("Item_Id") REFERENCES "public"."Item" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_Device_Uom" FOREIGN KEY ("Uom_Code") REFERENCES "public"."Uom" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
@@ -251,34 +256,6 @@ CREATE TABLE "public"."DoctorFee" (
|
||||
CONSTRAINT "fk_DoctorFee_Doctor" FOREIGN KEY ("Doctor_Id") REFERENCES "public"."Doctor" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_DoctorFee_Item" FOREIGN KEY ("Item_Id") REFERENCES "public"."Item" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
-- Create "InfraGroup" table
|
||||
CREATE TABLE "public"."InfraGroup" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(10) NULL,
|
||||
"Name" character varying(50) NULL,
|
||||
"Level" smallint NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_InfraGroup_Code" UNIQUE ("Code")
|
||||
);
|
||||
-- Create "Infra" table
|
||||
CREATE TABLE "public"."Infra" (
|
||||
"Id" serial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Code" character varying(10) NULL,
|
||||
"Name" character varying(50) NULL,
|
||||
"InfraGroup_Code" character varying(10) NULL,
|
||||
"Parent_Id" smallint NULL,
|
||||
"Item_Id" bigint NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_Infra_Code" UNIQUE ("Code"),
|
||||
CONSTRAINT "fk_Infra_InfraGroup" FOREIGN KEY ("InfraGroup_Code") REFERENCES "public"."InfraGroup" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_Infra_Item" FOREIGN KEY ("Item_Id") REFERENCES "public"."Item" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
-- Create "InsuranceCompany" table
|
||||
CREATE TABLE "public"."InsuranceCompany" (
|
||||
"Id" serial NOT NULL,
|
||||
@@ -316,10 +293,12 @@ CREATE TABLE "public"."Material" (
|
||||
"Code" character varying(10) NULL,
|
||||
"Name" character varying(50) NULL,
|
||||
"Uom_Code" character varying(10) NULL,
|
||||
"Infra_Id" integer NULL,
|
||||
"Stock" bigint NULL,
|
||||
"Item_Id" bigint NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_Material_Code" UNIQUE ("Code"),
|
||||
CONSTRAINT "fk_Material_Infra" FOREIGN KEY ("Infra_Id") REFERENCES "public"."Infra" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_Material_Item" FOREIGN KEY ("Item_Id") REFERENCES "public"."Item" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_Material_Uom" FOREIGN KEY ("Uom_Code") REFERENCES "public"."Uom" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Modify "Infra" table
|
||||
ALTER TABLE "public"."Infra" ALTER COLUMN "Parent_Id" TYPE integer;
|
||||
-- Modify "User" table
|
||||
ALTER TABLE "public"."User" ADD CONSTRAINT "uni_User_Name" UNIQUE ("Name");
|
||||
-- Modify "Employee" table
|
||||
ALTER TABLE "public"."Employee" ADD CONSTRAINT "fk_Employee_Person" FOREIGN KEY ("Person_Id") REFERENCES "public"."Person" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Employee_User" FOREIGN KEY ("User_Id") REFERENCES "public"."User" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Modify "McuSrc" table
|
||||
ALTER TABLE "public"."McuSrc" ADD CONSTRAINT "fk_McuSrc_CheckupCategory" FOREIGN KEY ("CheckupCategory_Code") REFERENCES "public"."McuSrcCategory" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Modify "Person" table
|
||||
ALTER TABLE "public"."Person" ADD COLUMN "FrontTitle" character varying(50) NULL, ADD COLUMN "EndTitle" character varying(50) NULL;
|
||||
@@ -1,2 +1,5 @@
|
||||
h1:MMNuESyEk0KZHA2z+7AukfG/ATboITROipz2wK3YNPg=
|
||||
20250828092003.sql h1:Rr221/6KN53t0eoEHK5+sPeMaVsnKjN4322WLulN8AQ=
|
||||
h1:vQwjJ2jG5TRFv8oZyhxcynOFS+H0vyKY/XWsXJyhpuo=
|
||||
20250829081952.sql h1:YMsYq3uPsx70EjWSGfYnVRR5GV0q1fRGIszYZAWzXNo=
|
||||
20250901073356.sql h1:jjd5TLs+Pyi0u3SrOM+aNTbHxSJboXgcOz/L4bkYx+c=
|
||||
20250901080035.sql h1:LWa3X0NWjalVcxNbk5HaHj1Oqu60/AQabi0jBmCeQBI=
|
||||
20250901105703.sql h1:45mFfTFkLv+1oQXfqNxtCBGXTyzWuqq759I3u1SVxRo=
|
||||
|
||||
@@ -2,22 +2,31 @@ package device
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ein "simrs-vx/internal/domain/main-entities/infra"
|
||||
ei "simrs-vx/internal/domain/main-entities/item"
|
||||
eu "simrs-vx/internal/domain/main-entities/uom"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Uom_Code string `json:"uom_code"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Uom_Code string `json:"uom_code"`
|
||||
Infra_Id *uint16 `json:"infra_id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Uom_Code string `json:"uom_code"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Uom_Code string `json:"uom_code"`
|
||||
Infra_Id *uint16 `json:"infra_id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
@@ -25,11 +34,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Uom_Code string `json:"uom_code"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -49,12 +55,14 @@ 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"`
|
||||
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_Id *uint16 `json:"infra_id"`
|
||||
Infra *ein.Infra `json:"infra,omitempty"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Item *ei.Item `json:"item,omitempty"`
|
||||
}
|
||||
|
||||
func (d Device) ToResponse() ResponseDto {
|
||||
@@ -63,6 +71,8 @@ func (d Device) ToResponse() ResponseDto {
|
||||
Name: d.Name,
|
||||
Uom_Code: d.Uom_Code,
|
||||
Uom: d.Uom,
|
||||
Infra_Id: d.Infra_Id,
|
||||
Infra: d.Infra,
|
||||
Item_Id: d.Item_Id,
|
||||
Item: d.Item,
|
||||
}
|
||||
|
||||
@@ -2,16 +2,19 @@ package device
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ein "simrs-vx/internal/domain/main-entities/infra"
|
||||
ei "simrs-vx/internal/domain/main-entities/item"
|
||||
eu "simrs-vx/internal/domain/main-entities/uom"
|
||||
)
|
||||
|
||||
type Device struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:10"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
Uom_Code string `json:"uom_code" gorm:"size:10"`
|
||||
Uom *eu.Uom `json:"uom,omitempty" gorm:"foreignKey:Uom_Code;references:Code"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:10"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
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 *ein.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Id;references:Id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
|
||||
}
|
||||
|
||||
@@ -21,10 +21,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
IndName string `json:"indName"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -19,10 +19,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint32 `json:"id"`
|
||||
Regency_Code string `json:"regency_code"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Id uint32 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -12,6 +12,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Division_Id *uint16 `json:"division_id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
@@ -22,10 +28,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Division_Id *uint16 `json:"division_id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -21,10 +21,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Parent_Id *int16 `json:"parent_id"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -4,19 +4,25 @@ import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ei "simrs-vx/internal/domain/main-entities/item"
|
||||
erc "simrs-vx/internal/domain/references/clinical"
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
FeeType_Code *erc.DoctorFeeTypeCode `json:"feeType_code"`
|
||||
FeeType_Code *ero.DoctorFeeTypeCode `json:"feeType_code"`
|
||||
Price *float64 `json:"price"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
FeeType_Code *erc.DoctorFeeTypeCode `json:"feeType_code"`
|
||||
FeeType_Code *ero.DoctorFeeTypeCode `json:"feeType_code"`
|
||||
Price *float64 `json:"price"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
|
||||
@@ -26,11 +32,9 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
FeeType_Code *erc.DoctorFeeTypeCode `json:"feeType_code"`
|
||||
Price *float64 `json:"price"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Id uint16 `json:"id"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -52,7 +56,7 @@ type ResponseDto struct {
|
||||
ecore.Main
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
FeeType_Code *erc.DoctorFeeTypeCode `json:"feeType_code"`
|
||||
FeeType_Code *ero.DoctorFeeTypeCode `json:"feeType_code"`
|
||||
Price *float64 `json:"price"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Item *ei.Item `json:"item,omitempty"`
|
||||
|
||||
@@ -4,14 +4,14 @@ import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ei "simrs-vx/internal/domain/main-entities/item"
|
||||
erc "simrs-vx/internal/domain/references/clinical"
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
)
|
||||
|
||||
type DoctorFee struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"`
|
||||
FeeType_Code *erc.DoctorFeeTypeCode `json:"feeType_code" gorm:"size:11"`
|
||||
FeeType_Code *ero.DoctorFeeTypeCode `json:"feeType_code" gorm:"size:11"`
|
||||
Price *float64 `json:"price"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
|
||||
|
||||
@@ -14,6 +14,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
IHS_Number *string `json:"ihs_number"`
|
||||
SIP_Number *string `json:"sip_number"`
|
||||
@@ -29,7 +35,6 @@ type ReadDetailDto struct {
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
IHS_Number *string `json:"ihs_number"`
|
||||
SIP_Number *string `json:"sip_number"`
|
||||
Unit_Id *uint `json:"unit_id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package employee
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/division"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
)
|
||||
|
||||
type Employee struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
User_Id *uint `json:"user_id"`
|
||||
Person_Id *uint `json:"person_id"`
|
||||
Position_Code ero.EmployeePosisitionCode `json:"position_code" gorm:"not null;size:20"`
|
||||
Division_Code *string `json:"division_code"`
|
||||
Division *ed.Division `json:"division,omitempty" gorm:"foreignKey:Division_Code;references:Code"`
|
||||
Number *string `json:"number" gorm:"size:20"`
|
||||
Status_Code erc.StatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
}
|
||||
@@ -3,26 +3,39 @@ package employee
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/division"
|
||||
ep "simrs-vx/internal/domain/main-entities/person"
|
||||
eu "simrs-vx/internal/domain/main-entities/user"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
User_Id *uint `json:"user_id"`
|
||||
User *eu.CreateDto `json:"user"`
|
||||
Person_Id *uint `json:"person_id"`
|
||||
Person *ep.CreateDto `json:"person"`
|
||||
Position_Code ero.EmployeePosisitionCode `json:"position_code"`
|
||||
Division_Code *string `json:"division_code"`
|
||||
Number *string `json:"number"`
|
||||
Status_Code erc.StatusCode `json:"status_code"`
|
||||
Status_Code erc.ActiveStatusCode `json:"status_code"`
|
||||
IHS_Number *string `json:"ihs_number"`
|
||||
SIP_Number *string `json:"sip_number"`
|
||||
Unit_Id *uint `json:"unit_id"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
User_Id *uint `json:"user_id"`
|
||||
Person_Id *uint `json:"person_id"`
|
||||
Position_Code ero.EmployeePosisitionCode `json:"position_code"`
|
||||
Division_Code *string `json:"division_code"`
|
||||
Number *string `json:"number"`
|
||||
Status_Code erc.StatusCode `json:"status_code"`
|
||||
Status_Code erc.ActiveStatusCode `json:"status_code"`
|
||||
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
@@ -30,13 +43,10 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
User_Id *uint `json:"user_id"`
|
||||
Person_Id *uint `json:"person_id"`
|
||||
Position_Code ero.EmployeePosisitionCode `json:"position_code"`
|
||||
Division_Code *string `json:"division_code"`
|
||||
Number *string `json:"number"`
|
||||
Status_Code erc.StatusCode `json:"status_code"`
|
||||
Id uint16 `json:"id"`
|
||||
User_Id *uint `json:"user_id"`
|
||||
Person_Id *uint `json:"person_id"`
|
||||
Number *string `json:"number"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -57,17 +67,20 @@ type MetaDto struct {
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
User_Id *uint `json:"user_id"`
|
||||
User *eu.User `json:"user,omitempty"`
|
||||
Person_Id *uint `json:"person_id"`
|
||||
Person *ep.Person `json:"person,omitempty"`
|
||||
Position_Code ero.EmployeePosisitionCode `json:"position_code"`
|
||||
Division_Code *string `json:"division_code"`
|
||||
Division *ed.Division `json:"division,omitempty"`
|
||||
Number *string `json:"number"`
|
||||
Status_Code erc.StatusCode `json:"status_code"`
|
||||
Status_Code erc.ActiveStatusCode `json:"status_code"`
|
||||
}
|
||||
|
||||
func (d Employee) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
User_Id: d.User_Id,
|
||||
User: d.User,
|
||||
Person_Id: d.Person_Id,
|
||||
Position_Code: d.Position_Code,
|
||||
Division_Code: d.Division_Code,
|
||||
@@ -86,3 +99,9 @@ func ToResponseList(data []Employee) []ResponseDto {
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
func (c CreateDto) Sanitize() CreateDto {
|
||||
sanitized := c
|
||||
sanitized.User.Password = "[REDACTED]"
|
||||
return sanitized
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package employee
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/division"
|
||||
ep "simrs-vx/internal/domain/main-entities/person"
|
||||
eu "simrs-vx/internal/domain/main-entities/user"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
)
|
||||
@@ -10,10 +12,12 @@ import (
|
||||
type Employee struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
User_Id *uint `json:"user_id"`
|
||||
User *eu.User `json:"user,omitempty" gorm:"foreignKey:User_Id;references:Id"`
|
||||
Person_Id *uint `json:"person_id"`
|
||||
Person *ep.Person `json:"person,omitempty" gorm:"foreignKey:Person_Id;references:Id"`
|
||||
Position_Code ero.EmployeePosisitionCode `json:"position_code" gorm:"not null;size:20"`
|
||||
Division_Code *string `json:"division_code"`
|
||||
Division *ed.Division `json:"division,omitempty" gorm:"foreignKey:Division_Code;references:Code"`
|
||||
Number *string `json:"number" gorm:"size:20"`
|
||||
Status_Code erc.StatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
Status_Code erc.ActiveStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
}
|
||||
|
||||
@@ -19,9 +19,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
package infragroup
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Level uint8 `json:"level"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Level uint8 `json:"level"`
|
||||
|
||||
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"`
|
||||
Level uint8 `json:"level"`
|
||||
}
|
||||
|
||||
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
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Level uint8 `json:"level"`
|
||||
}
|
||||
|
||||
func (d InfraGroup) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Code: d.Code,
|
||||
Name: d.Name,
|
||||
Level: d.Level,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []InfraGroup) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package infragroup
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
)
|
||||
|
||||
type InfraGroup struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:10"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
Level uint8 `json:"level"`
|
||||
}
|
||||
@@ -2,24 +2,31 @@ package infra
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
eig "simrs-vx/internal/domain/main-entities/infra-group"
|
||||
ei "simrs-vx/internal/domain/main-entities/item"
|
||||
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
InfraGroup_Code *string `json:"infraGroup_code"`
|
||||
Parent_Id *int16 `json:"parent_id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
InfraGroup_Code *string `json:"infraGroup_code"`
|
||||
Parent_Id *int16 `json:"parent_id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
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"`
|
||||
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
@@ -27,12 +34,9 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
InfraGroup_Code *string `json:"infraGroup_code"`
|
||||
Parent_Id *int16 `json:"parent_id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -52,13 +56,12 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.SmallMain
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
InfraGroup_Code *string `json:"infraGroup_code"`
|
||||
InfraGroup *eig.InfraGroup `json:"infraGroup,omitempty"`
|
||||
Parent_Id *int16 `json:"parent_id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Item *ei.Item `json:"item,omitempty"`
|
||||
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"`
|
||||
Item *ei.Item `json:"item,omitempty"`
|
||||
}
|
||||
|
||||
func (d Infra) ToResponse() ResponseDto {
|
||||
@@ -66,7 +69,6 @@ func (d Infra) ToResponse() ResponseDto {
|
||||
Code: d.Code,
|
||||
Name: d.Name,
|
||||
InfraGroup_Code: d.InfraGroup_Code,
|
||||
InfraGroup: d.InfraGroup,
|
||||
Parent_Id: d.Parent_Id,
|
||||
Item_Id: d.Item_Id,
|
||||
Item: d.Item,
|
||||
|
||||
@@ -2,17 +2,17 @@ package infra
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
eig "simrs-vx/internal/domain/main-entities/infra-group"
|
||||
ei "simrs-vx/internal/domain/main-entities/item"
|
||||
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
)
|
||||
|
||||
type Infra struct {
|
||||
ecore.SmallMain // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:10"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
InfraGroup_Code *string `json:"infraGroup_code" gorm:"size:10"`
|
||||
InfraGroup *eig.InfraGroup `json:"infraGroup,omitempty" gorm:"foreignKey:InfraGroup_Code;references:Code"`
|
||||
Parent_Id *int16 `json:"parent_id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
|
||||
ecore.SmallMain // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:10"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code" gorm:"size:10"`
|
||||
Parent_Id *uint16 `json:"parent_id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
|
||||
}
|
||||
|
||||
@@ -6,15 +6,15 @@ import (
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
EncounterClass_Code ere.EncounterClass `json:"encounterClass_code"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
EncounterClass_Code ere.EncounterClass `json:"encounterClass_code"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code"`
|
||||
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
@@ -22,10 +22,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
EncounterClass_Code ere.EncounterClass `json:"encounterClass_code"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -45,9 +43,9 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.SmallMain
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
EncounterClass_Code ere.EncounterClass `json:"encounterClass_code"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
EncounterClass_Code ere.EncounterClassCode `json:"encounterClass_code"`
|
||||
}
|
||||
|
||||
func (d Installation) ToResponse() ResponseDto {
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
)
|
||||
|
||||
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.EncounterClass `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"`
|
||||
}
|
||||
|
||||
@@ -14,6 +14,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Regency_Code *string `json:"regency_code"`
|
||||
@@ -26,12 +32,9 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
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"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
PhoneNumber *string `json:"phoneNumber"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package itemgroup
|
||||
|
||||
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.Main
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (d ItemGroup) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Code: d.Code,
|
||||
Name: d.Name,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []ItemGroup) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package itemgroup
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
)
|
||||
|
||||
type ItemGroup struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:50"`
|
||||
Name string `json:"name" gorm:"size:100"`
|
||||
}
|
||||
@@ -13,6 +13,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Price float64 `json:"price"`
|
||||
InsuranceCompany_Code *string `json:"insuranceCompany_code"`
|
||||
@@ -21,12 +27,9 @@ type ReadListDto struct {
|
||||
PageSize int `json:"page_size"`
|
||||
NoPagination int `json:"no_pagination"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Price float64 `json:"price"`
|
||||
InsuranceCompany_Code *string `json:"insuranceCompany_code"`
|
||||
Id uint16 `json:"id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -2,26 +2,32 @@ package item
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
eig "simrs-vx/internal/domain/main-entities/item-group"
|
||||
eu "simrs-vx/internal/domain/main-entities/uom"
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
ItemGroup_Code *string `json:"itemGroup_code"`
|
||||
Uom_Code *string `json:"uom_code"`
|
||||
Infra_Id *uint16 `json:"infra_id"`
|
||||
Stock *int `json:"stock"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
ItemGroup_Code ero.ItemGroupCode `json:"itemGroup_code"`
|
||||
Uom_Code *string `json:"uom_code"`
|
||||
Infra_Id *uint16 `json:"infra_id"`
|
||||
Stock *int `json:"stock"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
ItemGroup_Code *string `json:"itemGroup_code"`
|
||||
Uom_Code *string `json:"uom_code"`
|
||||
Infra_Id *uint16 `json:"infra_id"`
|
||||
Stock *int `json:"stock"`
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
ItemGroup_Code ero.ItemGroupCode `json:"itemGroup_code"`
|
||||
Uom_Code *string `json:"uom_code"`
|
||||
Infra_Id *uint16 `json:"infra_id"`
|
||||
Stock *int `json:"stock"`
|
||||
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
@@ -29,13 +35,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
ItemGroup_Code *string `json:"itemGroup_code"`
|
||||
Uom_Code *string `json:"uom_code"`
|
||||
Infra_Id *int16 `json:"infra_id"`
|
||||
Stock *int `json:"stock"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -55,14 +56,13 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
ItemGroup_Code *string `json:"itemGroup_code"`
|
||||
ItemGroup *eig.ItemGroup `json:"itemGroup,omitempty"`
|
||||
Uom_Code *string `json:"uom_code"`
|
||||
Uom *eu.Uom `json:"uom,omitempty"`
|
||||
Infra_Id *uint16 `json:"infra_id"`
|
||||
Stock *int `json:"stock"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
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"`
|
||||
Stock *int `json:"stock"`
|
||||
}
|
||||
|
||||
func (d Item) ToResponse() ResponseDto {
|
||||
@@ -70,7 +70,6 @@ func (d Item) ToResponse() ResponseDto {
|
||||
Code: d.Code,
|
||||
Name: d.Name,
|
||||
ItemGroup_Code: d.ItemGroup_Code,
|
||||
ItemGroup: d.ItemGroup,
|
||||
Uom_Code: d.Uom_Code,
|
||||
Uom: d.Uom,
|
||||
Infra_Id: d.Infra_Id,
|
||||
|
||||
@@ -2,18 +2,18 @@ package item
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
eig "simrs-vx/internal/domain/main-entities/item-group"
|
||||
eu "simrs-vx/internal/domain/main-entities/uom"
|
||||
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
)
|
||||
|
||||
type Item struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:50"`
|
||||
Name string `json:"name" gorm:"size:100"`
|
||||
ItemGroup_Code *string `json:"itemGroup_code" gorm:"size:10"`
|
||||
ItemGroup *eig.ItemGroup `json:"itemGroup,omitempty" gorm:"foreignKey:ItemGroup_Code;references:Code"`
|
||||
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"`
|
||||
Stock *int `json:"stock"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:50"`
|
||||
Name string `json:"name" gorm:"size:100"`
|
||||
ItemGroup_Code ero.ItemGroupCode `json:"itemGroup_code" gorm:"size:10"`
|
||||
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"`
|
||||
Stock *int `json:"stock"`
|
||||
}
|
||||
|
||||
@@ -2,24 +2,33 @@ package material
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ein "simrs-vx/internal/domain/main-entities/infra"
|
||||
ei "simrs-vx/internal/domain/main-entities/item"
|
||||
eu "simrs-vx/internal/domain/main-entities/uom"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Uom_Code string `json:"uom_code"`
|
||||
Stock *int `json:"stock"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Uom_Code string `json:"uom_code"`
|
||||
Stock *int `json:"stock"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
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"`
|
||||
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
@@ -27,12 +36,9 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Uom_Code string `json:"uom_code"`
|
||||
Stock *int `json:"stock"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -52,13 +58,15 @@ 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"`
|
||||
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_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"`
|
||||
}
|
||||
|
||||
func (d Material) ToResponse() ResponseDto {
|
||||
@@ -67,6 +75,8 @@ func (d Material) ToResponse() ResponseDto {
|
||||
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,
|
||||
|
||||
@@ -2,17 +2,20 @@ package material
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ein "simrs-vx/internal/domain/main-entities/infra"
|
||||
ei "simrs-vx/internal/domain/main-entities/item"
|
||||
eu "simrs-vx/internal/domain/main-entities/uom"
|
||||
)
|
||||
|
||||
type Material struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:10"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
Uom_Code string `json:"uom_code" gorm:"size:10"`
|
||||
Uom *eu.Uom `json:"uom,omitempty" gorm:"foreignKey:Uom_Code;references:Code"`
|
||||
Stock *int `json:"stock"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:10"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
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 *ein.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Id;references:Id"`
|
||||
Stock *int `json:"stock"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
|
||||
}
|
||||
|
||||
@@ -2,19 +2,19 @@ package division
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erc "simrs-vx/internal/domain/references/clinical"
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Scope_Code *erc.CheckupScopeCode `json:"scope_code"`
|
||||
Scope_Code *ere.CheckupScopeCode `json:"scope_code"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Scope_Code *erc.CheckupScopeCode `json:"scope_code"`
|
||||
Scope_Code *ere.CheckupScopeCode `json:"scope_code"`
|
||||
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
@@ -22,10 +22,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Scope_Code *erc.CheckupScopeCode `json:"scope_code"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -47,7 +45,7 @@ type ResponseDto struct {
|
||||
ecore.SmallMain
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Scope_Code *erc.CheckupScopeCode `json:"scope_code"`
|
||||
Scope_Code *ere.CheckupScopeCode `json:"scope_code"`
|
||||
}
|
||||
|
||||
func (d McuSrcCategory) ToResponse() ResponseDto {
|
||||
|
||||
@@ -2,12 +2,12 @@ package division
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erc "simrs-vx/internal/domain/references/clinical"
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
)
|
||||
|
||||
type McuSrcCategory struct {
|
||||
ecore.SmallMain // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:20"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
Scope_Code *erc.CheckupScopeCode `json:"scope_code" gorm:"size:10"`
|
||||
Scope_Code *ere.CheckupScopeCode `json:"scope_code" gorm:"size:10"`
|
||||
}
|
||||
|
||||
@@ -11,6 +11,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
CheckupCategory_Code *string `json:"checkupCategory_code"`
|
||||
@@ -21,10 +27,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
CheckupCategory_Code *string `json:"checkupCategory_code"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -2,11 +2,13 @@ package mcusrc
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
emsc "simrs-vx/internal/domain/main-entities/mcu-src-category"
|
||||
)
|
||||
|
||||
type McuSrc struct {
|
||||
ecore.SmallMain // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:20"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
CheckupCategory_Code *string `json:"checkupCategory_code" gorm:"size:20"`
|
||||
ecore.SmallMain // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:20"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
CheckupCategory_Code *string `json:"checkupCategory_code" gorm:"size:20"`
|
||||
CheckupCategory *emsc.McuSrcCategory `json:"checkupCategory,omitempty" gorm:"foreignKey:CheckupCategory_Code;references:Code"`
|
||||
}
|
||||
|
||||
@@ -14,6 +14,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
MedicalActionSrc_Id *uint `json:"medicalActionSrc_id"`
|
||||
ProcedureSrc_Id *uint `json:"procedureSrc_id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
@@ -24,10 +30,7 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
MedicalActionSrc_Id *uint `json:"medicalActionSrc_id"`
|
||||
ProcedureSrc_Id *uint `json:"procedureSrc_id"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Id uint16 `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -12,6 +12,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
@@ -22,10 +28,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -19,9 +19,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -19,9 +19,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -13,6 +13,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
MedicineMix_Id *uint `json:"medicineMix_id"`
|
||||
Medicine_Id *uint `json:"medicine_id"`
|
||||
Dose *uint8 `json:"dose"`
|
||||
@@ -23,10 +29,7 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
MedicineMix_Id *uint `json:"medicineMix_id"`
|
||||
Medicine_Id *uint `json:"medicine_id"`
|
||||
Dose *uint8 `json:"dose"`
|
||||
Id uint16 `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -17,8 +17,7 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Id uint16 `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -10,19 +10,24 @@ import (
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
MedicineGroup_Code *string `json:"medicineGroup_code"`
|
||||
MedicineMethod_Code *string `json:"medicineMethod_code"`
|
||||
Uom_Code *string `json:"uom_code"`
|
||||
Dose uint8 `json:"dose"`
|
||||
Infra_Id *uint16 `json:"infra_id"`
|
||||
Stock *int `json:"stock"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
InsuranceCompany_Code *string `json:"insuranceCompany_code"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
MedicineGroup_Code *string `json:"medicineGroup_code"`
|
||||
MedicineMethod_Code *string `json:"medicineMethod_code"`
|
||||
Uom_Code *string `json:"uom_code"`
|
||||
Dose uint8 `json:"dose"`
|
||||
Infra_Id *uint16 `json:"infra_id"`
|
||||
Stock *int `json:"stock"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
MedicineGroup_Code *string `json:"medicineGroup_code"`
|
||||
@@ -39,16 +44,9 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
MedicineGroup_Code *string `json:"medicineGroup_code"`
|
||||
MedicineMethod_Code *string `json:"medicineMethod_code"`
|
||||
Uom_Code *string `json:"uom_code"`
|
||||
Dose uint8 `json:"dose"`
|
||||
Infra_Id *uint16 `json:"infra_id"`
|
||||
Stock *int `json:"stock"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
Item_Id *uint `json:"item_id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -11,6 +11,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
IHS_Number *string `json:"ihs_number"`
|
||||
|
||||
@@ -18,7 +24,6 @@ type ReadListDto struct {
|
||||
PageSize int `json:"page_size"`
|
||||
NoPagination int `json:"no_pagination"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
|
||||
@@ -11,6 +11,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
IHS_Number *string `json:"ihs_number"`
|
||||
|
||||
|
||||
@@ -19,12 +19,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint `json:"id"`
|
||||
Person_Id uint `json:"person_id"`
|
||||
Address string `json:"address"`
|
||||
Rt string `json:"rt"`
|
||||
Rw string `json:"rw"`
|
||||
Village_Code string `json:"village_code"`
|
||||
Id uint `json:"id"`
|
||||
Person_Id uint `json:"person_id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -18,10 +18,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint `json:"id"`
|
||||
Person_Id uint `json:"person_id"`
|
||||
Type_Code erp.ContactTypeCode `json:"type_code"`
|
||||
Value string `json:"value"`
|
||||
Id uint `json:"id"`
|
||||
Person_Id uint `json:"person_id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -11,6 +11,8 @@ import (
|
||||
|
||||
type CreateDto struct {
|
||||
Name string `json:"name"`
|
||||
FrontTitle *string `json:"frontTitle"`
|
||||
EndTitle *string `json:"endTitle"`
|
||||
BirthDate *time.Time `json:"birthDate,omitempty"`
|
||||
BirthRegency_Code *string `json:"birthRegency_code"`
|
||||
Gender_Code *erp.GenderCode `json:"gender_code"`
|
||||
@@ -23,14 +25,15 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
NoPagination int `json:"no_pagination"`
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint `json:"id"`
|
||||
type FilterDto struct {
|
||||
Name string `json:"name"`
|
||||
FrontTitle *string `json:"frontTitle"`
|
||||
EndTitle *string `json:"endTitle"`
|
||||
BirthDate *time.Time `json:"birthDate,omitempty"`
|
||||
BirthRegency_Code *string `json:"birthRegency_code"`
|
||||
Gender_Code *erp.GenderCode `json:"gender_code"`
|
||||
@@ -40,6 +43,16 @@ type ReadDetailDto struct {
|
||||
Ocupation_Code *erp.OcupationCode `json:"occupation_code"`
|
||||
Ocupation_Name *string `json:"occupation_name"`
|
||||
Ethnic_Code *string `json:"ethnic_code"`
|
||||
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
NoPagination int `json:"no_pagination"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint `json:"id"`
|
||||
Name *string `json:"name"`
|
||||
ResidentIdentityNumber *string `json:"residentIdentityNumber"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -60,6 +73,8 @@ type MetaDto struct {
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Name string `json:"name"`
|
||||
FrontTitle *string `json:"frontTitle"`
|
||||
EndTitle *string `json:"endTitle"`
|
||||
BirthDate *time.Time `json:"birthDate,omitempty"`
|
||||
BirthRegency_Code *string `json:"birthRegency_code"`
|
||||
Gender_Code *erp.GenderCode `json:"gender_code"`
|
||||
@@ -77,6 +92,8 @@ type ResponseDto struct {
|
||||
func (d *Person) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Name: d.Name,
|
||||
FrontTitle: d.FrontTitle,
|
||||
EndTitle: d.EndTitle,
|
||||
BirthDate: d.BirthDate,
|
||||
BirthRegency_Code: d.BirthRegency_Code,
|
||||
Gender_Code: d.Gender_Code,
|
||||
|
||||
@@ -13,6 +13,8 @@ import (
|
||||
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"`
|
||||
|
||||
@@ -11,6 +11,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
IHS_Number *string `json:"ihs_number"`
|
||||
|
||||
|
||||
@@ -21,10 +21,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Regency_Code string `json:"regency_code"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -2,21 +2,27 @@ package practiceschedule
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erx "simrs-vx/internal/domain/references/xtime"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
Day_Code *erx.DayCode `json:"day_code"`
|
||||
Day_Code *erc.DayCode `json:"day_code"`
|
||||
StartTime *string `json:"startTime"`
|
||||
EndTime *string `json:"endTime"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
Day_Code *erx.DayCode `json:"day_code"`
|
||||
Day_Code *erc.DayCode `json:"day_code"`
|
||||
StartTime *string `json:"startTime"`
|
||||
EndTime *string `json:"endTime"`
|
||||
|
||||
@@ -26,12 +32,7 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
Day_Code *erx.DayCode `json:"day_code"`
|
||||
StartTime *string `json:"startTime"`
|
||||
EndTime *string `json:"endTime"`
|
||||
Id uint16 `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -53,7 +54,7 @@ type ResponseDto struct {
|
||||
ecore.Main
|
||||
Doctor_Id *uint `json:"doctor_id"`
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
Day_Code *erx.DayCode `json:"day_code"`
|
||||
Day_Code *erc.DayCode `json:"day_code"`
|
||||
StartTime *string `json:"startTime"`
|
||||
EndTime *string `json:"endTime"`
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
eu "simrs-vx/internal/domain/main-entities/unit"
|
||||
erx "simrs-vx/internal/domain/references/xtime"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type PracticeSchedule struct {
|
||||
@@ -13,7 +13,7 @@ type PracticeSchedule struct {
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Id;references:Id"`
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Code;references:Code"`
|
||||
Day_Code *erx.DayCode `json:"day_code"`
|
||||
Day_Code *erc.DayCode `json:"day_code"`
|
||||
StartTime *string `json:"startTime" gorm:"size:5"`
|
||||
EndTime *string `json:"endTime" gorm:"size:5"`
|
||||
}
|
||||
|
||||
@@ -21,10 +21,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
IndName string `json:"indName"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -15,9 +15,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id int16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Id int16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -19,10 +19,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Province_Code string `json:"province_code"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -12,6 +12,12 @@ type CreateDto struct {
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Installation_Id *uint16 `json:"installation_id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
@@ -22,10 +28,9 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Installation_Id *uint16 `json:"installation_id"`
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Installation_Id *uint16 `json:"installation_id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -19,9 +19,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Id uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Name string `json:"name"`
|
||||
Password string `json:"password"`
|
||||
Status_Code erc.StatusCode `json:"status_code"`
|
||||
Name string `json:"name"`
|
||||
Password string `json:"password"`
|
||||
Status_Code erc.UserStatusCode `json:"status_code"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
Name string `json:"name"`
|
||||
Status_Code erc.StatusCode `json:"status_code"`
|
||||
Name string `json:"name"`
|
||||
Status_Code erc.UserStatusCode `json:"status_code"`
|
||||
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
@@ -22,8 +22,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Id uint `json:"id"`
|
||||
Name *string `json:"name"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
@@ -49,11 +49,11 @@ type LoginDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Name string `json:"name"`
|
||||
Status_Code erc.StatusCode `json:"status_code"`
|
||||
FailedLoginCount uint8 `json:"failedLoginCount"`
|
||||
LastSuccessLogin *time.Time `json:"lastSuccessLogin,omitempty"`
|
||||
LastAllowdLogin *time.Time `json:"lastAllowdLogin,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Status_Code erc.UserStatusCode `json:"status_code"`
|
||||
FailedLoginCount uint8 `json:"failedLoginCount"`
|
||||
LastSuccessLogin *time.Time `json:"lastSuccessLogin,omitempty"`
|
||||
LastAllowdLogin *time.Time `json:"lastAllowdLogin,omitempty"`
|
||||
}
|
||||
|
||||
func (d *User) ToResponse() ResponseDto {
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Name string `json:"name" gorm:"not null;size:25"`
|
||||
Password string `json:"password" gorm:"not null;size:255"`
|
||||
Status_Code erc.StatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
FailedLoginCount uint8 `json:"failedLoginCount" gorm:"type:smallint"`
|
||||
LoginAttemptCount int `json:"-"`
|
||||
LastSuccessLogin *time.Time `json:"lastSuccessLogin,omitempty"`
|
||||
LastAllowdLogin *time.Time `json:"lastAllowdLogin,omitempty"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Name string `json:"name" gorm:"unique;not null;size:25"`
|
||||
Password string `json:"password" gorm:"not null;size:255"`
|
||||
Status_Code erc.UserStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
FailedLoginCount uint8 `json:"failedLoginCount" gorm:"type:smallint"`
|
||||
LoginAttemptCount int `json:"-"`
|
||||
LastSuccessLogin *time.Time `json:"lastSuccessLogin,omitempty"`
|
||||
LastAllowdLogin *time.Time `json:"lastAllowdLogin,omitempty"`
|
||||
}
|
||||
|
||||
@@ -17,10 +17,8 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint32 `json:"id"`
|
||||
District_Code string `json:"district_code"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Id uint32 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
|
||||
@@ -1,18 +1,38 @@
|
||||
package clinical
|
||||
|
||||
type (
|
||||
CheckupScopeCode string
|
||||
DoctorFeeTypeCode string
|
||||
SubjectCode string
|
||||
ObjectCode string
|
||||
AssessmentCode string
|
||||
InstructionCode string
|
||||
)
|
||||
|
||||
const (
|
||||
CSCLab CheckupScopeCode = "lab" // Laboratorium
|
||||
CSCMLab CheckupScopeCode = "mic-lab" // Microbacterial Laboratorium
|
||||
CSCPLab CheckupScopeCode = "pa-lab" // Patology Anatomy Laboratorium
|
||||
CSCRad CheckupScopeCode = "radiology" // Radiology
|
||||
SCPrimaryComplaint SubjectCode = "pri-compl" // Keluhan Utama
|
||||
SCSecComplaint SubjectCode = "sec-compl" // Secondary Complaint
|
||||
SCCurrentDiseaseHistory SubjectCode = "cur-disea-hist" // Current Disease History
|
||||
SCPastDiseaseHistory SubjectCode = "pas-disea-hist" // Past Disease History
|
||||
SCFamilyDiseaseHistory SubjectCode = "fam-disea-hist" // Family Disease History
|
||||
SCAllergyHistory SubjectCode = "alg-hist" // Allergic History
|
||||
SCAllergyReaction SubjectCode = "alg-react" // Allergic Reaction
|
||||
SCMedicationHistory SubjectCode = "med-hist" // Medication History
|
||||
|
||||
DFTCOut DoctorFeeTypeCode = "outpatient" // Rawat Jalan
|
||||
DFTCInp DoctorFeeTypeCode = "inpatient" // Rawat Inap
|
||||
DFTCEme DoctorFeeTypeCode = "emergency" // Darurat
|
||||
DFTCReh DoctorFeeTypeCode = "medic-rehab" // Rehab Medik
|
||||
OCConsciousnessLevel ObjectCode = "consc-level" // Tingkat Kesadaran
|
||||
OCConsciousnessLevelDet ObjectCode = "consc-level-det" // Detail Tingkat Kesadaran
|
||||
OCSystolicBloodPressure ObjectCode = "syst-bp" // Tekanan Darah Systolic
|
||||
OCDiastolicBloodPressure ObjectCode = "diast-bp" // Tekanan Darah Diastolic
|
||||
OCHeartRate ObjectCode = "hear-rt" // Detak Jantung
|
||||
OCTemperature ObjectCode = "temp" // Suhu
|
||||
OCSpO2 ObjectCode = "spo2" // SpO2
|
||||
OCWeight ObjectCode = "weight" // Berat Badan
|
||||
OCHeight ObjectCode = "height" // Tinggi Badan
|
||||
|
||||
ACEarlyDiag AssessmentCode = "early-diag" // Diagnosis Awal
|
||||
ACLateDiag AssessmentCode = "late-diag" // Diagnosis Akhir
|
||||
ACSecDiag AssessmentCode = "sec-diag" // Diagnosis Sekunder
|
||||
|
||||
ICDetail InstructionCode = "detail" // Detail instruksi
|
||||
ICMedAct InstructionCode = "med-act" // Tindakan medis
|
||||
ICMedication InstructionCode = "medication" // Obat
|
||||
ICMaterial InstructionCode = "material" // BMHP
|
||||
)
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package common
|
||||
|
||||
type (
|
||||
YaTidakCode byte
|
||||
SudahBelumCode byte
|
||||
AktifSimpelCode byte
|
||||
AktifAdvanceCode byte
|
||||
TersediaCode byte
|
||||
StatusCode string
|
||||
YaTidakCode byte
|
||||
SudahBelumCode byte
|
||||
AktifSimpelCode byte
|
||||
AktifAdvanceCode byte
|
||||
TersediaCode byte
|
||||
DayCode byte
|
||||
ActiveStatusCode string
|
||||
DataStatusCode string
|
||||
UserStatusCode string
|
||||
TimeUnitCode string
|
||||
PaymentMethodCode string
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -35,9 +40,61 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
SCNew StatusCode = "new"
|
||||
SCActive StatusCode = "active"
|
||||
SCInactive StatusCode = "inactive"
|
||||
SCBlocked StatusCode = "blocked"
|
||||
SCSuspended StatusCode = "suspended"
|
||||
DCMinggu DayCode = iota
|
||||
DCSenin
|
||||
DCSelasa
|
||||
DCRabu
|
||||
DCKamis
|
||||
DCJumat
|
||||
DCSabtu
|
||||
)
|
||||
|
||||
const (
|
||||
SCActive ActiveStatusCode = "active" // Aktif
|
||||
SCInactive ActiveStatusCode = "inactive" // Tidak aktif
|
||||
|
||||
DSCNew DataStatusCode = "new" // Baru
|
||||
DSCReview DataStatusCode = "review" // Review
|
||||
DSCProcess DataStatusCode = "process" // Proses
|
||||
DSCDone DataStatusCode = "done" // Selesai
|
||||
DSCCancel DataStatusCode = "cancel" // Dibatalkan
|
||||
DSCRejected DataStatusCode = "rejected" // Ditolak
|
||||
DSCSkipped DataStatusCode = "skipped" // Dilewati
|
||||
|
||||
USCNew UserStatusCode = "new" // Baru
|
||||
USCActive UserStatusCode = "active" // Aktif
|
||||
USCInactive UserStatusCode = "inactive" // Tidak aktif
|
||||
USCBlocked UserStatusCode = "blocked" // Diblokir
|
||||
USCSuspended UserStatusCode = "suspended" // Dibekukan
|
||||
|
||||
TUCSec TimeUnitCode = "sec" // Detik
|
||||
TUCMin TimeUnitCode = "min" // Menit
|
||||
TUCHour TimeUnitCode = "hour" // Jam
|
||||
TUCDay TimeUnitCode = "day" // Hari
|
||||
TUCWeek TimeUnitCode = "week" // Minggu
|
||||
TUCMonth TimeUnitCode = "month" // Bulan
|
||||
TUCYear TimeUnitCode = "year" // Tahun
|
||||
|
||||
PMCCash PaymentMethodCode = "cash" // Tunai
|
||||
PMCDebit PaymentMethodCode = "debit" // Debet
|
||||
PMCCredit PaymentMethodCode = "credit" // Kredit
|
||||
PMCInsurance PaymentMethodCode = "insurance" // Asuransi
|
||||
PMCMembership PaymentMethodCode = "membership" // Member
|
||||
|
||||
)
|
||||
|
||||
func GetDayCodes() map[DayCode]string {
|
||||
return map[DayCode]string{
|
||||
DCMinggu: "Minggu",
|
||||
DCSenin: "Senin",
|
||||
DCSelasa: "Selasa",
|
||||
DCRabu: "Rabu",
|
||||
DCKamis: "Kamis",
|
||||
DCJumat: "Jumat",
|
||||
DCSabtu: "Sabtu",
|
||||
}
|
||||
}
|
||||
|
||||
func (obj DayCode) String() string {
|
||||
return GetDayCodes()[obj]
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package digitalsignature
|
||||
|
||||
type (
|
||||
RMEType string
|
||||
SignType string
|
||||
)
|
||||
|
||||
const (
|
||||
// modules
|
||||
RMETypePrescription RMEType = "prescription"
|
||||
RMETypeExamination RMEType = "examination"
|
||||
RMETypeRadiology RMEType = "radiology"
|
||||
RMETypeSick RMEType = "sick"
|
||||
RMETypeReferral RMEType = "referral"
|
||||
RMETypeEndOfLife RMEType = "endoflife"
|
||||
RMETypeChangeDpjp RMEType = "changedpjp"
|
||||
|
||||
// employee
|
||||
SignTypeEmployee SignType = "employee"
|
||||
|
||||
// doctor
|
||||
SignTypeDoctor SignType = "doctor"
|
||||
|
||||
// patient
|
||||
SignTypePatient SignType = "patient"
|
||||
)
|
||||
@@ -1,32 +1,63 @@
|
||||
package encounter
|
||||
|
||||
type (
|
||||
EncounterStatus string
|
||||
EncounterClass string
|
||||
EmergencyClass string
|
||||
InpatientClass string
|
||||
EncounterClassCode string
|
||||
QueueStatusCode string
|
||||
DischargeMethodCode string
|
||||
TransportationCode string
|
||||
PersonConditionCode string
|
||||
EmergencyClassCode string
|
||||
OutpatientClassCode string
|
||||
CheckupScopeCode string
|
||||
)
|
||||
|
||||
const (
|
||||
EncounterStatusNew EncounterStatus = "new"
|
||||
EncounterStatusNurse EncounterStatus = "nurse assessment"
|
||||
EncounterStatusDoctor EncounterStatus = "doctor assessment"
|
||||
EncounterStatusDone EncounterStatus = "done"
|
||||
EncounterStatusCancel EncounterStatus = "canceled"
|
||||
)
|
||||
const (
|
||||
IGD EmergencyClass = "igd"
|
||||
Ponek EmergencyClass = "ponek"
|
||||
)
|
||||
const (
|
||||
ECAmbulatory EncounterClass = "ambulatory"
|
||||
ECOutpatient EncounterClass = "outpatient"
|
||||
ECInpatient EncounterClass = "inpatient"
|
||||
ECEmergency EncounterClass = "emergency"
|
||||
ECRadiology EncounterClass = "radiology"
|
||||
ECOutpatient EncounterClassCode = "outpatient"
|
||||
ECAmbulatory EncounterClassCode = "ambulatory"
|
||||
ECEmergency EncounterClassCode = "emergency"
|
||||
ECInpatient EncounterClassCode = "inpatient"
|
||||
ECDraft EncounterClassCode = "draft"
|
||||
ECDone EncounterClassCode = "done"
|
||||
ECCancel EncounterClassCode = "cancel"
|
||||
ECSkip EncounterClassCode = "skip"
|
||||
|
||||
QSCWait QueueStatusCode = "wait" // Tunggu
|
||||
QSCProc QueueStatusCode = "proc" // Proses
|
||||
QSCDone QueueStatusCode = "done" // Selesai
|
||||
QSCCancel QueueStatusCode = "cancel" // Dibatalkan
|
||||
QSCSkip QueueStatusCode = "skip" // Dilewati
|
||||
|
||||
DMCHome DischargeMethodCode = "home" // Rumah
|
||||
DMCHomeReq DischargeMethodCode = "home-request" // Rumah (Dibutuhkan)
|
||||
|
||||
TCAmbulance TransportationCode = "ambulance"
|
||||
TCCar TransportationCode = "car"
|
||||
TCMotorCycle TransportationCode = "motor-cycle"
|
||||
TCOther TransportationCode = "other"
|
||||
|
||||
PCCRes PersonConditionCode = "res" // Resutiasi
|
||||
PCCEmg PersonConditionCode = "emg" // Darurat
|
||||
PCCUrg PersonConditionCode = "urg" // Mendesak
|
||||
PCCLurg PersonConditionCode = "lurg" // Kurang mendesak
|
||||
PCCNurg PersonConditionCode = "nurg" //
|
||||
PCCDoa PersonConditionCode = "doa" // Meninggal saat tiba
|
||||
|
||||
ECCEmg EmergencyClassCode = "emg" // Darurat/Emergency biasa
|
||||
ECCEon EmergencyClassCode = "eon" // Ponek/Emergency obstetri neonatal
|
||||
|
||||
OCCOp OutpatientClassCode = "op" // Rawat Jalan
|
||||
OCCIcu OutpatientClassCode = "icu" // ICU
|
||||
OCCHcu OutpatientClassCode = "hcu" // HCU
|
||||
OCCVk OutpatientClassCode = "vk" // Verlos kamer
|
||||
|
||||
CSCLab CheckupScopeCode = "lab" // Laboratorium
|
||||
CSCMLab CheckupScopeCode = "mic-lab" // Microbacterial Laboratorium
|
||||
CSCPLab CheckupScopeCode = "pa-lab" // Patology Anatomy Laboratorium
|
||||
CSCRad CheckupScopeCode = "radiology" // Radiology
|
||||
|
||||
)
|
||||
|
||||
func (ec EncounterClass) Code() string {
|
||||
func (ec EncounterClassCode) Code() string {
|
||||
switch ec {
|
||||
case ECAmbulatory, ECOutpatient:
|
||||
return "AMB"
|
||||
@@ -38,8 +69,3 @@ func (ec EncounterClass) Code() string {
|
||||
return "UNKNOWN"
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
ICU InpatientClass = "ICU"
|
||||
NonICU InpatientClass = "non ICU"
|
||||
)
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
package finance
|
||||
|
||||
type (
|
||||
PaymentMethodCode string
|
||||
TaxCode string
|
||||
PaymentStatusCode string
|
||||
ServiceType string
|
||||
)
|
||||
|
||||
const (
|
||||
PMCCash PaymentMethodCode = "cash"
|
||||
PMCBPJS PaymentMethodCode = "bpjs"
|
||||
PMCInsurance PaymentMethodCode = "insurance"
|
||||
PMCMembership PaymentMethodCode = "membership"
|
||||
PMCDebit PaymentMethodCode = "debit"
|
||||
PMCCredit PaymentMethodCode = "credit"
|
||||
PMCOther PaymentMethodCode = "other"
|
||||
)
|
||||
|
||||
const (
|
||||
TCCountry TaxCode = "country"
|
||||
)
|
||||
|
||||
const (
|
||||
PaymentStatusNew PaymentStatusCode = "new"
|
||||
PaymentStatusUnpaid PaymentStatusCode = "unpaid"
|
||||
PaymentStatusPaid PaymentStatusCode = "paid"
|
||||
PaymentStatusCancel PaymentStatusCode = "cancel"
|
||||
PaymentStatusFailed PaymentStatusCode = "failed"
|
||||
)
|
||||
|
||||
func GetTaxeCodes() map[TaxCode]float32 {
|
||||
return map[TaxCode]float32{
|
||||
TCCountry: 0.11,
|
||||
}
|
||||
}
|
||||
|
||||
var NonInsurancePaymentMethods = map[PaymentMethodCode]bool{
|
||||
PMCCash: true,
|
||||
PMCDebit: true,
|
||||
PMCCredit: true,
|
||||
}
|
||||
|
||||
func (p PaymentMethodCode) IsInsurance() bool {
|
||||
switch p {
|
||||
case PMCCash, PMCDebit, PMCCredit, PMCBPJS:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
STInpatient = "Rawat Inap"
|
||||
STAmbulatory = "Rawat Jalan"
|
||||
STEmergency = "IGD"
|
||||
STPonek = "PONEK"
|
||||
STLab = "Laboratorium"
|
||||
STRadiology = "Radiologi"
|
||||
)
|
||||
|
||||
const (
|
||||
AdminEmergencyFee = "Biaya Administrasi IGD"
|
||||
DoctorEmergencyFee = "Biaya Dokter IGD"
|
||||
AdminPediatricInternalFee = "Biaya Administrasi Poli Anak/Penyakit Dalam"
|
||||
AdminGeneralPolyFee = "Biaya Administrasi Poli"
|
||||
)
|
||||
@@ -2,15 +2,45 @@ package organization
|
||||
|
||||
type (
|
||||
EmployeePosisitionCode string
|
||||
ItemGroupCode string
|
||||
InfraGroupCode string
|
||||
UnitTypeCode string
|
||||
DoctorFeeTypeCode string
|
||||
)
|
||||
|
||||
const (
|
||||
EPCDoc EmployeePosisitionCode = "doctor"
|
||||
EPCNur EmployeePosisitionCode = "nurse"
|
||||
EPCNut EmployeePosisitionCode = "nutritionist"
|
||||
EPCLab EmployeePosisitionCode = "laborant"
|
||||
EPCPha EmployeePosisitionCode = "pharmacy"
|
||||
EPCPay EmployeePosisitionCode = "payment"
|
||||
EPCPav EmployeePosisitionCode = "payment-verificator"
|
||||
EPCMan EmployeePosisitionCode = "management"
|
||||
EPCDoc EmployeePosisitionCode = "doctor" // Dokter
|
||||
EPCNur EmployeePosisitionCode = "nurse" // Perawat
|
||||
EPCNut EmployeePosisitionCode = "nutritionist" // Ahli gizi
|
||||
EPCLab EmployeePosisitionCode = "laborant" // Laboran
|
||||
EPCPha EmployeePosisitionCode = "pharmacy" // Farmasi
|
||||
EPCPay EmployeePosisitionCode = "payment" // Pembayaran
|
||||
EPCPav EmployeePosisitionCode = "payment-verificator" // Konfirmasi pembayaran
|
||||
EPCMan EmployeePosisitionCode = "management" // Manajemen
|
||||
|
||||
ITGCInfra ItemGroupCode = "infra"
|
||||
ITGCMedicine ItemGroupCode = "medicine"
|
||||
ITGCDevice ItemGroupCode = "device"
|
||||
ITGCMaterial ItemGroupCode = "material"
|
||||
ITGCEmpFee ItemGroupCode = "employee-fee"
|
||||
ITGCDocFee ItemGroupCode = "doctor-fee"
|
||||
|
||||
IFGCBuilding InfraGroupCode = "building"
|
||||
IFGCFloor InfraGroupCode = "floor"
|
||||
IFGCRoom InfraGroupCode = "room"
|
||||
IFGCChamber InfraGroupCode = "chamber"
|
||||
IFGCBed InfraGroupCode = "bed"
|
||||
IFGCWarehouse InfraGroupCode = "warehouse"
|
||||
|
||||
UTCReg UnitTypeCode = "reg" // Registrasi
|
||||
UTCExa UnitTypeCode = "exa" // Pemeriksaan
|
||||
UTCPay UnitTypeCode = "pay" // Pembayaran
|
||||
UTCPha UnitTypeCode = "pha" // Farmasi
|
||||
UTCLab UnitTypeCode = "lab" // Laboratorium
|
||||
UTCRad UnitTypeCode = "rad" // Radiologi
|
||||
|
||||
DFTCOut DoctorFeeTypeCode = "outpatient" // Rawat Jalan
|
||||
DFTCInp DoctorFeeTypeCode = "inpatient" // Rawat Inap
|
||||
DFTCEme DoctorFeeTypeCode = "emergency" // Darurat
|
||||
DFTCReh DoctorFeeTypeCode = "medic-rehab" // Rehab Medik
|
||||
)
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
package patient
|
||||
|
||||
type (
|
||||
ConsciousLevelCode string
|
||||
StatusCode string
|
||||
PaymentMethodCode string
|
||||
EndAssessmentCode string
|
||||
VisitTypeJknCode uint8
|
||||
)
|
||||
|
||||
const (
|
||||
CLCAlert ConsciousLevelCode = "alert"
|
||||
CLCVoice ConsciousLevelCode = "voice"
|
||||
CLCPain ConsciousLevelCode = "pain"
|
||||
CLCUnresponsive ConsciousLevelCode = "unresponsive"
|
||||
CLCAnxious ConsciousLevelCode = "anxious"
|
||||
CLCAcuteConfusional ConsciousLevelCode = "acute-confuncional"
|
||||
|
||||
PMCCash PaymentMethodCode = "cash"
|
||||
PMCDebit PaymentMethodCode = "debit"
|
||||
PMCCredit PaymentMethodCode = "credit"
|
||||
PMCBpjs PaymentMethodCode = "bpjs"
|
||||
PMCMembership PaymentMethodCode = "membership"
|
||||
PMCInsurance PaymentMethodCode = "insurance"
|
||||
|
||||
SCDraft StatusCode = "draft"
|
||||
SCActive StatusCode = "active"
|
||||
SCInactive StatusCode = "inactive"
|
||||
SCBlocked StatusCode = "blocked"
|
||||
SCDead StatusCode = "dead"
|
||||
|
||||
EACHomeRecom EndAssessmentCode = "home recommendation"
|
||||
EACHomeReq EndAssessmentCode = "home request"
|
||||
EACOtherPoly EndAssessmentCode = "others poly"
|
||||
EACRefInt EndAssessmentCode = "referral internal"
|
||||
EACRefExt EndAssessmentCode = "referral external"
|
||||
EACDecease EndAssessmentCode = "decease"
|
||||
|
||||
VTJCReference VisitTypeJknCode = 1
|
||||
VTJCInternalReference VisitTypeJknCode = 2
|
||||
VTJCControl VisitTypeJknCode = 3
|
||||
VTJCExternalReference VisitTypeJknCode = 4
|
||||
)
|
||||
|
||||
func GetStatusCodes() map[StatusCode]string {
|
||||
return map[StatusCode]string{
|
||||
SCDraft: "Draft",
|
||||
SCActive: "Aktif",
|
||||
SCInactive: "Tidak Aktif",
|
||||
SCBlocked: "Diblokir",
|
||||
SCDead: "Meninggal",
|
||||
}
|
||||
}
|
||||
|
||||
func GetConsciousLevelCodes() map[ConsciousLevelCode]string {
|
||||
return map[ConsciousLevelCode]string{
|
||||
CLCAlert: "Sadar Baik / Alert",
|
||||
CLCVoice: "Berespon dengan kata-kata / Voice",
|
||||
CLCPain: "Hanya beresponse jika dirangsang nyeri / pain",
|
||||
CLCUnresponsive: "Pasien tidak sadar / unresponsive",
|
||||
CLCAnxious: "Gelisah atau bingung",
|
||||
CLCAcuteConfusional: "Acute Confusional States",
|
||||
}
|
||||
}
|
||||
|
||||
func GetPaymentMethodCodes() map[PaymentMethodCode]string {
|
||||
return map[PaymentMethodCode]string{
|
||||
PMCCash: "cash",
|
||||
PMCDebit: "debit",
|
||||
PMCCredit: "credit",
|
||||
PMCBpjs: "bpjs",
|
||||
PMCMembership: "membership",
|
||||
PMCInsurance: "insurance"}
|
||||
}
|
||||
|
||||
func GetEndAssessments() map[EndAssessmentCode]string {
|
||||
return map[EndAssessmentCode]string{
|
||||
EACHomeRecom: "home-recommendation",
|
||||
EACHomeReq: "home-request",
|
||||
EACOtherPoly: "other-poly",
|
||||
EACRefInt: "referral-internal",
|
||||
EACRefExt: "referral-external",
|
||||
EACDecease: "decease",
|
||||
}
|
||||
}
|
||||
@@ -48,18 +48,18 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
ECTidakSekolah EducationCode = "TS"
|
||||
ECTK EducationCode = "TK"
|
||||
ECSD EducationCode = "SD"
|
||||
ECSLTP EducationCode = "SMP"
|
||||
ECSLTA EducationCode = "SMA"
|
||||
ECD1 EducationCode = "D1"
|
||||
ECD2 EducationCode = "D2"
|
||||
ECD3 EducationCode = "D3"
|
||||
ECD4 EducationCode = "D4"
|
||||
ECS1 EducationCode = "S1"
|
||||
ECS2 EducationCode = "S2"
|
||||
ECS3 EducationCode = "S3"
|
||||
ECTS EducationCode = "TS"
|
||||
ECTK EducationCode = "TK"
|
||||
ECSD EducationCode = "SD"
|
||||
ECSLTP EducationCode = "SMP"
|
||||
ECSLTA EducationCode = "SMA"
|
||||
ECD1 EducationCode = "D1"
|
||||
ECD2 EducationCode = "D2"
|
||||
ECD3 EducationCode = "D3"
|
||||
ECD4 EducationCode = "D4"
|
||||
ECS1 EducationCode = "S1"
|
||||
ECS2 EducationCode = "S2"
|
||||
ECS3 EducationCode = "S3"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -160,22 +160,22 @@ func GetReligionCodes() map[ReligionCode]string {
|
||||
|
||||
func GetEducationCodes() map[EducationCode]string {
|
||||
return map[EducationCode]string{
|
||||
ECTidakSekolah: "Tidak Sekolah",
|
||||
ECTK: "TK",
|
||||
ECSD: "SD",
|
||||
ECSLTP: "SMP sederajat",
|
||||
ECSLTA: "SMP sederajat",
|
||||
ECD1: "D1 sederajat",
|
||||
ECD2: "D2 sederajat",
|
||||
ECD3: "D3 sederajat",
|
||||
ECD4: "D4 sederajat",
|
||||
ECS1: "S1",
|
||||
ECS2: "S3",
|
||||
ECS3: "S3",
|
||||
ECTS: "Tidak Sekolah",
|
||||
ECTK: "TK",
|
||||
ECSD: "SD",
|
||||
ECSLTP: "SMP sederajat",
|
||||
ECSLTA: "SMP sederajat",
|
||||
ECD1: "D1 sederajat",
|
||||
ECD2: "D2 sederajat",
|
||||
ECD3: "D3 sederajat",
|
||||
ECD4: "D4 sederajat",
|
||||
ECS1: "S1",
|
||||
ECS2: "S3",
|
||||
ECS3: "S3",
|
||||
}
|
||||
}
|
||||
|
||||
func GetProfessions() map[OcupationCode]string {
|
||||
func GetOcupationCodes() map[OcupationCode]string {
|
||||
return map[OcupationCode]string{
|
||||
OCTidakBekerja: "Tidak Bekerja",
|
||||
OCPns: "PNS",
|
||||
@@ -259,7 +259,7 @@ func (obj EducationCode) String() string {
|
||||
}
|
||||
|
||||
func (obj OcupationCode) String() string {
|
||||
return GetProfessions()[obj]
|
||||
return GetOcupationCodes()[obj]
|
||||
}
|
||||
|
||||
func (obj AgeGroupCode) String() string {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package queue
|
||||
|
||||
const QueueName = "SABBI-QUEUE-"
|
||||
@@ -1,31 +0,0 @@
|
||||
package xtime
|
||||
|
||||
type (
|
||||
DayCode byte
|
||||
)
|
||||
|
||||
const (
|
||||
DCMinggu DayCode = iota
|
||||
DCSenin
|
||||
DCSelasa
|
||||
DCRabu
|
||||
DCKamis
|
||||
DCJumat
|
||||
DCSabtu
|
||||
)
|
||||
|
||||
func GetDayCodes() map[DayCode]string {
|
||||
return map[DayCode]string{
|
||||
DCMinggu: "Minggu",
|
||||
DCSenin: "Senin",
|
||||
DCSelasa: "Selasa",
|
||||
DCRabu: "Rabu",
|
||||
DCKamis: "Kamis",
|
||||
DCJumat: "Jumat",
|
||||
DCSabtu: "Sabtu",
|
||||
}
|
||||
}
|
||||
|
||||
func (obj DayCode) String() string {
|
||||
return GetDayCodes()[obj]
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package infragroup
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
sf "github.com/karincake/semprit"
|
||||
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/infra-group"
|
||||
u "simrs-vx/internal/use-case/main-use-case/infra-group"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
dto.Id = uint16(id)
|
||||
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 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Id = uint(id)
|
||||
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 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Id = uint(id)
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package itemgroup
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
sf "github.com/karincake/semprit"
|
||||
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/item-group"
|
||||
u "simrs-vx/internal/use-case/main-use-case/item-group"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
dto.Id = uint16(id)
|
||||
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 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Id = uint(id)
|
||||
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 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Id = uint(id)
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -44,11 +44,9 @@ import (
|
||||
doctorfee "simrs-vx/internal/interface/main-handler/doctor-fee"
|
||||
ethnic "simrs-vx/internal/interface/main-handler/ethnic"
|
||||
infra "simrs-vx/internal/interface/main-handler/infra"
|
||||
infragroup "simrs-vx/internal/interface/main-handler/infra-group"
|
||||
installation "simrs-vx/internal/interface/main-handler/installation"
|
||||
insurancecompany "simrs-vx/internal/interface/main-handler/insurance-company"
|
||||
item "simrs-vx/internal/interface/main-handler/item"
|
||||
itemgroup "simrs-vx/internal/interface/main-handler/item-group"
|
||||
itemprice "simrs-vx/internal/interface/main-handler/item-price"
|
||||
material "simrs-vx/internal/interface/main-handler/material"
|
||||
mcusrc "simrs-vx/internal/interface/main-handler/mcu-src"
|
||||
@@ -120,8 +118,6 @@ func SetRoutes() http.Handler {
|
||||
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/infra-group", infragroup.O)
|
||||
hc.RegCrud(r, "/v1/item-group", itemgroup.O)
|
||||
hc.RegCrud(r, "/v1/uom", uom.O)
|
||||
hc.RegCrud(r, "/v1/item", item.O)
|
||||
hc.RegCrud(r, "/v1/item-price", itemprice.O)
|
||||
|
||||
@@ -16,11 +16,9 @@ import (
|
||||
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"
|
||||
material "simrs-vx/internal/domain/main-entities/material"
|
||||
mcusrc "simrs-vx/internal/domain/main-entities/mcu-src"
|
||||
@@ -96,9 +94,7 @@ func GetEntities() []any {
|
||||
&pharmacycompany.PharmacyCompany{},
|
||||
&diagnosesrc.DiagnoseSrc{},
|
||||
&proceduresrc.ProcedureSrc{},
|
||||
&infragroup.InfraGroup{},
|
||||
&employee.Employee{},
|
||||
&itemgroup.ItemGroup{},
|
||||
&doctor.Doctor{},
|
||||
&nurse.Nurse{},
|
||||
&nutritionist.Nutritionist{},
|
||||
|
||||
@@ -65,9 +65,9 @@ func GenToken(input mu.LoginDto) (*d.Data, error) {
|
||||
user.LoginAttemptCount++
|
||||
dg.I.Save(&user)
|
||||
return nil, d.FieldErrors{"authentication": d.FieldError{Code: "auth-login-incorrect", Message: el.GenMessage("auth-login-incorrect")}}
|
||||
} else if user.Status_Code == erc.SCBlocked {
|
||||
} else if user.Status_Code == erc.USCBlocked {
|
||||
return nil, d.FieldErrors{"authentication": d.FieldError{Code: "auth-login-blocked", Message: el.GenMessage("auth-login-blocked")}}
|
||||
} else if user.Status_Code == erc.SCNew {
|
||||
} else if user.Status_Code == erc.USCNew {
|
||||
return nil, d.FieldErrors{"authentication": d.FieldError{Code: "auth-login-unverified", Message: el.GenMessage("auth-login-unverified")}}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := createItem(&input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if resData, err := CreateData(input, &event, tx); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -87,6 +90,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(input.Includes) > 0 {
|
||||
input.Preloads = pu.GetPreloads(input.Includes)
|
||||
}
|
||||
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -6,6 +6,16 @@ package device
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/device"
|
||||
ei "simrs-vx/internal/domain/main-entities/item"
|
||||
|
||||
ui "simrs-vx/internal/use-case/main-use-case/item"
|
||||
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Device) {
|
||||
@@ -22,3 +32,20 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Device) {
|
||||
data.Uom_Code = inputSrc.Uom_Code
|
||||
data.Item_Id = inputSrc.Item_Id
|
||||
}
|
||||
|
||||
func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
|
||||
itemCreate := ei.CreateDto{
|
||||
Code: pu.AddPrefix("dev-", input.Code),
|
||||
Name: input.Name,
|
||||
ItemGroup_Code: ero.ITGCDevice,
|
||||
Uom_Code: &input.Uom_Code,
|
||||
Infra_Id: input.Infra_Id,
|
||||
}
|
||||
item, err := ui.CreateData(itemCreate, event, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input.Item_Id = &item.Id
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.De
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if len(input.Preloads) > 0 {
|
||||
for _, preload := range input.Preloads {
|
||||
tx = tx.Preload(preload)
|
||||
}
|
||||
}
|
||||
|
||||
tx = tx.
|
||||
Model(&e.Device{}).
|
||||
Scopes(gh.Filter(input)).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Order("\"CreatedAt\" DESC")
|
||||
|
||||
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(input.Includes) > 0 {
|
||||
input.Preloads = pu.GetPreloads(input.Includes)
|
||||
}
|
||||
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -51,10 +51,16 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Di
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if len(input.Preloads) > 0 {
|
||||
for _, preload := range input.Preloads {
|
||||
tx = tx.Preload(preload)
|
||||
}
|
||||
}
|
||||
|
||||
tx = tx.
|
||||
Model(&e.DivisionPosition{}).
|
||||
Preload("Division").
|
||||
Scopes(gh.Filter(input)).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Order("\"CreatedAt\" DESC")
|
||||
|
||||
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(input.Includes) > 0 {
|
||||
input.Preloads = pu.GetPreloads(input.Includes)
|
||||
}
|
||||
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Do
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if len(input.Preloads) > 0 {
|
||||
for _, preload := range input.Preloads {
|
||||
tx = tx.Preload(preload)
|
||||
}
|
||||
}
|
||||
|
||||
tx = tx.
|
||||
Model(&e.DoctorFee{}).
|
||||
Scopes(gh.Filter(input)).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Order("\"CreatedAt\" DESC")
|
||||
|
||||
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(input.Includes) > 0 {
|
||||
input.Preloads = pu.GetPreloads(input.Includes)
|
||||
}
|
||||
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Do
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if len(input.Preloads) > 0 {
|
||||
for _, preload := range input.Preloads {
|
||||
tx = tx.Preload(preload)
|
||||
}
|
||||
}
|
||||
|
||||
tx = tx.
|
||||
Model(&e.Doctor{}).
|
||||
Scopes(gh.Filter(input)).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Order("\"CreatedAt\" DESC")
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
package employee
|
||||
|
||||
import (
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
e "simrs-vx/internal/domain/main-entities/employee"
|
||||
en "simrs-vx/internal/domain/main-entities/nurse"
|
||||
et "simrs-vx/internal/domain/main-entities/nutritionist"
|
||||
ep "simrs-vx/internal/domain/main-entities/pharmacist"
|
||||
"strconv"
|
||||
|
||||
dg "github.com/karincake/apem/db-gorm-pg"
|
||||
d "github.com/karincake/dodol"
|
||||
ud "simrs-vx/internal/use-case/main-use-case/doctor"
|
||||
un "simrs-vx/internal/use-case/main-use-case/nurse"
|
||||
ut "simrs-vx/internal/use-case/main-use-case/nutritionist"
|
||||
up "simrs-vx/internal/use-case/main-use-case/pharmacist"
|
||||
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
dg "github.com/karincake/apem/db-gorm-pg"
|
||||
d "github.com/karincake/dodol"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -24,7 +34,7 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "create")
|
||||
pl.SetLogInfo(&event, input.Sanitize(), "started", "create")
|
||||
|
||||
err := dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
mwRunner := newMiddlewareRunner(&event, tx)
|
||||
@@ -34,12 +44,57 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := createOrUpdatePerson(&input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := createUser(&input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resData, err := CreateData(input, &event, tx); err != nil {
|
||||
return err
|
||||
} else {
|
||||
data = *resData
|
||||
}
|
||||
|
||||
switch input.Position_Code {
|
||||
case ero.EPCDoc:
|
||||
createDoc := ed.CreateDto{
|
||||
Employee_Id: &data.Id,
|
||||
IHS_Number: input.IHS_Number,
|
||||
SIP_Number: input.SIP_Number,
|
||||
Unit_Id: input.Unit_Id,
|
||||
}
|
||||
if _, err := ud.CreateData(createDoc, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
case ero.EPCNur:
|
||||
createNurse := en.CreateDto{
|
||||
Employee_Id: &data.Id,
|
||||
IHS_Number: input.IHS_Number,
|
||||
}
|
||||
if _, err := un.CreateData(createNurse, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
case ero.EPCNut:
|
||||
createNutritionist := et.CreateDto{
|
||||
Employee_Id: &data.Id,
|
||||
IHS_Number: input.IHS_Number,
|
||||
}
|
||||
if _, err := ut.CreateData(createNutritionist, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
case ero.EPCPha:
|
||||
createPharmacist := ep.CreateDto{
|
||||
Employee_Id: &data.Id,
|
||||
IHS_Number: input.IHS_Number,
|
||||
}
|
||||
if _, err := up.CreateData(createPharmacist, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunCreateMiddleware(createPostMw, &input, &data); err != nil {
|
||||
@@ -87,6 +142,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(input.Includes) > 0 {
|
||||
input.Preloads = pu.GetPreloads(input.Includes)
|
||||
}
|
||||
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -5,7 +5,17 @@ Any functions that are used internally by the use-case
|
||||
package employee
|
||||
|
||||
import (
|
||||
"errors"
|
||||
e "simrs-vx/internal/domain/main-entities/employee"
|
||||
ep "simrs-vx/internal/domain/main-entities/person"
|
||||
"strconv"
|
||||
|
||||
up "simrs-vx/internal/use-case/main-use-case/person"
|
||||
uu "simrs-vx/internal/use-case/main-use-case/user"
|
||||
|
||||
pl "simrs-vx/pkg/logger"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Employee) {
|
||||
@@ -24,3 +34,52 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Employee) {
|
||||
data.Number = inputSrc.Number
|
||||
data.Status_Code = inputSrc.Status_Code
|
||||
}
|
||||
|
||||
func createUser(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
|
||||
if input.User == nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-create-fail",
|
||||
Detail: "user request is required",
|
||||
Raw: errors.New("user request is required"),
|
||||
}
|
||||
return pl.SetLogError(event, input)
|
||||
}
|
||||
user, err := uu.CreateData(*input.User, event, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
input.User_Id = &user.Id
|
||||
return nil
|
||||
}
|
||||
|
||||
func createOrUpdatePerson(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
|
||||
if input.Person_Id == nil {
|
||||
person, err := up.CreateData(*input.Person, event, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
input.Person_Id = &person.Id
|
||||
return nil
|
||||
}
|
||||
|
||||
person, err := up.ReadDetailData(ep.ReadDetailDto{Id: *input.Person_Id}, event, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if person == nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-notFound",
|
||||
Detail: "person with ID " + strconv.Itoa(int(*input.Person_Id)) + " not found",
|
||||
Raw: errors.New("person with ID " + strconv.Itoa(int(*input.Person_Id)) + " not found"),
|
||||
}
|
||||
return pl.SetLogError(event, input)
|
||||
}
|
||||
|
||||
if err := up.UpdateData(ep.UpdateDto{CreateDto: *input.Person}, person, event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Em
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if len(input.Preloads) > 0 {
|
||||
for _, preload := range input.Preloads {
|
||||
tx = tx.Preload(preload)
|
||||
}
|
||||
}
|
||||
|
||||
tx = tx.
|
||||
Model(&e.Employee{}).
|
||||
Scopes(gh.Filter(input)).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Order("\"CreatedAt\" DESC")
|
||||
|
||||
@@ -1,275 +0,0 @@
|
||||
package infragroup
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/infra-group"
|
||||
"strconv"
|
||||
|
||||
dg "github.com/karincake/apem/db-gorm-pg"
|
||||
d "github.com/karincake/dodol"
|
||||
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const source = "infra-group"
|
||||
|
||||
func Create(input e.CreateDto) (*d.Data, error) {
|
||||
data := e.InfraGroup{}
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "Create",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "create")
|
||||
|
||||
err := dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
mwRunner := newMiddlewareRunner(&event, tx)
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunCreateMiddleware(createPreMw, &input, &data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resData, err := CreateData(input, &event, tx); err != nil {
|
||||
return err
|
||||
} else {
|
||||
data = *resData
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunCreateMiddleware(createPostMw, &input, &data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pl.SetLogInfo(&event, nil, "complete")
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &d.Data{
|
||||
Meta: d.II{
|
||||
"source": source,
|
||||
"structure": "single-data",
|
||||
"status": "created",
|
||||
},
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
var data *e.InfraGroup
|
||||
var dataList []e.InfraGroup
|
||||
var metaList *e.MetaDto
|
||||
var err error
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "ReadList",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "readList")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
mwRunner := newMiddlewareRunner(&event, tx)
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunReadListMiddleware(readListPreMw, &input, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunReadListMiddleware(readListPostMw, &input, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &d.Data{
|
||||
Meta: d.IS{
|
||||
"source": source,
|
||||
"structure": "list-data",
|
||||
"status": "fetched",
|
||||
"page_number": strconv.Itoa(metaList.PageNumber),
|
||||
"page_size": strconv.Itoa(metaList.PageSize),
|
||||
"record_totalCount": strconv.Itoa(metaList.Count),
|
||||
},
|
||||
Data: e.ToResponseList(dataList),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
|
||||
var data *e.InfraGroup
|
||||
var err error
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "ReadDetail",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "readDetail")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
mwRunner := newMiddlewareRunner(&event, tx)
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunReadDetailMiddleware(readDetailPreMw, &input, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if data, err = ReadDetailData(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunReadDetailMiddleware(readDetailPostMw, &input, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &d.Data{
|
||||
Meta: d.IS{
|
||||
"source": source,
|
||||
"structure": "single-data",
|
||||
"status": "fetched",
|
||||
},
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
|
||||
var data *e.InfraGroup
|
||||
var err error
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "Update",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "update")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
if data, err = ReadDetailData(rdDto, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event, tx)
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunUpdateMiddleware(readDetailPreMw, &rdDto, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := UpdateData(input, data, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pl.SetLogInfo(&event, nil, "complete")
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunUpdateMiddleware(readDetailPostMw, &rdDto, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &d.Data{
|
||||
Meta: d.IS{
|
||||
"source": source,
|
||||
"structure": "single-data",
|
||||
"status": "updated",
|
||||
},
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
|
||||
var data *e.InfraGroup
|
||||
var err error
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "Delete",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "delete")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
if data, err = ReadDetailData(rdDto, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event, tx)
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunDeleteMiddleware(readDetailPreMw, &rdDto, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := DeleteData(data, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunDeleteMiddleware(readDetailPostMw, &rdDto, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &d.Data{
|
||||
Meta: d.IS{
|
||||
"source": source,
|
||||
"structure": "single-data",
|
||||
"status": "deleted",
|
||||
},
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Any functions that are used internally by the use-case
|
||||
*/
|
||||
package infragroup
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/infra-group"
|
||||
)
|
||||
|
||||
func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.InfraGroup) {
|
||||
var inputSrc *e.CreateDto
|
||||
if inputT, ok := any(input).(*e.CreateDto); ok {
|
||||
inputSrc = inputT
|
||||
} else {
|
||||
inputTemp := any(input).(*e.UpdateDto)
|
||||
inputSrc = &inputTemp.CreateDto
|
||||
}
|
||||
data.Code = inputSrc.Code
|
||||
data.Name = inputSrc.Name
|
||||
data.Level = inputSrc.Level
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
package infragroup
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/infra-group"
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
dg "github.com/karincake/apem/db-gorm-pg"
|
||||
gh "github.com/karincake/getuk"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.InfraGroup, error) {
|
||||
pl.SetLogInfo(event, nil, "started", "DBCreate")
|
||||
|
||||
data := e.InfraGroup{}
|
||||
setData(&input, &data)
|
||||
|
||||
var tx *gorm.DB
|
||||
if len(dbx) > 0 {
|
||||
tx = dbx[0]
|
||||
} else {
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if err := tx.Create(&data).Error; err != nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-create-fail",
|
||||
Detail: "Database insert failed",
|
||||
Raw: err,
|
||||
}
|
||||
return nil, pl.SetLogError(event, input)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(event, nil, "complete")
|
||||
return &data, nil
|
||||
}
|
||||
|
||||
func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.InfraGroup, *e.MetaDto, error) {
|
||||
pl.SetLogInfo(event, input, "started", "DBReadList")
|
||||
data := []e.InfraGroup{}
|
||||
pagination := gh.Pagination{}
|
||||
count := int64(0)
|
||||
meta := e.MetaDto{}
|
||||
|
||||
var tx *gorm.DB
|
||||
if len(dbx) > 0 {
|
||||
tx = dbx[0]
|
||||
} else {
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
tx = tx.
|
||||
Model(&e.InfraGroup{}).
|
||||
Scopes(gh.Filter(input)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Order("\"CreatedAt\" DESC")
|
||||
|
||||
if err := tx.Debug().Find(&data).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil, &meta, nil
|
||||
}
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-get-fail",
|
||||
Detail: "Database get failed",
|
||||
Raw: err,
|
||||
}
|
||||
return nil, nil, pl.SetLogError(event, input)
|
||||
|
||||
}
|
||||
meta.Count = int(count)
|
||||
meta.PageNumber = pagination.PageNumber
|
||||
meta.PageSize = pagination.PageSize
|
||||
|
||||
pl.SetLogInfo(event, nil, "complete")
|
||||
return data, &meta, nil
|
||||
}
|
||||
|
||||
func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e.InfraGroup, error) {
|
||||
pl.SetLogInfo(event, input, "started", "DBReadDetail")
|
||||
data := e.InfraGroup{}
|
||||
|
||||
var tx *gorm.DB
|
||||
if len(dbx) > 0 {
|
||||
tx = dbx[0]
|
||||
} else {
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
pl.SetLogInfo(event, nil, "complete")
|
||||
return &data, nil
|
||||
}
|
||||
|
||||
func UpdateData(input e.UpdateDto, data *e.InfraGroup, event *pl.Event, dbx ...*gorm.DB) error {
|
||||
pl.SetLogInfo(event, data, "started", "DBUpdate")
|
||||
setData(&input, data)
|
||||
|
||||
var tx *gorm.DB
|
||||
if len(dbx) > 0 {
|
||||
tx = dbx[0]
|
||||
} else {
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if err := tx.Save(&data).Error; err != nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-update-fail",
|
||||
Detail: "Database update failed",
|
||||
Raw: err,
|
||||
}
|
||||
return pl.SetLogError(event, input)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(event, nil, "complete")
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteData(data *e.InfraGroup, event *pl.Event, dbx ...*gorm.DB) error {
|
||||
pl.SetLogInfo(event, data, "started", "DBDelete")
|
||||
var tx *gorm.DB
|
||||
if len(dbx) > 0 {
|
||||
tx = dbx[0]
|
||||
} else {
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if err := tx.Delete(&data).Error; err != nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-delete-fail",
|
||||
Detail: "Database delete failed",
|
||||
Raw: err,
|
||||
}
|
||||
return pl.SetLogError(event, data)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(event, nil, "complete")
|
||||
return nil
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
package infragroup
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/infra-group"
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type middlewareRunner struct {
|
||||
Event *pl.Event
|
||||
Tx *gorm.DB
|
||||
MwType pu.MWType
|
||||
}
|
||||
|
||||
// NewMiddlewareExecutor creates a new middleware executor
|
||||
func newMiddlewareRunner(event *pl.Event, tx *gorm.DB) *middlewareRunner {
|
||||
return &middlewareRunner{
|
||||
Event: event,
|
||||
Tx: tx,
|
||||
}
|
||||
}
|
||||
|
||||
// ExecuteCreateMiddleware executes create middleware
|
||||
func (me *middlewareRunner) RunCreateMiddleware(middlewares []createMw, input *e.CreateDto, data *e.InfraGroup) error {
|
||||
for _, middleware := range middlewares {
|
||||
logData := pu.GetLogData(input, data)
|
||||
|
||||
pl.SetLogInfo(me.Event, logData, "started", middleware.Name)
|
||||
|
||||
if err := middleware.Func(input, data, me.Tx); err != nil {
|
||||
return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(me.Event, nil, "complete")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *middlewareRunner) RunReadListMiddleware(middlewares []readListMw, input *e.ReadListDto, data *e.InfraGroup) error {
|
||||
for _, middleware := range middlewares {
|
||||
logData := pu.GetLogData(input, data)
|
||||
|
||||
pl.SetLogInfo(me.Event, logData, "started", middleware.Name)
|
||||
|
||||
if err := middleware.Func(input, data, me.Tx); err != nil {
|
||||
return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(me.Event, nil, "complete")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *middlewareRunner) RunReadDetailMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.InfraGroup) error {
|
||||
for _, middleware := range middlewares {
|
||||
logData := pu.GetLogData(input, data)
|
||||
|
||||
pl.SetLogInfo(me.Event, logData, "started", middleware.Name)
|
||||
|
||||
if err := middleware.Func(input, data, me.Tx); err != nil {
|
||||
return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(me.Event, nil, "complete")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *middlewareRunner) RunUpdateMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.InfraGroup) error {
|
||||
for _, middleware := range middlewares {
|
||||
logData := pu.GetLogData(input, data)
|
||||
|
||||
pl.SetLogInfo(me.Event, logData, "started", middleware.Name)
|
||||
|
||||
if err := middleware.Func(input, data, me.Tx); err != nil {
|
||||
return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(me.Event, nil, "complete")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *middlewareRunner) RunDeleteMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.InfraGroup) error {
|
||||
for _, middleware := range middlewares {
|
||||
logData := pu.GetLogData(input, data)
|
||||
|
||||
pl.SetLogInfo(me.Event, logData, "started", middleware.Name)
|
||||
|
||||
if err := middleware.Func(input, data, me.Tx); err != nil {
|
||||
return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(me.Event, nil, "complete")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *middlewareRunner) setMwType(mwType pu.MWType) {
|
||||
me.MwType = mwType
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package infragroup
|
||||
|
||||
// example of middleware
|
||||
// func init() {
|
||||
// createPreMw = append(createPreMw,
|
||||
// CreateMw{Name: "modif-input", Func: pm.ModifInput},
|
||||
// CreateMw{Name: "check-data", Func: pm.CheckData},
|
||||
// )
|
||||
// }
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
A sample, part of the package that contains type, constants, and/or variables.
|
||||
|
||||
In this sample it also provides type and variable regarding the needs of the
|
||||
middleware to separate from main use-case which has the basic CRUD
|
||||
functionality. The purpose of this is to make the code more maintainable.
|
||||
*/
|
||||
package infragroup
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/infra-group"
|
||||
)
|
||||
|
||||
type createMw struct {
|
||||
Name string
|
||||
Func func(input *e.CreateDto, data *e.InfraGroup, tx *gorm.DB) error
|
||||
}
|
||||
|
||||
type readListMw struct {
|
||||
Name string
|
||||
Func func(input *e.ReadListDto, data *e.InfraGroup, tx *gorm.DB) error
|
||||
}
|
||||
|
||||
type readDetailMw struct {
|
||||
Name string
|
||||
Func func(input *e.ReadDetailDto, data *e.InfraGroup, tx *gorm.DB) error
|
||||
}
|
||||
|
||||
type UpdateMw = readDetailMw
|
||||
type DeleteMw = readDetailMw
|
||||
|
||||
var createPreMw []createMw // preprocess middleware
|
||||
var createPostMw []createMw // postprocess middleware
|
||||
var readListPreMw []readListMw // ..
|
||||
var readListPostMw []readListMw // ..
|
||||
var readDetailPreMw []readDetailMw
|
||||
var readDetailPostMw []readDetailMw
|
||||
var updatePreMw []readDetailMw
|
||||
var updatePostMw []readDetailMw
|
||||
var deletePreMw []readDetailMw
|
||||
var deletePostMw []readDetailMw
|
||||
@@ -1,12 +1,15 @@
|
||||
package infra
|
||||
|
||||
import (
|
||||
"errors"
|
||||
e "simrs-vx/internal/domain/main-entities/infra"
|
||||
"strconv"
|
||||
|
||||
dg "github.com/karincake/apem/db-gorm-pg"
|
||||
d "github.com/karincake/dodol"
|
||||
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
@@ -34,6 +37,21 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if input.InfraGroup_Code == ero.IFGCRoom {
|
||||
if input.Parent_Id == nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-create-fail",
|
||||
Detail: "parent_id is required",
|
||||
Raw: errors.New("parent_id is required"),
|
||||
}
|
||||
return pl.SetLogError(&event, input)
|
||||
|
||||
}
|
||||
if err := createItem(&input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if resData, err := CreateData(input, &event, tx); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -87,6 +105,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(input.Includes) > 0 {
|
||||
input.Preloads = pu.GetPreloads(input.Includes)
|
||||
}
|
||||
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -6,6 +6,13 @@ package infra
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/infra"
|
||||
ei "simrs-vx/internal/domain/main-entities/item"
|
||||
ero "simrs-vx/internal/domain/references/organization"
|
||||
ui "simrs-vx/internal/use-case/main-use-case/item"
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Infra) {
|
||||
@@ -23,3 +30,19 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Infra) {
|
||||
data.Parent_Id = inputSrc.Parent_Id
|
||||
data.Item_Id = inputSrc.Item_Id
|
||||
}
|
||||
|
||||
func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
|
||||
itemCreate := ei.CreateDto{
|
||||
Code: pu.AddPrefix("inf-", input.Code),
|
||||
Name: input.Name,
|
||||
ItemGroup_Code: ero.ITGCInfra,
|
||||
Infra_Id: input.Parent_Id,
|
||||
}
|
||||
item, err := ui.CreateData(itemCreate, event, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input.Item_Id = &item.Id
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.In
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if len(input.Preloads) > 0 {
|
||||
for _, preload := range input.Preloads {
|
||||
tx = tx.Preload(preload)
|
||||
}
|
||||
}
|
||||
|
||||
tx = tx.
|
||||
Model(&e.Infra{}).
|
||||
Scopes(gh.Filter(input)).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Order("\"CreatedAt\" DESC")
|
||||
|
||||
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(input.Includes) > 0 {
|
||||
input.Preloads = pu.GetPreloads(input.Includes)
|
||||
}
|
||||
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.In
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if len(input.Preloads) > 0 {
|
||||
for _, preload := range input.Preloads {
|
||||
tx = tx.Preload(preload)
|
||||
}
|
||||
}
|
||||
|
||||
tx = tx.
|
||||
Model(&e.InsuranceCompany{}).
|
||||
Scopes(gh.Filter(input)).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Order("\"CreatedAt\" DESC")
|
||||
|
||||
@@ -1,275 +0,0 @@
|
||||
package itemgroup
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/item-group"
|
||||
"strconv"
|
||||
|
||||
dg "github.com/karincake/apem/db-gorm-pg"
|
||||
d "github.com/karincake/dodol"
|
||||
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const source = "item-group"
|
||||
|
||||
func Create(input e.CreateDto) (*d.Data, error) {
|
||||
data := e.ItemGroup{}
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "Create",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "create")
|
||||
|
||||
err := dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
mwRunner := newMiddlewareRunner(&event, tx)
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunCreateMiddleware(createPreMw, &input, &data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resData, err := CreateData(input, &event, tx); err != nil {
|
||||
return err
|
||||
} else {
|
||||
data = *resData
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunCreateMiddleware(createPostMw, &input, &data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pl.SetLogInfo(&event, nil, "complete")
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &d.Data{
|
||||
Meta: d.II{
|
||||
"source": source,
|
||||
"structure": "single-data",
|
||||
"status": "created",
|
||||
},
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
var data *e.ItemGroup
|
||||
var dataList []e.ItemGroup
|
||||
var metaList *e.MetaDto
|
||||
var err error
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "ReadList",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "readList")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
mwRunner := newMiddlewareRunner(&event, tx)
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunReadListMiddleware(readListPreMw, &input, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunReadListMiddleware(readListPostMw, &input, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &d.Data{
|
||||
Meta: d.IS{
|
||||
"source": source,
|
||||
"structure": "list-data",
|
||||
"status": "fetched",
|
||||
"page_number": strconv.Itoa(metaList.PageNumber),
|
||||
"page_size": strconv.Itoa(metaList.PageSize),
|
||||
"record_totalCount": strconv.Itoa(metaList.Count),
|
||||
},
|
||||
Data: e.ToResponseList(dataList),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
|
||||
var data *e.ItemGroup
|
||||
var err error
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "ReadDetail",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "readDetail")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
mwRunner := newMiddlewareRunner(&event, tx)
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunReadDetailMiddleware(readDetailPreMw, &input, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if data, err = ReadDetailData(input, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunReadDetailMiddleware(readDetailPostMw, &input, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &d.Data{
|
||||
Meta: d.IS{
|
||||
"source": source,
|
||||
"structure": "single-data",
|
||||
"status": "fetched",
|
||||
},
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
|
||||
var data *e.ItemGroup
|
||||
var err error
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "Update",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "update")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
if data, err = ReadDetailData(rdDto, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event, tx)
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunUpdateMiddleware(readDetailPreMw, &rdDto, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := UpdateData(input, data, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pl.SetLogInfo(&event, nil, "complete")
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunUpdateMiddleware(readDetailPostMw, &rdDto, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &d.Data{
|
||||
Meta: d.IS{
|
||||
"source": source,
|
||||
"structure": "single-data",
|
||||
"status": "updated",
|
||||
},
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
|
||||
var data *e.ItemGroup
|
||||
var err error
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "Delete",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "delete")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
if data, err = ReadDetailData(rdDto, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event, tx)
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunDeleteMiddleware(readDetailPreMw, &rdDto, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := DeleteData(data, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mwRunner.setMwType(pu.MWTPost)
|
||||
// Run post-middleware
|
||||
if err := mwRunner.RunDeleteMiddleware(readDetailPostMw, &rdDto, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &d.Data{
|
||||
Meta: d.IS{
|
||||
"source": source,
|
||||
"structure": "single-data",
|
||||
"status": "deleted",
|
||||
},
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user