@@ -66,9 +66,11 @@ bpjsCfg:
|
||||
baseUrl:
|
||||
|
||||
syncUrlCfg:
|
||||
enable: false
|
||||
host:
|
||||
prefix: new-to-old
|
||||
enable: false
|
||||
targetHost:
|
||||
prefix: new-to-old
|
||||
source: old-app
|
||||
secretKey: new-world-order!!
|
||||
|
||||
docsCfg:
|
||||
path: ../../assets/docs/
|
||||
@@ -0,0 +1,23 @@
|
||||
-- Modify "Chemo" table
|
||||
ALTER TABLE "public"."Chemo" ADD COLUMN "Doctor_Code" character varying(20) NULL, ADD COLUMN "NextChemoDate" timestamptz NULL, ADD CONSTRAINT "fk_Chemo_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
-- Rename a column from "Encounter_Id" to "Chemo_Id"
|
||||
ALTER TABLE "public"."ChemoProtocol" RENAME COLUMN "Encounter_Id" TO "Chemo_Id";
|
||||
-- Modify "ChemoProtocol" table
|
||||
ALTER TABLE "public"."ChemoProtocol" DROP CONSTRAINT "fk_ChemoProtocol_Encounter", ALTER COLUMN "DurationUnit_Code" TYPE text, ADD COLUMN "Interval" bigint NULL, ADD COLUMN "Cycle" bigint NULL, ADD COLUMN "Series" integer NULL, ADD COLUMN "Status_Code" text NULL, ADD CONSTRAINT "fk_ChemoProtocol_Chemo" FOREIGN KEY ("Chemo_Id") REFERENCES "public"."Chemo" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
-- Create "ChemoPlan" table
|
||||
CREATE TABLE "public"."ChemoPlan" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Parent_Id" bigint NULL,
|
||||
"Protocol_Id" bigint NULL,
|
||||
"SeriesNumber" integer NULL,
|
||||
"CycleNumber" bigint NULL,
|
||||
"PlanDate" timestamptz NULL,
|
||||
"RealizationDate" timestamptz NULL,
|
||||
"Notes" text NULL,
|
||||
"Status" text NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "fk_ChemoPlan_Protocol" FOREIGN KEY ("Protocol_Id") REFERENCES "public"."ChemoProtocol" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Modify "ChemoPlan" table
|
||||
ALTER TABLE "public"."ChemoPlan" DROP CONSTRAINT "fk_ChemoPlan_Protocol", ADD CONSTRAINT "fk_ChemoProtocol_ChemoPlans" FOREIGN KEY ("Protocol_Id") REFERENCES "public"."ChemoProtocol" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Modify "ChemoProtocol" table
|
||||
ALTER TABLE "public"."ChemoProtocol" ADD COLUMN "Patient_Id" bigint NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Modify "ChemoProtocol" table
|
||||
ALTER TABLE "public"."ChemoProtocol" ADD COLUMN "VerifiedAt" timestamptz NULL, ADD COLUMN "VerifiedBy_User_Id" bigint NULL, ADD CONSTRAINT "fk_ChemoProtocol_VerifiedBy" FOREIGN KEY ("VerifiedBy_User_Id") REFERENCES "public"."User" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
@@ -0,0 +1,22 @@
|
||||
-- Create "ApMcuOrder" table
|
||||
CREATE TABLE "public"."ApMcuOrder" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"McuOrder_Id" smallint NULL,
|
||||
"Substances" text NULL,
|
||||
"Fictations" text NULL,
|
||||
"Localization" text NULL,
|
||||
"ClinicalDiagnoses" text NULL,
|
||||
"Stadium" text NULL,
|
||||
"ClinicalNotes" text NULL,
|
||||
"PastHistory" text NULL,
|
||||
"CurrentHistory" text NULL,
|
||||
"PrevApMcu" text NULL,
|
||||
"PrevApMcuNotes" text NULL,
|
||||
"SupportingExams" text NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_ApMcuOrder_McuOrder_Id" UNIQUE ("McuOrder_Id"),
|
||||
CONSTRAINT "fk_ApMcuOrder_McuOrder" FOREIGN KEY ("McuOrder_Id") REFERENCES "public"."McuOrder" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
@@ -0,0 +1,99 @@
|
||||
-- Modify "ApMcuOrder" table
|
||||
ALTER TABLE "public"."ApMcuOrder" DROP COLUMN "McuOrder_Id", ADD COLUMN "Encounter_Id" bigint NULL, ADD COLUMN "Number" bigint NULL, ADD COLUMN "Doctor_Code" character varying(20) NULL, ADD CONSTRAINT "uni_ApMcuOrder_Doctor_Code" UNIQUE ("Doctor_Code"), ADD CONSTRAINT "fk_ApMcuOrder_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ApMcuOrder_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
-- Create "CpMcuOrder" table
|
||||
CREATE TABLE "public"."CpMcuOrder" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Encounter_Id" bigint NULL,
|
||||
"Number" bigint NULL,
|
||||
"Doctor_Code" character varying(20) NULL,
|
||||
"UrgencyLevel_Code" character varying(15) NOT NULL,
|
||||
"OtherNotes" text NULL,
|
||||
"ExamScheduleDate" timestamptz NULL,
|
||||
"Resume" text NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_CpMcuOrder_Doctor_Code" UNIQUE ("Doctor_Code"),
|
||||
CONSTRAINT "fk_CpMcuOrder_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_CpMcuOrder_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
-- Create "CpMcuOrderItem" table
|
||||
CREATE TABLE "public"."CpMcuOrderItem" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"CpMcuOrder_Id" bigint NULL,
|
||||
"McuSrc_Code" character varying(20) NULL,
|
||||
"Note" character varying(1024) NULL,
|
||||
"Result" text NULL,
|
||||
"Status_Code" text NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "fk_CpMcuOrderItem_CpMcuOrder" FOREIGN KEY ("CpMcuOrder_Id") REFERENCES "public"."CpMcuOrder" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_CpMcuOrderItem_McuSrc" FOREIGN KEY ("McuSrc_Code") REFERENCES "public"."McuSrc" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
-- Create "MicroMcuOrder" table
|
||||
CREATE TABLE "public"."MicroMcuOrder" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Encounter_Id" bigint NULL,
|
||||
"Number" bigint NULL,
|
||||
"Doctor_Code" character varying(20) NULL,
|
||||
"Stage_Code" character varying(10) NOT NULL,
|
||||
"AxillaryTemp" numeric NULL,
|
||||
"OtherNotes" text NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_MicroMcuOrder_Doctor_Code" UNIQUE ("Doctor_Code"),
|
||||
CONSTRAINT "fk_MicroMcuOrder_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_MicroMcuOrder_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
-- Create "MicroMcuOrderItem" table
|
||||
CREATE TABLE "public"."MicroMcuOrderItem" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"MicroMcuOrder_Id" bigint NULL,
|
||||
"McuSrc_Code" character varying(20) NULL,
|
||||
"Note" character varying(1024) NULL,
|
||||
"Result" text NULL,
|
||||
"Status_Code" text NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "fk_MicroMcuOrderItem_McuSrc" FOREIGN KEY ("McuSrc_Code") REFERENCES "public"."McuSrc" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_MicroMcuOrderItem_MicroMcuOrder" FOREIGN KEY ("MicroMcuOrder_Id") REFERENCES "public"."MicroMcuOrder" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
-- Create "RadiologyMcuOrder" table
|
||||
CREATE TABLE "public"."RadiologyMcuOrder" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Encounter_Id" bigint NULL,
|
||||
"Number" bigint NULL,
|
||||
"Doctor_Code" character varying(20) NULL,
|
||||
"ClinicalNotes" text NULL,
|
||||
"OtherNotes" text NULL,
|
||||
"Resume" text NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_RadiologyMcuOrder_Doctor_Code" UNIQUE ("Doctor_Code"),
|
||||
CONSTRAINT "fk_RadiologyMcuOrder_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_RadiologyMcuOrder_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
-- Create "RadiologyMcuOrderItem" table
|
||||
CREATE TABLE "public"."RadiologyMcuOrderItem" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"RadiologyMcuOrder_Id" bigint NULL,
|
||||
"McuSrc_Code" character varying(20) NULL,
|
||||
"Note" character varying(1024) NULL,
|
||||
"Result" text NULL,
|
||||
"Status_Code" text NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "fk_RadiologyMcuOrderItem_McuSrc" FOREIGN KEY ("McuSrc_Code") REFERENCES "public"."McuSrc" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_RadiologyMcuOrderItem_RadiologyMcuOrder" FOREIGN KEY ("RadiologyMcuOrder_Id") REFERENCES "public"."RadiologyMcuOrder" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Modify "ApMcuOrder" table
|
||||
ALTER TABLE "public"."ApMcuOrder" ADD COLUMN "Status_Code" character varying(10) NOT NULL;
|
||||
-- Modify "CpMcuOrder" table
|
||||
ALTER TABLE "public"."CpMcuOrder" ADD COLUMN "Status_Code" character varying(10) NOT NULL;
|
||||
-- Modify "MicroMcuOrder" table
|
||||
ALTER TABLE "public"."MicroMcuOrder" ADD COLUMN "Status_Code" character varying(10) NOT NULL;
|
||||
-- Modify "RadiologyMcuOrder" table
|
||||
ALTER TABLE "public"."RadiologyMcuOrder" ADD COLUMN "Status_Code" character varying(10) NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Modify "ChemoPlan" table
|
||||
ALTER TABLE "public"."ChemoPlan" ADD COLUMN "Encounter_Id" bigint NULL, ADD CONSTRAINT "fk_ChemoPlan_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Modify "Chemo" table
|
||||
ALTER TABLE "public"."Chemo" ADD COLUMN "Class_Code" text NULL;
|
||||
@@ -0,0 +1,12 @@
|
||||
-- Create "Registration" table
|
||||
CREATE TABLE "public"."Registration" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Employee_Id" bigint NULL,
|
||||
"Installation_Code" character varying(20) NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "fk_Registration_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
|
||||
CONSTRAINT "fk_Registration_Installation" FOREIGN KEY ("Installation_Code") REFERENCES "public"."Installation" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION
|
||||
);
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Modify "Person" table
|
||||
ALTER TABLE "public"."Person" ADD COLUMN "BirthPlace" text NULL;
|
||||
@@ -1,4 +1,4 @@
|
||||
h1:qjr3k9/ymXjw1nopw49c6+fWtu0n+H8sQgsioqUC9Fo=
|
||||
h1:YJzcjq4dKD7GKlV0GJ88TOtZgg0JRDcVMlAe5ZYT9/U=
|
||||
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
|
||||
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
|
||||
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
|
||||
@@ -144,4 +144,17 @@ h1:qjr3k9/ymXjw1nopw49c6+fWtu0n+H8sQgsioqUC9Fo=
|
||||
20251202160848.sql h1:Kd2/TziKSMezrt4XgbjQcYvY/Lo9rX0qw7/Lz0/oyKk=
|
||||
20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM=
|
||||
20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY=
|
||||
20251203205052.sql h1:az/hGpk7u4YKT7gU+UuEw9guqB9AqdckPF1cYavQ3CA=
|
||||
20251203205052.sql h1:nk0VK2Uv4bHE3SBfHo/aevVZxtHzr7zAzvmMU8TCCtk=
|
||||
20251205073858.sql h1:46qqXnArgJmzGE/WO7v7Ev8Jh7BudDiGbdANexq/5Dk=
|
||||
20251205211957.sql h1:3fvtZ/mBWsTIXllXMFOuCLJsp4MivVP56dunehlU0yo=
|
||||
20251205214433.sql h1:rn3++FEfX7ntcJcOmCEuOMnr27TZqH0KMGRppzFwFTc=
|
||||
20251205221124.sql h1:CRruUvGZqlVDBmbQSVEl4wFm+uq30AurMMDI6sb8jxg=
|
||||
20251206021053.sql h1:bpuEocu4lOhZ7oLuxd//22dzjfNgU2iaWEqSD1mVwoU=
|
||||
20251207020537.sql h1:m6uh4NHVF3EKNTVMqOmuBSDFD9oCQk5mAwo05fT46G4=
|
||||
20251207212015.sql h1:UPelYGTeUR6rm8mU8dfNzgRDEDun0UQ4tkgsaDljn30=
|
||||
20251207221222.sql h1:bTfUCvCf2UPh+BA2IY2PHQafb9DwY9nhH5FRuMEHy+0=
|
||||
20251209022744.sql h1:y5/PAiZH/fYCpDJpkQdNRJwWICHH2iNIwM1V+S1P6KA=
|
||||
20251209025908.sql h1:p3kZA8kyEj+mQZSrdY3k2K1NojQzFJh/MlZJ0Oy6t/k=
|
||||
20251209030538.sql h1:zltV6/Fu2zJW0/lVBl7MdnWuJcqNTUIRcqYYZ8Fi1wo=
|
||||
20251209064304.sql h1:Mj6Zh+2b/4AkM1HjnJGjAs788kVN0UaL34jeaKQIjT0=
|
||||
20251209070128.sql h1:rdqSlAmJS5XSc1w9dka3C53zwgibQwRIUqBcgmIPoTM=
|
||||
|
||||
@@ -34,4 +34,12 @@ langCfg:
|
||||
|
||||
corsCfg:
|
||||
allowedOrigin:
|
||||
allowedMethod: GET, POST, PUT, PATCH, DELETE, OPTIONS
|
||||
allowedMethod: GET, POST, PUT, PATCH, DELETE, OPTIONS
|
||||
|
||||
syncPartnerCfg:
|
||||
oldSource
|
||||
oldSecretKey
|
||||
oldHost
|
||||
newSource
|
||||
newSecretKey
|
||||
newHost
|
||||
@@ -0,0 +1,23 @@
|
||||
package apmcuorder
|
||||
|
||||
type CreateDto struct {
|
||||
Encounter_Id uint `json:"encounter_id"`
|
||||
Number uint64 `json:"number"`
|
||||
Doctor_Code string `json:"-"`
|
||||
Substances string `json:"substances"`
|
||||
Fictations string `json:"fictations"`
|
||||
Localization string `json:"localization"`
|
||||
ClinicalDiagnoses string `json:"clinicalDiagnoses"`
|
||||
Stadium string `json:"stadium"`
|
||||
ClinicalNotes string `json:"clinicalNotes"`
|
||||
CurrentHistory string `json:"currentHistory"`
|
||||
PastHistory string `json:"pastHistory"`
|
||||
PrevApMcu string `json:"prevApMcu"`
|
||||
PrevApMcuNotes string `json:"prevApMcuNotes"`
|
||||
SupportingExams string `json:"supportingExams"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package apmcuorder
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type ApMcuOrder struct {
|
||||
ecore.BigMain
|
||||
Encounter_Id uint `json:"encounter_id"`
|
||||
Number uint64 `json:"number"`
|
||||
Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"`
|
||||
Substances string `json:"substances"`
|
||||
Fictations string `json:"fictations"`
|
||||
Localization string `json:"localization"`
|
||||
ClinicalDiagnoses string `json:"clinicalDiagnoses"`
|
||||
Stadium string `json:"stadium"`
|
||||
ClinicalNotes *string `json:"clinicalNotes"`
|
||||
CurrentHistory string `json:"currentHistory"`
|
||||
PastHistory string `json:"pastHistory"`
|
||||
PrevApMcu *string `json:"prevApMcu"`
|
||||
PrevApMcuNotes *string `json:"prevApMcuNotes"`
|
||||
SupportingExams *string `json:"supportingExams"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package apmcuorder
|
||||
|
||||
import (
|
||||
la "simrs-vx/internal/lib/auth"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
eamob "simrs-vx/internal/domain/main-entities/ap-mcu-order/base"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
eamob.CreateDto
|
||||
la.AuthInfo
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Sort string `json:"sort"`
|
||||
Pagination ecore.Pagination
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
McuOrder_Id string `json:"mcu-order-id"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
PageNumber int `json:"page_number"`
|
||||
PageSize int `json:"page_size"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.BigMain
|
||||
Encounter_Id uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter
|
||||
Number uint64 `json:"number"`
|
||||
Doctor_Code string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor
|
||||
Substances string `json:"substances"`
|
||||
Fictations string `json:"fictations"`
|
||||
Localization string `json:"localization"`
|
||||
ClinicalDiagnoses string `json:"clinicalDiagnoses"`
|
||||
Stadium string `json:"stadium"`
|
||||
ClinicalNotes *string `json:"clinicalNotes"`
|
||||
PastHistory string `json:"pastHistory"`
|
||||
CurrentHistory string `json:"currentHistory"`
|
||||
PrevApMcu *string `json:"prevApMcu"`
|
||||
PrevApMcuNotes *string `json:"prevApMcuNotes"`
|
||||
SupportingExams *string `json:"supportingExams"`
|
||||
}
|
||||
|
||||
func (d ApMcuOrder) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
Encounter: d.Encounter,
|
||||
Number: d.Number,
|
||||
Doctor_Code: d.Doctor_Code,
|
||||
Doctor: d.Doctor,
|
||||
Substances: d.Substances,
|
||||
Fictations: d.Fictations,
|
||||
Localization: d.Localization,
|
||||
ClinicalDiagnoses: d.ClinicalDiagnoses,
|
||||
Stadium: d.Stadium,
|
||||
ClinicalNotes: d.ClinicalNotes,
|
||||
PastHistory: d.PastHistory,
|
||||
CurrentHistory: d.CurrentHistory,
|
||||
PrevApMcu: d.PrevApMcu,
|
||||
PrevApMcuNotes: d.PrevApMcuNotes,
|
||||
SupportingExams: d.SupportingExams,
|
||||
}
|
||||
resp.BigMain = d.BigMain
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []ApMcuOrder) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package apmcuorder
|
||||
|
||||
import (
|
||||
eamob "simrs-vx/internal/domain/main-entities/ap-mcu-order/base"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type ApMcuOrder struct {
|
||||
eamob.ApMcuOrder
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
}
|
||||
|
||||
func (d ApMcuOrder) IsNotNew() bool {
|
||||
return d.Status_Code != erc.DSCNew
|
||||
}
|
||||
|
||||
func (d ApMcuOrder) IsCompleted() bool {
|
||||
return d.Status_Code == erc.DSCDone
|
||||
}
|
||||
|
||||
func (d ApMcuOrder) IsSameDoctor(doctor_code *string) bool {
|
||||
return d.Doctor_Code == *doctor_code
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package chemo_plan
|
||||
|
||||
import (
|
||||
// std
|
||||
"time"
|
||||
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
|
||||
// internal - domain - main-entities
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Parent_Id *uint `json:"parent_id"`
|
||||
SeriesNumber *uint16 `json:"seriesNumber"`
|
||||
CycleNumber *uint `json:"cycleNumber"`
|
||||
PlanDate *time.Time `json:"planDate"`
|
||||
RealizationDate *time.Time `json:"realizationDate"`
|
||||
Notes *string `json:"notes"`
|
||||
Status ere.StatusProtocolChemo `json:"status"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Pagination ecore.Pagination
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Parent_Id *uint `json:"parent-id"`
|
||||
Protocol_Id *uint `json:"protocol-id"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
PageNumber int `json:"page_number"`
|
||||
PageSize int `json:"page_size"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Parent_Id *uint `json:"parent_id"` // chemo.Id
|
||||
Protocol_Id *uint `json:"protocol_id"`
|
||||
SeriesNumber *uint16 `json:"seriesNumber"` // series ke -
|
||||
CycleNumber *uint `json:"cycleNumber"` // cycle ke -
|
||||
PlanDate *time.Time `json:"planDate"`
|
||||
RealizationDate *time.Time `json:"realizationDate"`
|
||||
Notes *string `json:"notes"`
|
||||
Status ere.StatusProtocolChemo `json:"status"`
|
||||
}
|
||||
|
||||
func (d ChemoPlan) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Parent_Id: d.Parent_Id,
|
||||
SeriesNumber: d.SeriesNumber,
|
||||
CycleNumber: d.CycleNumber,
|
||||
PlanDate: d.PlanDate,
|
||||
RealizationDate: d.RealizationDate,
|
||||
Notes: d.Notes,
|
||||
Status: d.Status,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []ChemoPlan) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package chemo_plan
|
||||
|
||||
import (
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
"time"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
)
|
||||
|
||||
type ChemoPlan struct {
|
||||
ecore.Main
|
||||
Parent_Id *uint `json:"parent_id"` // chemo.Id
|
||||
Protocol_Id *uint `json:"protocol_id"`
|
||||
SeriesNumber *uint16 `json:"seriesNumber"` // series ke -
|
||||
CycleNumber *uint `json:"cycleNumber"` // cycle ke -
|
||||
PlanDate *time.Time `json:"planDate"`
|
||||
RealizationDate *time.Time `json:"realizationDate"`
|
||||
Notes *string `json:"notes"`
|
||||
Status ere.StatusProtocolChemo `json:"status"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
}
|
||||
@@ -9,18 +9,21 @@ import (
|
||||
|
||||
// internal - domain - main-entities
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
|
||||
ec "simrs-vx/internal/domain/main-entities/chemo"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Patient_Weight *float32 `json:"patient_weight"`
|
||||
Patient_Height *float32 `json:"patient_height"`
|
||||
Diagnoses *string `json:"diagnoses"`
|
||||
Duration *uint `json:"duration"`
|
||||
DurationUnit_Code *erc.TimeUnitCode `json:"durationUnit_code"`
|
||||
StartDate *time.Time `json:"startDate"`
|
||||
EndDate *time.Time `json:"endDate"`
|
||||
Chemo_Id *uint `json:"chemo_id"`
|
||||
Patient_Weight *float32 `json:"patient_weight"`
|
||||
Patient_Height *float32 `json:"patient_height"`
|
||||
Diagnoses *string `json:"diagnoses"`
|
||||
Interval *uint `json:"interval"`
|
||||
Cycle *uint `json:"cycle"`
|
||||
Series *uint16 `json:"series"`
|
||||
StartDate *time.Time `json:"startDate"`
|
||||
EndDate *time.Time `json:"endDate"`
|
||||
Status_Code erc.DataVerifiedCode `json:"-"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
@@ -30,7 +33,7 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Encounter_Id *uint `json:"encounter-id"`
|
||||
Chemo_Id *uint `json:"chemo-id"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
@@ -55,28 +58,32 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||
Patient_Weight *float32 `json:"patient_weight"`
|
||||
Patient_Height *float32 `json:"patient_height"`
|
||||
Diagnoses *string `json:"diagnoses"`
|
||||
Duration *uint `json:"duration"`
|
||||
DurationUnit_Code *erc.TimeUnitCode `json:"durationUnit_code"`
|
||||
StartDate *time.Time `json:"startDate"`
|
||||
EndDate *time.Time `json:"endDate"`
|
||||
Chemo_Id *uint `json:"chemo_id"`
|
||||
Chemo *ec.Chemo `json:"chemo,omitempty"`
|
||||
Patient_Weight *float32 `json:"patient_weight"`
|
||||
Patient_Height *float32 `json:"patient_height"`
|
||||
Diagnoses *string `json:"diagnoses"`
|
||||
Interval *uint `json:"interval"`
|
||||
Cycle *uint `json:"cycle"`
|
||||
Series *uint16 `json:"series"`
|
||||
StartDate *time.Time `json:"startDate"`
|
||||
EndDate *time.Time `json:"endDate"`
|
||||
Status_Code erc.DataVerifiedCode `json:"status_code"`
|
||||
}
|
||||
|
||||
func (d ChemoProtocol) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
Encounter: d.Encounter,
|
||||
Patient_Weight: d.Patient_Weight,
|
||||
Patient_Height: d.Patient_Height,
|
||||
Diagnoses: d.Diagnoses,
|
||||
Duration: d.Duration,
|
||||
DurationUnit_Code: d.DurationUnit_Code,
|
||||
StartDate: d.StartDate,
|
||||
EndDate: d.EndDate,
|
||||
Chemo_Id: d.Chemo_Id,
|
||||
Chemo: d.Chemo,
|
||||
Patient_Weight: d.Patient_Weight,
|
||||
Patient_Height: d.Patient_Height,
|
||||
Diagnoses: d.Diagnoses,
|
||||
Interval: d.Interval,
|
||||
Cycle: d.Cycle,
|
||||
Series: d.Series,
|
||||
StartDate: d.StartDate,
|
||||
EndDate: d.EndDate,
|
||||
Status_Code: d.Status_Code,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -1,21 +1,34 @@
|
||||
package chemo_protocol
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
"simrs-vx/internal/domain/references/common"
|
||||
"time"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
|
||||
ec "simrs-vx/internal/domain/main-entities/chemo"
|
||||
ecp "simrs-vx/internal/domain/main-entities/chemo-plan"
|
||||
eus "simrs-vx/internal/domain/main-entities/user"
|
||||
)
|
||||
|
||||
type ChemoProtocol struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Patient_Weight *float32 `json:"patient_weight"`
|
||||
Patient_Height *float32 `json:"patient_height"`
|
||||
Diagnoses *string `json:"diagnoses"`
|
||||
Duration *uint `json:"duration"`
|
||||
DurationUnit_Code *common.TimeUnitCode `json:"durationUnit_code" gorm:"size:10"`
|
||||
StartDate *time.Time `json:"startDate"`
|
||||
EndDate *time.Time `json:"endDate"`
|
||||
Chemo_Id *uint `json:"chemo_id"`
|
||||
Chemo *ec.Chemo `json:"chemo,omitempty" gorm:"foreignKey:Chemo_Id;references:Id"`
|
||||
Patient_Weight *float32 `json:"patient_weight"`
|
||||
Patient_Height *float32 `json:"patient_height"`
|
||||
Diagnoses *string `json:"diagnoses"`
|
||||
Duration *uint `json:"duration"` // not used
|
||||
DurationUnit_Code *erc.TimeUnitCode `json:"durationUnit_code"` // not used
|
||||
Interval *uint `json:"interval"`
|
||||
Cycle *uint `json:"cycle"` // total cycle
|
||||
Series *uint16 `json:"series"` // total series
|
||||
StartDate *time.Time `json:"startDate"`
|
||||
EndDate *time.Time `json:"endDate"`
|
||||
Status_Code erc.DataVerifiedCode `json:"status_code"`
|
||||
VerifiedAt *time.Time `json:"verifiedAt"`
|
||||
VerifiedBy_User_Id *uint `json:"verifiedBy_user_id"`
|
||||
VerifiedBy *eus.User `json:"verifiedBy,omitempty" gorm:"foreignKey:VerifiedBy_User_Id;references:Id"`
|
||||
ChemoPlans *[]ecp.ChemoPlan `json:"chemoPlans,omitempty" gorm:"foreignKey:Protocol_Id;references:Id"`
|
||||
Patient_Id *uint `json:"patient_id"`
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package chemo
|
||||
|
||||
import (
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
// std
|
||||
"time"
|
||||
|
||||
@@ -50,10 +51,12 @@ type DeleteDto struct {
|
||||
}
|
||||
|
||||
type VerifyDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Status_Code erc.DataVerifiedCode `json:"status_code"`
|
||||
Bed *string `json:"bed" validate:"required"`
|
||||
Needs *string `json:"needs" validate:"required"`
|
||||
Id uint16 `json:"id"`
|
||||
Status_Code erc.DataVerifiedCode `json:"status_code"`
|
||||
Bed *string `json:"bed"`
|
||||
Needs *string `json:"needs"`
|
||||
Doctor_Code *string `json:"doctor_code" validate:"required"`
|
||||
NextChemoDate *time.Time `json:"nextChemoDate"`
|
||||
|
||||
pa.AuthInfo
|
||||
}
|
||||
@@ -74,6 +77,9 @@ type ResponseDto struct {
|
||||
VerifiedBy *eus.User `json:"verifiedBy,omitempty"`
|
||||
SrcUnit_Code *string `json:"srcUnit_code"`
|
||||
SrcUnit *eun.Unit `json:"srcUnit,omitempty"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
NextChemoDate *time.Time `json:"nextChemoDate"`
|
||||
}
|
||||
|
||||
func (d Chemo) ToResponse() ResponseDto {
|
||||
@@ -86,6 +92,9 @@ func (d Chemo) ToResponse() ResponseDto {
|
||||
VerifiedBy: d.VerifiedBy,
|
||||
SrcUnit_Code: d.SrcUnit_Code,
|
||||
SrcUnit: d.SrcUnit,
|
||||
Doctor_Code: d.Doctor_Code,
|
||||
Doctor: d.Doctor,
|
||||
NextChemoDate: d.NextChemoDate,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package chemo
|
||||
|
||||
import (
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
"time"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
eun "simrs-vx/internal/domain/main-entities/unit"
|
||||
eus "simrs-vx/internal/domain/main-entities/user"
|
||||
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type Chemo struct {
|
||||
@@ -19,8 +21,12 @@ type Chemo struct {
|
||||
VerifiedAt *time.Time `json:"verifiedAt"`
|
||||
VerifiedBy_User_Id *uint `json:"verifiedBy_user_id"`
|
||||
VerifiedBy *eus.User `json:"verifiedBy,omitempty" gorm:"foreignKey:VerifiedBy_User_Id;references:Id"`
|
||||
SrcUnit_Code *string `json:"src_unit_code"`
|
||||
SrcUnit_Code *string `json:"src_unit_code"` // klinik asal
|
||||
SrcUnit *eun.Unit `json:"src_unit,omitempty" gorm:"foreignKey:SrcUnit_Code;references:Code"`
|
||||
Bed *string `json:"bed" gorm:"size:1024"`
|
||||
Needs *string `json:"needs" gorm:"size:2048"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
NextChemoDate *time.Time `json:"nextChemoDate"`
|
||||
Class_Code ere.ChemoClassCode `json:"class_code"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package cpmcuorderitem
|
||||
|
||||
type SubCreateDto struct {
|
||||
McuSrc_Code string `json:"mcuSrc_code" validate:"required"`
|
||||
Note string `json:"note"`
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cpmcuorderitem
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ems "simrs-vx/internal/domain/main-entities/mcu-src"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type CpMcuOrderItem struct {
|
||||
ecore.BigMain // adjust this according to the needs
|
||||
CpMcuOrder_Id uint64 `json:"cpMcuOrder_id" gorm:"uniqueIndex:idx_order_src"`
|
||||
McuSrc_Code string `json:"mcuSrc_code" gorm:"uniqueIndex:idx_order_src"`
|
||||
McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Code;references:Code"`
|
||||
Note *string `json:"note" gorm:"size:1024"`
|
||||
Result *string `json:"result"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package cpmcuorderitem
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
emro "simrs-vx/internal/domain/main-entities/cp-mcu-order"
|
||||
ems "simrs-vx/internal/domain/main-entities/mcu-src"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
CpMcuOrder_Id uint64 `json:"cpMcuOrder_id"`
|
||||
McuSrc_Code string `json:"mcuSrc_code"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Pagination ecore.Pagination
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
CpMcuOrder_Id *uint64 `json:"cp-mcu-order-id"`
|
||||
McuSrc_Code *string `json:"mcu-src-code"`
|
||||
Status_Code erc.DataStatusCode `json:"status-code"`
|
||||
}
|
||||
type ReadDetailDto struct {
|
||||
Id uint `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint `json:"id"`
|
||||
}
|
||||
|
||||
type SetScheduleDto struct {
|
||||
Id uint `json:"id"`
|
||||
ExaminationDate *time.Time `json:"examinationDate"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
PageNumber int `json:"page_number"`
|
||||
PageSize int `json:"page_size"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.BigMain
|
||||
CpMcuOrder_Id uint64 `json:"cpMcuOrder_id"`
|
||||
CpMcuOrder *emro.CpMcuOrder `json:"cpMcuOrder,omitempty"`
|
||||
McuSrc_Code string `json:"mcuSrc_code"`
|
||||
McuSrc *ems.McuSrc `json:"mcuSrc,omitempty"`
|
||||
Result *string `json:"result"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
}
|
||||
|
||||
func (d CpMcuOrderItem) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
CpMcuOrder_Id: d.CpMcuOrder_Id,
|
||||
CpMcuOrder: d.CpMcuOrder,
|
||||
McuSrc_Code: d.McuSrc_Code,
|
||||
McuSrc: d.McuSrc,
|
||||
Result: d.Result,
|
||||
Status_Code: d.Status_Code,
|
||||
}
|
||||
resp.BigMain = d.BigMain
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []CpMcuOrderItem) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cpmcuorderitem
|
||||
|
||||
import (
|
||||
emo "simrs-vx/internal/domain/main-entities/cp-mcu-order"
|
||||
emoib "simrs-vx/internal/domain/main-entities/cp-mcu-order-item/base"
|
||||
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type CpMcuOrderItem struct {
|
||||
emoib.CpMcuOrderItem
|
||||
CpMcuOrder *emo.CpMcuOrder `json:"cpMcuOrder,omitempty" gorm:"foreignKey:CpMcuOrder_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d CpMcuOrderItem) IsCompleted() bool {
|
||||
return d.Status_Code == erc.DSCDone
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cpmcuorder
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ercl "simrs-vx/internal/domain/references/clinical"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type CpMcuOrder struct {
|
||||
ecore.BigMain
|
||||
Encounter_Id uint `json:"encounter_id"`
|
||||
Number uint64 `json:"number"`
|
||||
Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"`
|
||||
UrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"urgencyLevel_code" gorm:"not null;size:15"`
|
||||
OtherNotes *string `json:"otherNotes"`
|
||||
ExamScheduleDate *time.Time `json:"examinationDate"`
|
||||
Resume *string `json:"resume"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package cpmcuorder
|
||||
|
||||
import (
|
||||
la "simrs-vx/internal/lib/auth"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Encounter_Id uint `json:"encounter_id" validate:"required"`
|
||||
Number uint64 `json:"number"` // SHOULD BE AUTOMATIC WITHOUT SYNC
|
||||
UrgencyLevel_Code string `json:"urgencyLevel_code" validate:"required"`
|
||||
OtherNotes string `json:"otherNotes"`
|
||||
la.AuthInfo
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Sort string `json:"sort"`
|
||||
Pagination ecore.Pagination
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Encounter_Id uint `json:"encounter-id"`
|
||||
Doctor_Code string `json:"doctor-code"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
PageNumber int `json:"page_number"`
|
||||
PageSize int `json:"page_size"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.BigMain
|
||||
Encounter_Id uint
|
||||
Encounter *ee.Encounter
|
||||
Number uint64 `json:"number"`
|
||||
Doctor_Code string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor
|
||||
UrgencyLevel_Code string `json:"urgencyLevel_code" gorm:"not null;size:15"`
|
||||
OtherNotes *string `json:"otherNotes"`
|
||||
Resume *string `json:"resume"`
|
||||
}
|
||||
|
||||
func (d CpMcuOrder) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
Encounter: d.Encounter,
|
||||
Number: d.Number,
|
||||
Doctor_Code: d.Doctor_Code,
|
||||
Doctor: d.Doctor,
|
||||
UrgencyLevel_Code: string(d.UrgencyLevel_Code),
|
||||
OtherNotes: d.OtherNotes,
|
||||
Resume: d.Resume,
|
||||
}
|
||||
resp.BigMain = d.BigMain
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []CpMcuOrder) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cpmcuorder
|
||||
|
||||
import (
|
||||
ecmoi "simrs-vx/internal/domain/main-entities/cp-mcu-order-item/base"
|
||||
eamob "simrs-vx/internal/domain/main-entities/cp-mcu-order/base"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type CpMcuOrder struct {
|
||||
eamob.CpMcuOrder
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
Items []*ecmoi.CpMcuOrderItem `json:"items" gorm:"foreignKey:CpMcuOrder_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d CpMcuOrder) IsNotNew() bool {
|
||||
return d.Status_Code != erc.DSCNew
|
||||
}
|
||||
|
||||
func (d CpMcuOrder) IsCompleted() bool {
|
||||
return d.Status_Code == erc.DSCDone
|
||||
}
|
||||
|
||||
func (d CpMcuOrder) IsSameDoctor(doctor_code *string) bool {
|
||||
return d.Doctor_Code == *doctor_code
|
||||
}
|
||||
@@ -34,28 +34,39 @@ import (
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Patient_Id *uint `json:"patient_id"`
|
||||
RegisteredAt *time.Time `json:"registeredAt"`
|
||||
Class_Code ere.EncounterClassCode `json:"class_code" validate:"maxLength=10"`
|
||||
SubClass_Code *string `json:"subClass_code" validate:"maxLength=10"` // for sub
|
||||
Infra_Code *string `json:"infra_code"` // for inpatient
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
Specialist_Code *string `json:"specialist_code"`
|
||||
Subspecialist_Code *string `json:"subspecialist_code"`
|
||||
VisitDate time.Time `json:"visitDate"`
|
||||
PaymentMethod_Code ere.AllPaymentMethodCode `json:"paymentMethod_code" gorm:"size:10"`
|
||||
InsuranceCompany_Code *string `json:"insuranceCompany_code"`
|
||||
Member_Number *string `json:"member_number" validate:"maxLength=20"`
|
||||
Ref_Number *string `json:"ref_number" validate:"maxLength=20"`
|
||||
Trx_Number *string `json:"trx_number" validate:"maxLength=20"`
|
||||
Appointment_Doctor_Code *string `json:"appointment_doctor_code"`
|
||||
Adm_Employee_Id *uint `json:"-"`
|
||||
Responsible_Doctor_Code *string `json:"responsible_doctor_code"`
|
||||
RefSource_Name *string `json:"refSource_name" validate:"maxLength=100"`
|
||||
Appointment_Id *uint `json:"appointment_id"`
|
||||
RefTypeCode ere.RefTypeCode `json:"refTypeCode"`
|
||||
NewStatus bool `json:"newStatus"`
|
||||
VclaimReference *TRujukan `json:"vclaimReference"`
|
||||
Patient_Id *uint `json:"patient_id"`
|
||||
RegisteredAt *time.Time `json:"registeredAt"`
|
||||
Class_Code ere.EncounterClassCode `json:"class_code" validate:"maxLength=10"`
|
||||
SubClass_Code *string `json:"subClass_code" validate:"maxLength=10"` // for sub
|
||||
Infra_Code *string `json:"infra_code"` // for inpatient
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
Specialist_Code *string `json:"specialist_code"`
|
||||
Subspecialist_Code *string `json:"subspecialist_code"`
|
||||
VisitDate time.Time `json:"visitDate"`
|
||||
StartedAt *time.Time `json:"startedAt"`
|
||||
FinishedAt *time.Time `json:"finishedAt"`
|
||||
PaymentMethod_Code ere.AllPaymentMethodCode `json:"paymentMethod_code" gorm:"size:10"`
|
||||
InsuranceCompany_Code *string `json:"insuranceCompany_code"`
|
||||
Member_Number *string `json:"member_number" validate:"maxLength=20"`
|
||||
RefTypeCode ere.RefTypeCode `json:"refTypeCode"`
|
||||
Ref_Number *string `json:"ref_number" validate:"maxLength=20"`
|
||||
Trx_Number *string `json:"trx_number" validate:"maxLength=20"`
|
||||
Appointment_Doctor_Code *string `json:"appointment_doctor_code"`
|
||||
Adm_Employee_Id *uint `json:"-"`
|
||||
Responsible_Doctor_Code *string `json:"responsible_doctor_code"`
|
||||
Responsible_Nurse_Code *string `json:"responsible_nurse_code"`
|
||||
Discharge_Method_Code *ere.DischargeMethodCode `json:"discharge_method_code" gorm:"size:16"`
|
||||
RefSource_Name *string `json:"refSource_name" validate:"maxLength=100"`
|
||||
Appointment_Id *uint `json:"appointment_id"`
|
||||
EarlyEducation *string `json:"earlyEducation"`
|
||||
MedicalDischargeEducation *string `json:"medicalDischargeEducation"`
|
||||
AdmDischargeEducation *string `json:"admDischargeEducation"`
|
||||
DischargeReason *string `json:"dischargeReason"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code" gorm:"size:10"`
|
||||
Discharge_Date *time.Time `json:"discharge_date"`
|
||||
DeathCause *edc.DeathCause `json:"deathCause"`
|
||||
NewStatus bool `json:"newStatus"`
|
||||
VclaimReference *TRujukan `json:"vclaimReference"`
|
||||
|
||||
Id uint `json:"-"`
|
||||
RecentEncounterAdm *Encounter `json:"-"` // if subClass_Code is rehab
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package micromcuorderitem
|
||||
|
||||
type SubCreateDto struct {
|
||||
McuSrc_Code string `json:"mcuSrc_code" validate:"required"`
|
||||
Note string `json:"note"`
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package micromcuorderitem
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ems "simrs-vx/internal/domain/main-entities/mcu-src"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type MicroMcuOrderItem struct {
|
||||
ecore.BigMain // adjust this according to the needs
|
||||
MicroMcuOrder_Id uint64 `json:"microMcuOrder_id" gorm:"uniqueIndex:idx_order_src"`
|
||||
McuSrc_Code string `json:"mcuSrc_code" gorm:"uniqueIndex:idx_order_src"`
|
||||
McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Code;references:Code"`
|
||||
Note *string `json:"note" gorm:"size:1024"`
|
||||
Result *string `json:"result"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package micromcuorderitem
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ems "simrs-vx/internal/domain/main-entities/mcu-src"
|
||||
emro "simrs-vx/internal/domain/main-entities/micro-mcu-order"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
MicroMcuOrder_Id uint64 `json:"microMcuOrder_id"`
|
||||
McuSrc_Code string `json:"mcuSrc_code"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Pagination ecore.Pagination
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
MicroMcuOrder_Id *uint64 `json:"micro-mcu-order-id"`
|
||||
McuSrc_Code *string `json:"mcu-src-code"`
|
||||
Status_Code erc.DataStatusCode `json:"status-code"`
|
||||
}
|
||||
type ReadDetailDto struct {
|
||||
Id uint `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint `json:"id"`
|
||||
}
|
||||
|
||||
type SetScheduleDto struct {
|
||||
Id uint `json:"id"`
|
||||
ExaminationDate *time.Time `json:"examinationDate"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
PageNumber int `json:"page_number"`
|
||||
PageSize int `json:"page_size"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.BigMain
|
||||
MicroMcuOrder_Id uint64 `json:"microMcuOrder_id"`
|
||||
MicroMcuOrder *emro.MicroMcuOrder `json:"microMcuOrder,omitempty"`
|
||||
McuSrc_Code string `json:"mcuSrc_code"`
|
||||
McuSrc *ems.McuSrc `json:"mcuSrc,omitempty"`
|
||||
Result *string `json:"result"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
}
|
||||
|
||||
func (d MicroMcuOrderItem) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
MicroMcuOrder_Id: d.MicroMcuOrder_Id,
|
||||
MicroMcuOrder: d.MicroMcuOrder,
|
||||
McuSrc_Code: d.McuSrc_Code,
|
||||
McuSrc: d.McuSrc,
|
||||
Result: d.Result,
|
||||
Status_Code: d.Status_Code,
|
||||
}
|
||||
resp.BigMain = d.BigMain
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []MicroMcuOrderItem) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package micromcuorderitem
|
||||
|
||||
import (
|
||||
ems "simrs-vx/internal/domain/main-entities/mcu-src"
|
||||
emo "simrs-vx/internal/domain/main-entities/micro-mcu-order"
|
||||
emoib "simrs-vx/internal/domain/main-entities/micro-mcu-order-item/base"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type MicroMcuOrderItem struct {
|
||||
emoib.MicroMcuOrderItem
|
||||
MicroMcuOrder *emo.MicroMcuOrder `json:"microMcuOrder,omitempty" gorm:"foreignKey:MicroMcuOrder_Id;references:Id"`
|
||||
McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Code;references:Code"`
|
||||
}
|
||||
|
||||
func (d MicroMcuOrderItem) IsCompleted() bool {
|
||||
return d.Status_Code == erc.DSCDone
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package micromcuorder
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ercl "simrs-vx/internal/domain/references/clinical"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type MicroMcuOrder struct {
|
||||
ecore.BigMain
|
||||
Encounter_Id uint `json:"encounter_id"`
|
||||
Number uint64 `json:"number"`
|
||||
Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"`
|
||||
Stage_Code ercl.McuOrderStageCode `json:"stage_code" gorm:"not null;size:10"`
|
||||
AxillaryTemp float64 `json:"axillaryTemp"`
|
||||
OtherNotes *string `json:"otherNotes"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package micromcuorder
|
||||
|
||||
import (
|
||||
la "simrs-vx/internal/lib/auth"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
ercl "simrs-vx/internal/domain/references/clinical"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Encounter_Id uint `json:"encounter_id" validate:"required"`
|
||||
Number uint64 `json:"number"` // SHOULD BE AUTOMATIC WITHOUT SYNC
|
||||
OrderStage_Code string `json:"orderStage_code" gorm:"not null;size:10"`
|
||||
AxillaryTemp float64 `json:"axillaryTemp"`
|
||||
OtherNotes string `json:"otherNotes"`
|
||||
la.AuthInfo
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Sort string `json:"sort"`
|
||||
Pagination ecore.Pagination
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Encounter_Id uint `json:"encounter-id"`
|
||||
Doctor_Code string `json:"doctor-code"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
PageNumber int `json:"page_number"`
|
||||
PageSize int `json:"page_size"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.BigMain
|
||||
Encounter_Id uint
|
||||
Encounter *ee.Encounter
|
||||
Number uint64 `json:"number"`
|
||||
Doctor_Code string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor
|
||||
Stage_Code ercl.McuOrderStageCode `json:"stage_code" gorm:"not null;size:10"`
|
||||
AxillaryTemp float64 `json:"axillaryTemp"`
|
||||
OtherNotes *string `json:"otherNotes"`
|
||||
}
|
||||
|
||||
func (d MicroMcuOrder) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
Encounter: d.Encounter,
|
||||
Number: d.Number,
|
||||
Doctor_Code: d.Doctor_Code,
|
||||
Doctor: d.Doctor,
|
||||
Stage_Code: d.Stage_Code,
|
||||
AxillaryTemp: d.AxillaryTemp,
|
||||
OtherNotes: d.OtherNotes,
|
||||
}
|
||||
resp.BigMain = d.BigMain
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []MicroMcuOrder) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package micromcuorder
|
||||
|
||||
import (
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
emmoi "simrs-vx/internal/domain/main-entities/micro-mcu-order-item/base"
|
||||
eamob "simrs-vx/internal/domain/main-entities/micro-mcu-order/base"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type MicroMcuOrder struct {
|
||||
eamob.MicroMcuOrder
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
Items []*emmoi.MicroMcuOrderItem `json:"items" gorm:"foreignKey:MicroMcuOrder_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d MicroMcuOrder) IsNotNew() bool {
|
||||
return d.Status_Code != erc.DSCNew
|
||||
}
|
||||
|
||||
func (d MicroMcuOrder) IsCompleted() bool {
|
||||
return d.Status_Code == erc.DSCDone
|
||||
}
|
||||
|
||||
func (d MicroMcuOrder) IsSameDoctor(doctor_code *string) bool {
|
||||
return d.Doctor_Code == *doctor_code
|
||||
}
|
||||
@@ -60,6 +60,7 @@ type UpdateDto struct {
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint `json:"id"`
|
||||
pa.AuthInfo
|
||||
}
|
||||
|
||||
type SearchDto struct {
|
||||
|
||||
@@ -19,6 +19,7 @@ type CreateDto struct {
|
||||
FrontTitle *string `json:"frontTitle" validate:"maxLength=50"`
|
||||
EndTitle *string `json:"endTitle" validate:"maxLength=50"`
|
||||
BirthDate *time.Time `json:"birthDate,omitempty"`
|
||||
BirthPlace *string `json:"birthPlace" validate:"maxLength=4"`
|
||||
BirthRegency_Code *string `json:"birthRegency_code" validate:"maxLength=4"`
|
||||
Gender_Code *erp.GenderCode `json:"gender_code"`
|
||||
ResidentIdentityNumber *string `json:"residentIdentityNumber" validate:"nik;maxLength=16"`
|
||||
@@ -46,14 +47,13 @@ type ReadListDto struct {
|
||||
|
||||
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"`
|
||||
FrontTitle *string `json:"front-title"`
|
||||
EndTitle *string `json:"end-title"`
|
||||
BirthDate *time.Time `json:"birth-date,omitempty"`
|
||||
Gender_Code *erp.GenderCode `json:"gender-code"`
|
||||
ResidentIdentityNumber *string `json:"residentIdentityNumber"`
|
||||
PassportNumber *string `json:"passportNumber"`
|
||||
DrivingLicenseNumber *string `json:"drivingLicenseNumber"`
|
||||
ResidentIdentityNumber *string `json:"resident-identity-number"`
|
||||
PassportNumber *string `json:"passport-number"`
|
||||
DrivingLicenseNumber *string `json:"driving-license-number"`
|
||||
Religion_Code *erp.ReligionCode `json:"religion-code"`
|
||||
Education_Code *erp.EducationCode `json:"education-code"`
|
||||
Ocupation_Code *erp.OcupationCode `json:"occupation-code"`
|
||||
@@ -61,7 +61,7 @@ type FilterDto struct {
|
||||
Nationality *string `json:"nationality"`
|
||||
Ethnic_Code *string `json:"ethnic-code"`
|
||||
Language_Code *string `json:"language-code"`
|
||||
CommunicationIssueStatus bool `json:"communicationIssueStatus"`
|
||||
CommunicationIssueStatus bool `json:"communication-issue-status"`
|
||||
Disability *string `json:"disability"`
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ type ResponseDto struct {
|
||||
FrontTitle *string `json:"frontTitle"`
|
||||
EndTitle *string `json:"endTitle"`
|
||||
BirthDate *time.Time `json:"birthDate,omitempty"`
|
||||
BirthPlace *string `json:"birthPlace"`
|
||||
BirthRegency_Code *string `json:"birthRegency_code"`
|
||||
BirthRegency *er.Regency `json:"birthRegency,omitempty"`
|
||||
Gender_Code *erp.GenderCode `json:"gender_code"`
|
||||
@@ -128,6 +129,7 @@ func (d *Person) ToResponse() ResponseDto {
|
||||
FrontTitle: d.FrontTitle,
|
||||
EndTitle: d.EndTitle,
|
||||
BirthDate: d.BirthDate,
|
||||
BirthPlace: d.BirthPlace,
|
||||
BirthRegency_Code: d.BirthRegency_Code,
|
||||
BirthRegency: d.BirthRegency,
|
||||
Gender_Code: d.Gender_Code,
|
||||
|
||||
@@ -23,6 +23,7 @@ type Person struct {
|
||||
FrontTitle *string `json:"frontTitle" gorm:"size:50"`
|
||||
EndTitle *string `json:"endTitle" gorm:"size:50"`
|
||||
BirthDate *time.Time `json:"birthDate,omitempty"`
|
||||
BirthPlace *string `json:"birthPlace,omitempty"`
|
||||
BirthRegency_Code *string `json:"birthRegency_code" gorm:"size:4"`
|
||||
BirthRegency *er.Regency `json:"birthRegency,omitempty" gorm:"foreignKey:BirthRegency_Code;references:Code"`
|
||||
Gender_Code *erp.GenderCode `json:"gender_code" gorm:"size:10"`
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package radiologymcuorderitem
|
||||
|
||||
type SubCreateDto struct {
|
||||
McuSrc_Code string `json:"mcuSrc_code" validate:"required"`
|
||||
Note string `json:"note"`
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package radiologymcuorderitem
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ems "simrs-vx/internal/domain/main-entities/mcu-src"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type RadiologyMcuOrderItem struct {
|
||||
ecore.BigMain // adjust this according to the needs
|
||||
RadiologyMcuOrder_Id uint64 `json:"radiologyMcuOrder_id" gorm:"uniqueIndex:idx_order_src"`
|
||||
McuSrc_Code string `json:"mcuSrc_code" gorm:"uniqueIndex:idx_order_src"`
|
||||
McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Code;references:Code"`
|
||||
Note *string `json:"note" gorm:"size:1024"`
|
||||
Result *string `json:"result"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package radiologymcuorderitem
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ems "simrs-vx/internal/domain/main-entities/mcu-src"
|
||||
emro "simrs-vx/internal/domain/main-entities/radiology-mcu-order"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
RadiologyMcuOrder_Id uint64 `json:"radiologyMcuOrder_id"`
|
||||
McuSrc_Code string `json:"mcuSrc_code"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Pagination ecore.Pagination
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
RadiologyMcuOrder_Id *uint64 `json:"radiology-mcu-order-id"`
|
||||
McuSrc_Code *string `json:"mcu-src-code"`
|
||||
Status_Code erc.DataStatusCode `json:"status-code"`
|
||||
}
|
||||
type ReadDetailDto struct {
|
||||
Id uint `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint `json:"id"`
|
||||
}
|
||||
|
||||
type SetScheduleDto struct {
|
||||
Id uint `json:"id"`
|
||||
ExaminationDate *time.Time `json:"examinationDate"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
PageNumber int `json:"page_number"`
|
||||
PageSize int `json:"page_size"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.BigMain
|
||||
RadiologyMcuOrder_Id uint64 `json:"radiologyMcuOrder_id"`
|
||||
RadiologyMcuOrder *emro.RadiologyMcuOrder `json:"radiologyMcuOrder,omitempty"`
|
||||
McuSrc_Code string `json:"mcuSrc_code"`
|
||||
McuSrc *ems.McuSrc `json:"mcuSrc,omitempty"`
|
||||
Result *string `json:"result"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
}
|
||||
|
||||
func (d RadiologyMcuOrderItem) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
RadiologyMcuOrder_Id: d.RadiologyMcuOrder_Id,
|
||||
RadiologyMcuOrder: d.RadiologyMcuOrder,
|
||||
McuSrc_Code: d.McuSrc_Code,
|
||||
McuSrc: d.McuSrc,
|
||||
Result: d.Result,
|
||||
Status_Code: d.Status_Code,
|
||||
}
|
||||
resp.BigMain = d.BigMain
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []RadiologyMcuOrderItem) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package radiologymcuorderitem
|
||||
|
||||
import (
|
||||
emo "simrs-vx/internal/domain/main-entities/radiology-mcu-order"
|
||||
emoib "simrs-vx/internal/domain/main-entities/radiology-mcu-order-item/base"
|
||||
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type RadiologyMcuOrderItem struct {
|
||||
emoib.RadiologyMcuOrderItem
|
||||
RadiologyMcuOrder *emo.RadiologyMcuOrder `json:"radiologyMcuOrder,omitempty" gorm:"foreignKey:RadiologyMcuOrder_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d RadiologyMcuOrderItem) IsCompleted() bool {
|
||||
return d.Status_Code == erc.DSCDone
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package radiologymcuorder
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type RadiologyMcuOrder struct {
|
||||
ecore.BigMain
|
||||
Encounter_Id uint `json:"encounter_id"`
|
||||
Number uint64 `json:"number"`
|
||||
Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"`
|
||||
ClinicalNotes *string `json:"clinicalNotes"`
|
||||
OtherNotes *string `json:"otherNotes"`
|
||||
Resume *string `json:"resume"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package radiologymcuorder
|
||||
|
||||
import (
|
||||
la "simrs-vx/internal/lib/auth"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
ermoi "simrs-vx/internal/domain/main-entities/radiology-mcu-order-item/base"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Encounter_Id uint `json:"encounter_id"`
|
||||
Number *uint64 `json:"number"` // SHOULD BE AUTOMATIC WITHOUT SYNC
|
||||
Doctor_Code string `json:"-" validate:"required"`
|
||||
ClinicalNotes *string `json:"clinicalNotes"`
|
||||
OtherNotes *string `json:"otherNotes"`
|
||||
Items []ermoi.SubCreateDto `json:"items" validate:"required"`
|
||||
la.AuthInfo
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Sort string `json:"sort"`
|
||||
Pagination ecore.Pagination
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Encounter_Id uint `json:"encounter-id"`
|
||||
Doctor_Code string `json:"doctor-code"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint64 `json:"id"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
PageNumber int `json:"page_number"`
|
||||
PageSize int `json:"page_size"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.BigMain
|
||||
Encounter_Id uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter
|
||||
Number uint64 `json:"number"`
|
||||
Doctor_Code string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor
|
||||
ClinicalNotes *string `json:"clinicalNotes"`
|
||||
OtherNotes *string `json:"otherNotes"`
|
||||
Resume *string `json:"resume"`
|
||||
Items []*ermoi.RadiologyMcuOrderItem
|
||||
}
|
||||
|
||||
func (d RadiologyMcuOrder) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Encounter_Id: d.Encounter_Id,
|
||||
Encounter: d.Encounter,
|
||||
Number: d.Number,
|
||||
Doctor_Code: d.Doctor_Code,
|
||||
Doctor: d.Doctor,
|
||||
ClinicalNotes: d.ClinicalNotes,
|
||||
OtherNotes: d.OtherNotes,
|
||||
Resume: d.Resume,
|
||||
}
|
||||
resp.BigMain = d.BigMain
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []RadiologyMcuOrder) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package radiologymcuorder
|
||||
|
||||
import (
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
ermoi "simrs-vx/internal/domain/main-entities/radiology-mcu-order-item/base"
|
||||
eamob "simrs-vx/internal/domain/main-entities/radiology-mcu-order/base"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type RadiologyMcuOrder struct {
|
||||
eamob.RadiologyMcuOrder
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
Items []*ermoi.RadiologyMcuOrderItem `json:"items" gorm:"foreignKey:RadiologyMcuOrder_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d RadiologyMcuOrder) IsNotNew() bool {
|
||||
return d.Status_Code != erc.DSCNew
|
||||
}
|
||||
|
||||
func (d RadiologyMcuOrder) IsCompleted() bool {
|
||||
return d.Status_Code == erc.DSCDone
|
||||
}
|
||||
|
||||
func (d RadiologyMcuOrder) IsSameDoctor(doctor_code *string) bool {
|
||||
return d.Doctor_Code == *doctor_code
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package doctor
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ee "simrs-vx/internal/domain/main-entities/employee"
|
||||
ei "simrs-vx/internal/domain/main-entities/installation"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Employee_Id uint `json:"employee_id"`
|
||||
Installation_Code string `json:"installation_code" validate:"maxLength=20"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Pagination ecore.Pagination
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Employee_Id *uint `json:"employee-id"`
|
||||
Installation_Code *string `json:"installation-code"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id *uint `json:"id"`
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
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
|
||||
Employee_Id uint `json:"employee_id"`
|
||||
Employee *ee.Employee `json:"employee,omitempty"`
|
||||
Installation_Code string `json:"installation_code"`
|
||||
Installation *ei.Installation `json:"installation,omitempty"`
|
||||
}
|
||||
|
||||
func (d Registration) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Employee_Id: d.Employee_Id,
|
||||
Employee: d.Employee,
|
||||
Installation_Code: d.Installation_Code,
|
||||
Installation: d.Installation,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(data []Registration) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(data))
|
||||
for i, u := range data {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package doctor
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ee "simrs-vx/internal/domain/main-entities/employee"
|
||||
ei "simrs-vx/internal/domain/main-entities/installation"
|
||||
)
|
||||
|
||||
type Registration struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Employee_Id uint `json:"employee_id"`
|
||||
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
|
||||
Installation_Code string `json:"installation_code" gorm:"size:20"`
|
||||
Installation *ei.Installation `json:"installation,omitempty" gorm:"foreignKey:Installation_Code;references:Code"`
|
||||
}
|
||||
@@ -37,16 +37,19 @@ type FilterDto struct {
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id uint `json:"id"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id uint `json:"id"`
|
||||
CreateDto
|
||||
pa.AuthInfo
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id uint `json:"id"`
|
||||
pa.AuthInfo
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
|
||||
@@ -24,8 +24,9 @@ type CreateDto struct {
|
||||
Employee *EmployeUpdateDto `json:"employee"`
|
||||
IHS_Number *string `json:"ihs_number" validate:"maxLength=20"`
|
||||
SIP_Number *string `json:"sip_number" validate:"maxLength=20"`
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
Infra_Code *string `json:"infra_code"`
|
||||
Installation_Code *string `json:"installation_code"`
|
||||
Unit_Code *string `json:"unit_code"`
|
||||
Specialist_Code *string `json:"specialist_code"`
|
||||
Subspecialist_Code *string `json:"subspecialist_code"`
|
||||
ContractPosition_Code erg.ContractPositionCode `json:"contractPosition_code" gorm:"not null;size:20"`
|
||||
|
||||
@@ -9,6 +9,7 @@ type (
|
||||
InstructionCode string
|
||||
HeadToToeCode string
|
||||
McuUrgencyLevelCode string
|
||||
McuOrderStageCode string
|
||||
McuScopeCode string
|
||||
SoapiTypeCode string
|
||||
MedicalActionTypeCode string
|
||||
@@ -126,6 +127,9 @@ const (
|
||||
MULCPF McuUrgencyLevelCode = "priority-form" // Form Prioritas
|
||||
MULCRT McuUrgencyLevelCode = "routine" // Pemeriksaan Rutin
|
||||
|
||||
MOSFirst McuOrderStageCode = "first" // Stage 1
|
||||
MOSSecond McuOrderStageCode = "repeat" // Stage 2
|
||||
|
||||
STCEarlyNurse SoapiTypeCode = "early-nursery" // Kajian Awal Keperawatan
|
||||
STCEEarlyMedic SoapiTypeCode = "early-medic" // Kajian Awal Rehab Medis
|
||||
STCEarlyRehab SoapiTypeCode = "early-rehab" // Kajian Awal Rehab Medik
|
||||
@@ -403,8 +407,8 @@ type SoapiSrc struct {
|
||||
|
||||
type EarlyMedicValue struct {
|
||||
Vaccinated bool `json:"vaccinated,omitempty"`
|
||||
CaseStatus string `json:"case-status,omitempty"`
|
||||
EncounterStatus string `json:"encounter-status,omitempty"`
|
||||
CaseStatus int `json:"case-status,omitempty"`
|
||||
EncounterStatus int `json:"encounter-status,omitempty"`
|
||||
PrimaryComplain string `json:"pri-complain,omitempty"`
|
||||
CurrentDiseaseHistory string `json:"cur-disea-hist,omitempty"`
|
||||
SpO2 int `json:"spo2,omitempty"`
|
||||
|
||||
@@ -22,6 +22,7 @@ type (
|
||||
PolySwitchCode string
|
||||
DocTypeCode string
|
||||
EntityTypeCode string
|
||||
StatusProtocolChemo string
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -128,6 +129,10 @@ const (
|
||||
ETCPerson EntityTypeCode = "person"
|
||||
ETCEncounter EntityTypeCode = "encounter"
|
||||
ETCMCU EntityTypeCode = "mcu"
|
||||
|
||||
SPCComplete StatusProtocolChemo = "complete"
|
||||
SPCPlanned StatusProtocolChemo = "planned"
|
||||
SPCSchedule StatusProtocolChemo = "schedule"
|
||||
)
|
||||
|
||||
func (ec EncounterClassCode) Code() string {
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
package m_pasien
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
e "simrs-vx/internal/domain/main-entities/patient"
|
||||
pr "simrs-vx/internal/domain/main-entities/person"
|
||||
pa "simrs-vx/internal/domain/main-entities/person-address"
|
||||
pab "simrs-vx/internal/domain/main-entities/person-address/base"
|
||||
pc "simrs-vx/internal/domain/main-entities/person-contact"
|
||||
rf "simrs-vx/internal/domain/references/person"
|
||||
|
||||
"time"
|
||||
)
|
||||
|
||||
type MPasienDto struct {
|
||||
Id uint `json:"id" gorm:"primaryKey;autoIncrement;column:id"`
|
||||
Nomr string `json:"nomr" gorm:"uniqueIndex;column:nomr"`
|
||||
Title string `json:"title" gorm:"column:title"`
|
||||
Nama string `json:"nama" gorm:"column:nama"`
|
||||
Tempat string `json:"tempat" gorm:"column:tempat"`
|
||||
Tgllahir string `json:"tgllahir" gorm:"column:tgllahir"`
|
||||
Jeniskelamin string `json:"jeniskelamin" gorm:"column:jeniskelamin"`
|
||||
Alamat string `json:"alamat" gorm:"column:alamat"`
|
||||
Kelurahan uint64 `json:"kelurahan" gorm:"column:kelurahan"`
|
||||
Kdkecamatan uint `json:"kdkecamatan" gorm:"column:kdkecamatan"`
|
||||
Kota uint `json:"kota" gorm:"column:kota"`
|
||||
Kdprovinsi uint `json:"kdprovinsi" gorm:"column:kdprovinsi"`
|
||||
Notelp string `json:"notelp" gorm:"column:notelp"`
|
||||
Noktp string `json:"noktp" gorm:"column:noktp"`
|
||||
SuamiOrtu *string `json:"suami_ortu" gorm:"column:suami_ortu"`
|
||||
Pekerjaan string `json:"pekerjaan" gorm:"column:pekerjaan"`
|
||||
Status uint `json:"status" gorm:"column:status"`
|
||||
Agama uint `json:"agama" gorm:"column:agama"`
|
||||
Pendidikan uint `json:"pendidikan" gorm:"column:pendidikan"`
|
||||
Kdcarabayar *uint `json:"kdcarabayar" gorm:"column:kdcarabayar"`
|
||||
Nip *string `json:"nip" gorm:"column:nip"`
|
||||
Tgldaftar string `json:"tgldaftar" gorm:"column:tgldaftar"`
|
||||
AlamatKtp string `json:"alamat_ktp" gorm:"column:alamat_ktp"`
|
||||
ParentNomr *string `json:"parent_nomr" gorm:"column:parent_nomr"`
|
||||
Kepercayaan string `json:"kepercayaan" gorm:"column:kepercayaan"`
|
||||
PenanggungjawabNama string `json:"penanggungjawab_nama" gorm:"column:penanggungjawab_nama"`
|
||||
PenanggungjawabHubungan string `json:"penanggungjawab_hubungan" gorm:"column:penanggungjawab_hubungan"`
|
||||
PenanggungjawabAlamat string `json:"penanggungjawab_alamat" gorm:"column:penanggungjawab_alamat"`
|
||||
PenanggungjawabPhone string `json:"penanggungjawab_phone" gorm:"column:penanggungjawab_phone"`
|
||||
NoKartu string `json:"no_kartu" gorm:"column:no_kartu"`
|
||||
JnsPasien string `json:"jns_pasien" gorm:"column:jns_pasien"`
|
||||
Nk *string `json:"nk" gorm:"column:nk"`
|
||||
Kdprovider *string `json:"kdprovider" gorm:"column:kdprovider"`
|
||||
Nmprovider *string `json:"nmprovider" gorm:"column:nmprovider"`
|
||||
Kelas *uint `json:"kelas" gorm:"column:kelas"`
|
||||
Sim *string `json:"sim" gorm:"column:sim"`
|
||||
Paspor *string `json:"paspor" gorm:"column:paspor"`
|
||||
Disabilitas *string `json:"disabilitas" gorm:"column:disabilitas"`
|
||||
Bahasa string `json:"bahasa" gorm:"column:bahasa"`
|
||||
HambatanKomunikasi string `json:"hambatan_komunikasi" gorm:"column:hambatan_komunikasi"`
|
||||
Kebangsaan string `json:"kebangsaan" gorm:"column:kebangsaan"`
|
||||
Notelprumah1 string `json:"notelprumah1" gorm:"column:notelprumah1"`
|
||||
Notelprumah2 *string `json:"notelprumah2" gorm:"column:notelprumah2"`
|
||||
Notelpkantor string `json:"notelpkantor" gorm:"column:notelpkantor"`
|
||||
NoHp *string `json:"no_hp" gorm:"column:no_hp"`
|
||||
AsalMasuk *string `json:"asal_masuk" gorm:"column:asal_masuk"`
|
||||
Diagnosa *string `json:"diagnosa" gorm:"column:diagnosa"`
|
||||
DiagnosaUtama *string `json:"diagnosa_utama" gorm:"column:diagnosa_utama"`
|
||||
Suku string `json:"suku" gorm:"column:suku"`
|
||||
AgamaLain string `json:"agama_lain" gorm:"column:agama_lain"`
|
||||
StDisabilitas uint `json:"stDisabilitas" gorm:"column:st_disabilitas"`
|
||||
TxtKelurahan string `json:"txt_kelurahan" gorm:"column:txt_kelurahan"`
|
||||
TxtKecamatan string `json:"txt_kecamatan" gorm:"column:txt_kecamatan"`
|
||||
TxtKota string `json:"txt_kota" gorm:"column:txt_kota"`
|
||||
TxtProvinsi string `json:"txt_provinsi" gorm:"column:txt_provinsi"`
|
||||
TxtStatus string `json:"txt_status" gorm:"column:txt_status"`
|
||||
TxtAgama string `json:"txt_agama" gorm:"column:txt_agama"`
|
||||
TxtPendidikan string `json:"txt_pendidikan" gorm:"column:txt_pendidikan"`
|
||||
NamaAyah string `json:"nama_ayah" gorm:"column:nama_ayah"`
|
||||
NamaIbu string `json:"nama_ibu" gorm:"column:nama_ibu"`
|
||||
PendidikanAyah string `json:"pendidikan_ayah" gorm:"column:pendidikan_ayah"`
|
||||
PendidikanIbu string `json:"pendidikan_ibu" gorm:"column:pendidikan_ibu"`
|
||||
StIdentitasOrtu int `json:"st_identitas_ortu" gorm:"column:st_identitas_ortu"`
|
||||
NomrBaru *string `json:"nomr_baru" gorm:"column:nomr_baru"`
|
||||
KtpFile *string `json:"ktp_file" gorm:"column:ktp_file"`
|
||||
KkFile *string `json:"kk_file" gorm:"column:kk_file"`
|
||||
CreatedAt *time.Time `json:"created_at" gorm:"column:created_at"`
|
||||
UpdatedAt *time.Time `json:"updated_at" gorm:"column:updated_at"`
|
||||
NoKk *string `json:"no_kk" gorm:"column:no_kk"`
|
||||
NoktpBaru string `json:"noktp_baru" gorm:"column:noktp_baru"`
|
||||
}
|
||||
|
||||
func (mp MPasienDto) ToPatient() e.Patient {
|
||||
|
||||
patient := e.Patient{
|
||||
Main: ecore.Main{
|
||||
Id: mp.Id,
|
||||
},
|
||||
NewBornStatus: mp.ParentNomr != nil,
|
||||
RegisteredAt: parseTimeDateOnly(mp.Tgldaftar),
|
||||
RegisteredBy_User_Name: mp.Nip,
|
||||
Number: &mp.Nomr,
|
||||
Parent_Number: mp.ParentNomr,
|
||||
// Status_Code: getActiveStatus(mp.Status),
|
||||
// mp.Status is marital status
|
||||
// Parent
|
||||
}
|
||||
|
||||
// person
|
||||
gc := getGender(mp.Jeniskelamin)
|
||||
rc := getReligion(mp.Agama)
|
||||
ec := getEducation(mp.Pendidikan)
|
||||
mc := getMaritalStatus(mp.Status)
|
||||
bc := getBirthRegencyCode(mp.Tempat)
|
||||
et := getEthnicCode(mp.Suku)
|
||||
lc := getLanguageCode(mp.Bahasa)
|
||||
|
||||
person := pr.Person{
|
||||
Name: mp.Nama,
|
||||
FrontTitle: &mp.Title,
|
||||
BirthDate: parseTimeDateOnly(mp.Tgllahir),
|
||||
BirthRegency_Code: &bc,
|
||||
Gender_Code: &gc,
|
||||
ResidentIdentityNumber: nilEmptyString(&mp.Noktp),
|
||||
PassportNumber: nilEmptyString(mp.Paspor),
|
||||
DrivingLicenseNumber: nilEmptyString(mp.Sim),
|
||||
Religion_Code: &rc,
|
||||
Education_Code: &ec,
|
||||
Ocupation_Name: &mp.Pekerjaan,
|
||||
MaritalStatus_Code: &mc,
|
||||
Nationality: &mp.Kebangsaan,
|
||||
Ethnic_Code: &et,
|
||||
Language_Code: &lc,
|
||||
CommunicationIssueStatus: mp.HambatanKomunikasi == "Y",
|
||||
Disability: mp.Disabilitas,
|
||||
ResidentIdentityFileUrl: mp.KtpFile,
|
||||
FamilyIdentityFileUrl: mp.KkFile,
|
||||
// EndTitle
|
||||
// Confidence
|
||||
// Ocupation_Code
|
||||
}
|
||||
var addresses []pa.PersonAddress
|
||||
if mp.Alamat != "" {
|
||||
vc := fmt.Sprintf("%d", mp.Kelurahan)
|
||||
addresses = append(addresses, pa.PersonAddress{
|
||||
PersonAddress: pab.PersonAddress{
|
||||
Address: mp.Alamat,
|
||||
LocationType_Code: rf.ALTCDom,
|
||||
Village_Code: &vc,
|
||||
},
|
||||
})
|
||||
}
|
||||
if mp.AlamatKtp != "" {
|
||||
addresses = append(addresses, pa.PersonAddress{
|
||||
PersonAddress: pab.PersonAddress{
|
||||
Address: mp.AlamatKtp,
|
||||
LocationType_Code: rf.ALTCIdn,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
var contacts []pc.PersonContact
|
||||
|
||||
if mp.NoHp != nil {
|
||||
|
||||
}
|
||||
|
||||
person.Addresses = &addresses
|
||||
person.Contacts = &contacts
|
||||
patient.Person = &person
|
||||
return patient
|
||||
}
|
||||
|
||||
func nilEmptyString(s *string) *string {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func getGender(g string) rf.GenderCode {
|
||||
if g == "L" {
|
||||
return rf.GCMale
|
||||
} else if g == "P" {
|
||||
return rf.GCFemale
|
||||
}
|
||||
return rf.GCUnknown
|
||||
|
||||
}
|
||||
|
||||
func getReligion(r uint) rf.ReligionCode {
|
||||
switch r {
|
||||
case 1:
|
||||
return rf.RCIslam
|
||||
case 2:
|
||||
return rf.RCProtestan
|
||||
case 3:
|
||||
return rf.RCKatolik
|
||||
case 4:
|
||||
return rf.RCHindu
|
||||
case 5:
|
||||
return rf.RCBudha
|
||||
case 6:
|
||||
return rf.RCKonghucu
|
||||
default:
|
||||
// 9 "Lainnya"
|
||||
// 0 "Tidak diketahui"
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func getEducation(e uint) rf.EducationCode {
|
||||
switch e {
|
||||
case 0:
|
||||
return rf.ECTS
|
||||
case 1:
|
||||
return rf.ECSD
|
||||
case 2:
|
||||
return rf.ECSLTP
|
||||
case 3:
|
||||
return rf.ECSLTA
|
||||
case 4:
|
||||
return rf.ECD3
|
||||
case 5:
|
||||
return rf.ECS1
|
||||
case 6:
|
||||
return rf.ECOther
|
||||
case 7:
|
||||
return rf.ECUnkown
|
||||
default:
|
||||
return rf.ECUnkown
|
||||
}
|
||||
}
|
||||
|
||||
func getMaritalStatus(m uint) rf.MaritalStatusCode {
|
||||
switch m {
|
||||
case 1:
|
||||
return rf.MaritalStatusSingle // S
|
||||
case 2:
|
||||
return rf.MaritalStatusMarried // M
|
||||
case 3:
|
||||
return rf.MaritalStatusWidowed // W
|
||||
case 4:
|
||||
return rf.MaritalStatusDivorced // D
|
||||
default:
|
||||
return "" // unknown
|
||||
}
|
||||
}
|
||||
|
||||
func getBirthRegencyCode(r string) string {
|
||||
if r != "" {
|
||||
// TODO get from database
|
||||
}
|
||||
return "3574"
|
||||
}
|
||||
|
||||
func getEthnicCode(s string) string {
|
||||
if s != "" {
|
||||
// TODO check database
|
||||
}
|
||||
return "jawa"
|
||||
}
|
||||
|
||||
func getLanguageCode(s string) string {
|
||||
if s != "" {
|
||||
// TODO check database
|
||||
}
|
||||
return "jawa"
|
||||
}
|
||||
|
||||
func parseTimeDateOnly(d string) *time.Time {
|
||||
do, err := time.Parse("2006-01-02", d)
|
||||
if err == nil {
|
||||
return &do
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -11,29 +11,29 @@ type TDiagnosaDanTerapi struct {
|
||||
GolonganDarah string `json:"golongan_darah" gorm:"column:golongan_darah"`
|
||||
TinggiBadan float64 `json:"tinggi_badan" gorm:"column:tinggi_badan"`
|
||||
BeratBadan float64 `json:"berat_badan" gorm:"column:berat_badan"`
|
||||
Diagnosa string `json:"diagnosa" gorm:"column:diagnosa"`
|
||||
Komplikasi string `json:"komplikasi" gorm:"column:komplikasi"`
|
||||
Terapi string `json:"terapi" gorm:"column:terapi"`
|
||||
Anamnesa string `json:"anamnesa" gorm:"column:anamnesa"`
|
||||
Diagnosa *string `json:"diagnosa" gorm:"column:diagnosa"`
|
||||
Komplikasi *string `json:"komplikasi" gorm:"column:komplikasi"`
|
||||
Terapi *string `json:"terapi" gorm:"column:terapi"`
|
||||
Anamnesa *string `json:"anamnesa" gorm:"column:anamnesa"`
|
||||
Kdpoly uint `json:"kdpoly" gorm:"column:kdpoly"`
|
||||
Kddokter uint `json:"kddokter" gorm:"column:kddokter"`
|
||||
Kdtujuanrujuk uint `json:"kdtujuanrujuk" gorm:"column:kdtujuanrujuk"`
|
||||
Kdtujuanrujuk *uint `json:"kdtujuanrujuk" gorm:"column:kdtujuanrujuk"`
|
||||
Nip string `json:"nip" gorm:"column:nip"`
|
||||
IcdCode string `json:"icd_code" gorm:"column:icd_code"`
|
||||
IcdCode *string `json:"icd_code" gorm:"column:icd_code"`
|
||||
KunjunganBl uint `json:"kunjungan_bl" gorm:"column:kunjungan_bl"`
|
||||
KasusBl uint `json:"kasus_bl" gorm:"column:kasus_bl"`
|
||||
Icdcm string `json:"icdcm" gorm:"column:icdcm"`
|
||||
Icd9 string `json:"icd_9" gorm:"column:icd_9"`
|
||||
Klb uint `json:"klb" gorm:"column:klb"`
|
||||
Bedah uint `json:"bedah" gorm:"column:bedah"`
|
||||
Jenis uint `json:"jenis" gorm:"column:jenis"`
|
||||
Perawat string `json:"perawat" gorm:"column:perawat"`
|
||||
Status string `json:"status" gorm:"column:status"`
|
||||
PemeriksaanFisik string `json:"pemeriksaan_fisik" gorm:"column:pemeriksaan_fisik"`
|
||||
RiwayatPasien string `json:"riwayat_pasien" gorm:"column:riwayat_pasien"`
|
||||
TindakanMedis string `json:"tindakan_medis" gorm:"column:tindakan_medis"`
|
||||
Icdcm *string `json:"icdcm" gorm:"column:icdcm"`
|
||||
Icd9 *string `json:"icd_9" gorm:"column:icd_9"`
|
||||
Klb *uint `json:"klb" gorm:"column:klb"`
|
||||
Bedah *uint `json:"bedah" gorm:"column:bedah"`
|
||||
Jenis *uint `json:"jenis" gorm:"column:jenis"`
|
||||
Perawat *string `json:"perawat" gorm:"column:perawat"`
|
||||
Status *string `json:"status" gorm:"column:status"`
|
||||
PemeriksaanFisik *string `json:"pemeriksaan_fisik" gorm:"column:pemeriksaan_fisik"`
|
||||
RiwayatPasien *string `json:"riwayat_pasien" gorm:"column:riwayat_pasien"`
|
||||
TindakanMedis *string `json:"tindakan_medis" gorm:"column:tindakan_medis"`
|
||||
Rajal uint `json:"rajal" gorm:"column:rajal"`
|
||||
UserBatal string `json:"user_batal" gorm:"column:user_batal"`
|
||||
UserBatal *string `json:"user_batal" gorm:"column:user_batal"`
|
||||
TglBatal *time.Time `json:"tgl_batal" gorm:"column:tgl_batal"`
|
||||
SudahVaksin string `json:"sudah_vaksin" gorm:"column:sudah_vaksin"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
|
||||
@@ -41,7 +41,7 @@ type TDiagnosaDanTerapi struct {
|
||||
Pernapasan string `json:"pernapasan" gorm:"column:pernapasan"`
|
||||
Suhu string `json:"suhu" gorm:"column:suhu"`
|
||||
Sp02 string `json:"sp02" gorm:"column:sp02"`
|
||||
TujuanPerawatan string `json:"tujuan_perawatan" gorm:"column:tujuan_perawatan"`
|
||||
TujuanPerawatan *string `json:"tujuan_perawatan" gorm:"column:tujuan_perawatan"`
|
||||
TargetCapaian string `json:"target_capaian" gorm:"column:target_capaian"`
|
||||
}
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@ type TIcdCm struct {
|
||||
Nomr string `json:"nomr" gorm:"column:nomr"`
|
||||
Idxdaftar uint `json:"idxdaftar" gorm:"column:idxdaftar"`
|
||||
Kddokter uint `json:"kddokter" gorm:"column:kddokter"`
|
||||
Icd string `json:"icd" gorm:"column:icd"`
|
||||
IcdVerified string `json:"icd_verified" gorm:"column:icd_verified"`
|
||||
Icd *string `json:"icd" gorm:"column:icd"`
|
||||
IcdVerified *string `json:"icd_verified" gorm:"column:icd_verified"`
|
||||
StatusRajal uint16 `json:"status_rajal" gorm:"column:status_rajal"`
|
||||
Tanggal time.Time `json:"tanggal" gorm:"column:tanggal"`
|
||||
StatusVerif uint16 `json:"status_verif" gorm:"column:status_verif"`
|
||||
IcdVerifiedOrder uint16 `json:"icd_verified_order" gorm:"column:icd_verified_order"`
|
||||
IcdVerifBy string `json:"icd_verif_by" gorm:"column:icd_verif_by"`
|
||||
StatusVerif *uint16 `json:"status_verif" gorm:"column:status_verif"`
|
||||
IcdVerifiedOrder *uint16 `json:"icd_verified_order" gorm:"column:icd_verified_order"`
|
||||
IcdVerifBy *string `json:"icd_verif_by" gorm:"column:icd_verif_by"`
|
||||
IcdVerifDate *time.Time `json:"icd_verif_date" gorm:"column:icd_verif_date"`
|
||||
IcdActive uint16 `json:"icd_active" gorm:"column:icd_active"`
|
||||
IcdActive *uint16 `json:"icd_active" gorm:"column:icd_active"`
|
||||
}
|
||||
|
||||
func (TIcdCm) TableName() string {
|
||||
|
||||
@@ -8,15 +8,15 @@ type TIcd struct {
|
||||
Idxdaftar uint `json:"idxdaftar" gorm:"column:idxdaftar"`
|
||||
Kddokter uint `json:"kddokter" gorm:"column:kddokter"`
|
||||
Icd string `json:"icd" gorm:"column:icd"`
|
||||
IcdVerified string `json:"icd_verified" gorm:"column:icd_verified"`
|
||||
IcdVerified *string `json:"icd_verified" gorm:"column:icd_verified"`
|
||||
StatusRajal uint16 `json:"status_rajal" gorm:"column:status_rajal"`
|
||||
Tanggal time.Time `json:"tanggal" gorm:"column:tanggal"`
|
||||
StatusVerif uint16 `json:"status_verif" gorm:"column:status_verif"`
|
||||
IcdVerifiedOrder uint16 `json:"icd_verified_order" gorm:"column:icd_verified_order"`
|
||||
IcdVerifBy string `json:"icd_verif_by" gorm:"column:icd_verif_by"`
|
||||
StatusVerif *uint16 `json:"status_verif" gorm:"column:status_verif"`
|
||||
IcdVerifiedOrder *uint16 `json:"icd_verified_order" gorm:"column:icd_verified_order"`
|
||||
IcdVerifBy *string `json:"icd_verif_by" gorm:"column:icd_verif_by"`
|
||||
IcdVerifDate *time.Time `json:"icd_verif_date" gorm:"column:icd_verif_date"`
|
||||
IcdActive uint16 `json:"icd_active" gorm:"column:icd_active"`
|
||||
StSebabMati uint16 `json:"st_sebab_mati" gorm:"column:st_sebab_mati"`
|
||||
IcdActive *uint16 `json:"icd_active" gorm:"column:icd_active"`
|
||||
StSebabMati *uint16 `json:"st_sebab_mati" gorm:"column:st_sebab_mati"`
|
||||
}
|
||||
|
||||
func (TIcd) TableName() string {
|
||||
|
||||
@@ -5,16 +5,16 @@ import "time"
|
||||
type TRekammedik struct {
|
||||
TglKirim *time.Time `json:"tgl_kirim" gorm:"column:tgl_kirim"`
|
||||
TglTerima *time.Time `json:"tgl_terima" gorm:"column:tgl_terima"`
|
||||
Idxdaftar int `json:"idxdaftar" gorm:"column:idxdaftar"`
|
||||
Kdpoly int `json:"kdpoly" gorm:"column:kdpoly"`
|
||||
Idxdaftar uint `json:"idxdaftar" gorm:"column:idxdaftar"`
|
||||
Kdpoly uint `json:"kdpoly" gorm:"column:kdpoly"`
|
||||
Pengirim string `json:"pengirim" gorm:"column:pengirim"`
|
||||
Penerima string `json:"penerima" gorm:"column:penerima"`
|
||||
Statusrm int `json:"statusrm" gorm:"column:statusrm"`
|
||||
PenerimaPoly string `json:"penerima_poly" gorm:"column:penerima_poly"`
|
||||
JamKirimRm string `json:"jam_kirim_rm" gorm:"column:jam_kirim_rm"`
|
||||
JamTerimaRm string `json:"jam_terima_rm" gorm:"column:jam_terima_rm"`
|
||||
PjBerkasRm string `json:"pj_berkas_rm" gorm:"column:pj_berkas_rm"`
|
||||
StatusFisikBerkas string `json:"status_fisik_berkas" gorm:"column:status_fisik_berkas"`
|
||||
Penerima *string `json:"penerima" gorm:"column:penerima"`
|
||||
Statusrm *uint `json:"statusrm" gorm:"column:statusrm"`
|
||||
PenerimaPoly *string `json:"penerima_poly" gorm:"column:penerima_poly"`
|
||||
JamKirimRm *time.Time `json:"jam_kirim_rm" gorm:"column:jam_kirim_rm"`
|
||||
JamTerimaRm *time.Time `json:"jam_terima_rm" gorm:"column:jam_terima_rm"`
|
||||
PjBerkasRm *string `json:"pj_berkas_rm" gorm:"column:pj_berkas_rm"`
|
||||
StatusFisikBerkas *string `json:"status_fisik_berkas" gorm:"column:status_fisik_berkas"`
|
||||
}
|
||||
|
||||
func (TRekammedik) TableName() string {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package authentication
|
||||
|
||||
type SyncKey struct{}
|
||||
|
||||
type CredentialDto struct {
|
||||
Source string `json:"X-Sync-Source"`
|
||||
SecretKey string `json:"X-Sync-SecretKey"`
|
||||
UserName string `json:"X-Sync-UserName"`
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
func SetConfig() {
|
||||
a.ParseSingleCfg(&O)
|
||||
|
||||
if O.Host == "" || O.Prefix == "" {
|
||||
panic("config sync host and prefix empty")
|
||||
if O.NewSecretKey == "" || O.NewHost == "" || O.OldSecretKey == "" || O.OldHost == "" {
|
||||
panic("secret key and host of the sync partner config can not be empty")
|
||||
}
|
||||
lo.I.Println("sync url config loaded, status: DONE!!")
|
||||
lo.I.Println("sync partner config loaded, status: DONE!!")
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package synccfg
|
||||
|
||||
var O SyncUrlCfg = SyncUrlCfg{}
|
||||
var O SyncPartnerCfg = SyncPartnerCfg{} // old
|
||||
|
||||
type SyncUrlCfg struct {
|
||||
Prefix string `yaml:"prefix"`
|
||||
Host string `yaml:"host"`
|
||||
Enable bool `yaml:"enable"`
|
||||
// Used by sync itself, so any partner should be stated here
|
||||
type SyncPartnerCfg struct {
|
||||
OldSource string `yaml:"oldSource"`
|
||||
OldSecretKey string `yaml:"oldSecretKey"`
|
||||
OldHost string `yaml:"oldHost"`
|
||||
NewSource string `yaml:"newSource"`
|
||||
NewSecretKey string `yaml:"newSecretKey"`
|
||||
NewHost string `yaml:"newHost"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package synccfg
|
||||
|
||||
import (
|
||||
a "github.com/karincake/apem"
|
||||
lo "github.com/karincake/apem/loggero"
|
||||
)
|
||||
|
||||
func SetConfig() {
|
||||
a.ParseSingleCfg(&O)
|
||||
|
||||
if O.TargetHost == "" || O.Prefix == "" {
|
||||
panic("config sync host and prefix empty")
|
||||
}
|
||||
lo.I.Println("sync url config loaded, status: DONE!!")
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package synccfg
|
||||
|
||||
var O SyncConsumerUrlCfg = SyncConsumerUrlCfg{} // old
|
||||
var O SyncConsumerUrlCfg = SyncConsumerUrlCfg{} // new
|
||||
|
||||
type SyncConsumerUrlCfg struct {
|
||||
Prefix string `yaml:"prefix"`
|
||||
|
||||
@@ -9,9 +9,12 @@ import (
|
||||
sp "github.com/karincake/semprit"
|
||||
sr "github.com/karincake/serabi"
|
||||
|
||||
is "simrs-vx/internal/infra/sync-consumer-cfg"
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
|
||||
m "simrs-vx/internal/domain/main-entities/user"
|
||||
mf "simrs-vx/internal/domain/main-entities/user-fes"
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
esga "simrs-vx/internal/domain/sync-entities/authentication"
|
||||
s "simrs-vx/internal/use-case/main-use-case/authentication"
|
||||
)
|
||||
|
||||
@@ -66,12 +69,37 @@ func Logout(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func GuardMW(next http.Handler) http.Handler {
|
||||
var (
|
||||
accessDetail *pa.AuthInfo
|
||||
err error
|
||||
)
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
accessDetail, err := s.ExtractToken(r, s.AccessToken)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, err.(d.FieldError), nil)
|
||||
return
|
||||
// Check if it's from sync
|
||||
credential := esga.CredentialDto{}
|
||||
credential.Source = r.Header.Get("X-Sync-Source")
|
||||
credential.SecretKey = r.Header.Get("X-Sync-SecretKey")
|
||||
credential.UserName = r.Header.Get("X-Sync-UserName")
|
||||
if credential.Source != "" || credential.SecretKey != "" || credential.UserName != "" {
|
||||
// validate secretKey and source
|
||||
if credential.SecretKey != is.O.SecretKey || credential.Source != is.O.Source {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "invalid consumer credential"}, nil)
|
||||
return
|
||||
}
|
||||
|
||||
accessDetail, err = s.GetAuthInfoByUserName(credential.UserName)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, err.(d.FieldError), nil)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// Normal flow goes here
|
||||
accessDetail, err = s.ExtractToken(r, s.AccessToken)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, err.(d.FieldError), nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
ctx := context.WithValue(r.Context(), pa.AuthKey{}, accessDetail)
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
})
|
||||
|
||||
@@ -69,7 +69,7 @@ import (
|
||||
gs "simrs-vx/internal/infra/gorm-setting"
|
||||
minio "simrs-vx/internal/infra/minio"
|
||||
ssdb "simrs-vx/internal/infra/ss-db"
|
||||
simgossync "simrs-vx/internal/infra/sync-cfg"
|
||||
sync "simrs-vx/internal/infra/sync-consumer-cfg"
|
||||
|
||||
/******************** pkg ********************/
|
||||
cmw "simrs-vx/pkg/cors-manager-mw"
|
||||
@@ -153,7 +153,7 @@ func SetRoutes() http.Handler {
|
||||
a.RegisterExtCall(mh.I.SetClient)
|
||||
a.RegisterExtCall(ibpjs.SetConfig)
|
||||
a.RegisterExtCall(validation.RegisterValidation)
|
||||
a.RegisterExtCall(simgossync.SetConfig)
|
||||
a.RegisterExtCall(sync.SetConfig)
|
||||
a.RegisterExtCall(docscfg.ParseCfg)
|
||||
a.RegisterExtCall(ibpjs.SetConfig)
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
dto.Id = uint(id)
|
||||
dto.AuthInfo = *authInfo
|
||||
res, err := u.Update(dto)
|
||||
@@ -81,7 +82,15 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
|
||||
dto.Id = uint(id)
|
||||
dto.AuthInfo = *authInfo
|
||||
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
dto.Id = uint16(id)
|
||||
dto.Id = uint(id)
|
||||
res, err := u.ReadDetail(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Id = uint16(id)
|
||||
dto.Id = uint(id)
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Id = uint16(id)
|
||||
dto.Id = uint(id)
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -7,13 +7,17 @@ import (
|
||||
ambulatory "simrs-vx/internal/domain/main-entities/ambulatory"
|
||||
antibioticinuse "simrs-vx/internal/domain/main-entities/antibiotic-in-use"
|
||||
antibioticsrccategory "simrs-vx/internal/domain/main-entities/antibiotic-src-category"
|
||||
apmcuorder "simrs-vx/internal/domain/main-entities/ap-mcu-order"
|
||||
appointment "simrs-vx/internal/domain/main-entities/appointment"
|
||||
authpartner "simrs-vx/internal/domain/main-entities/auth-partner"
|
||||
chemo "simrs-vx/internal/domain/main-entities/chemo"
|
||||
chemoplan "simrs-vx/internal/domain/main-entities/chemo-plan"
|
||||
chemoprotocol "simrs-vx/internal/domain/main-entities/chemo-protocol"
|
||||
consultation "simrs-vx/internal/domain/main-entities/consultation"
|
||||
controlletter "simrs-vx/internal/domain/main-entities/control-letter"
|
||||
counter "simrs-vx/internal/domain/main-entities/counter"
|
||||
cpmcuorder "simrs-vx/internal/domain/main-entities/cp-mcu-order"
|
||||
cpmcuorderitem "simrs-vx/internal/domain/main-entities/cp-mcu-order-item"
|
||||
deathcause "simrs-vx/internal/domain/main-entities/death-cause"
|
||||
device "simrs-vx/internal/domain/main-entities/device"
|
||||
deviceorder "simrs-vx/internal/domain/main-entities/device-order"
|
||||
@@ -66,6 +70,8 @@ import (
|
||||
medicinemethod "simrs-vx/internal/domain/main-entities/medicine-method"
|
||||
medicinemix "simrs-vx/internal/domain/main-entities/medicine-mix"
|
||||
medicinemixitem "simrs-vx/internal/domain/main-entities/medicine-mix-item"
|
||||
micromcuorder "simrs-vx/internal/domain/main-entities/micro-mcu-order"
|
||||
micromcuorderitem "simrs-vx/internal/domain/main-entities/micro-mcu-order-item"
|
||||
midwife "simrs-vx/internal/domain/main-entities/midwife"
|
||||
nurse "simrs-vx/internal/domain/main-entities/nurse"
|
||||
nutritionist "simrs-vx/internal/domain/main-entities/nutritionist"
|
||||
@@ -87,7 +93,10 @@ import (
|
||||
procedureroomorderitem "simrs-vx/internal/domain/main-entities/procedure-room-order-item"
|
||||
proceduresrc "simrs-vx/internal/domain/main-entities/procedure-src"
|
||||
province "simrs-vx/internal/domain/main-entities/province"
|
||||
radiologymcuorder "simrs-vx/internal/domain/main-entities/radiology-mcu-order"
|
||||
radiologymcuorderitem "simrs-vx/internal/domain/main-entities/radiology-mcu-order-item"
|
||||
regency "simrs-vx/internal/domain/main-entities/regency"
|
||||
registration "simrs-vx/internal/domain/main-entities/registration"
|
||||
rehab "simrs-vx/internal/domain/main-entities/rehab"
|
||||
responsibledoctorhist "simrs-vx/internal/domain/main-entities/responsible-doctor-hist"
|
||||
resume "simrs-vx/internal/domain/main-entities/resume"
|
||||
@@ -140,6 +149,7 @@ func getMainEntities() []any {
|
||||
&proceduresrc.ProcedureSrc{},
|
||||
&employee.Employee{},
|
||||
&intern.Intern{},
|
||||
®istration.Registration{},
|
||||
&doctor.Doctor{},
|
||||
&nurse.Nurse{},
|
||||
&nutritionist.Nutritionist{},
|
||||
@@ -200,6 +210,13 @@ func getMainEntities() []any {
|
||||
&mcuorderitem.McuOrderItem{},
|
||||
&mcusubsrc.McuSubSrc{},
|
||||
&mcuordersubitem.McuOrderSubItem{},
|
||||
&apmcuorder.ApMcuOrder{},
|
||||
&radiologymcuorder.RadiologyMcuOrder{},
|
||||
&radiologymcuorderitem.RadiologyMcuOrderItem{},
|
||||
&cpmcuorder.CpMcuOrder{},
|
||||
&cpmcuorderitem.CpMcuOrderItem{},
|
||||
µmcuorder.MicroMcuOrder{},
|
||||
µmcuorderitem.MicroMcuOrderItem{},
|
||||
&antibioticsrccategory.AntibioticSrcCategory{},
|
||||
&antibioticinuse.AntibioticInUse{},
|
||||
&consultation.Consultation{},
|
||||
@@ -235,5 +252,6 @@ func getMainEntities() []any {
|
||||
&vclaimreference.VclaimReference{},
|
||||
&screening.Screening{},
|
||||
&procedurereport.ProcedureReport{},
|
||||
&chemoplan.ChemoPlan{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package soapi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/soapi"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/new/soapi"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.Soapi{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CreateLog(w http.ResponseWriter, r *http.Request) {
|
||||
dto := esync.SimxLogDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.CreateSimxLog(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.Soapi{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package authentication
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
rw "github.com/karincake/risoles"
|
||||
|
||||
sc "simrs-vx/internal/lib/sync-credential"
|
||||
|
||||
e "simrs-vx/internal/domain/sync-entities/authentication"
|
||||
is "simrs-vx/internal/infra/sync-cfg"
|
||||
)
|
||||
|
||||
func NewGuardMW(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// check the data format
|
||||
input := e.CredentialDto{}
|
||||
if success := sc.CheckCredentialData(&input, r, w); !success {
|
||||
return
|
||||
}
|
||||
|
||||
// check the validity
|
||||
if input.Source != is.O.NewSource || input.SecretKey != is.O.NewSecretKey {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "invalid consumer credential"}, nil)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.WithValue(r.Context(), e.SyncKey{}, input)
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
})
|
||||
}
|
||||
|
||||
func OldGuardMW(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// check the data format
|
||||
input := e.CredentialDto{}
|
||||
if success := sc.CheckCredentialData(&input, r, w); !success {
|
||||
return
|
||||
}
|
||||
|
||||
// check the validity
|
||||
if input.Source != is.O.OldSource || input.SecretKey != is.O.OldSecretKey {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "invalid consumer credential"}, nil)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.WithValue(r.Context(), e.SyncKey{}, input)
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package patient
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
p "simrs-vx/internal/domain/simgos-entities/m-pasien"
|
||||
uo "simrs-vx/internal/use-case/simgos-sync-use-case/old/patient"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := p.MPasienDto{}
|
||||
if !rw.ValidateStructByIOR(w, r.Body, &dto) {
|
||||
return
|
||||
}
|
||||
|
||||
// mapping m_patient to patient
|
||||
patient := dto.ToPatient()
|
||||
res, err := uo.Create(patient)
|
||||
rw.DataResponse(w, res, err)
|
||||
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
dto := p.MPasienDto{}
|
||||
if !rw.ValidateStructByIOR(w, r.Body, &dto) {
|
||||
return
|
||||
}
|
||||
patient := dto.ToPatient()
|
||||
res, err := uo.Update(patient)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
dto := p.MPasienDto{}
|
||||
if !rw.ValidateStructByIOR(w, r.Body, &dto) {
|
||||
return
|
||||
}
|
||||
patient := dto.ToPatient()
|
||||
res, err := uo.Delete(patient)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
/******************** infra ********************/
|
||||
gs "simrs-vx/internal/infra/gorm-setting"
|
||||
simgosdb "simrs-vx/internal/infra/simgos-db"
|
||||
sync "simrs-vx/internal/infra/sync-cfg"
|
||||
|
||||
/******************** pkg ********************/
|
||||
cmw "simrs-vx/pkg/cors-manager-mw"
|
||||
@@ -24,9 +25,14 @@ import (
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/encounter"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/installation"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/patient"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/soapi"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/specialist"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/subspecialist"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/unit"
|
||||
|
||||
oldpatient "simrs-vx/internal/interface/simgos-sync-handler/old/patient"
|
||||
|
||||
oauth "simrs-vx/internal/interface/simgos-sync-handler/old/authentication" // just a reminder, an openauth
|
||||
)
|
||||
|
||||
func SetRoutes() http.Handler {
|
||||
@@ -34,6 +40,7 @@ func SetRoutes() http.Handler {
|
||||
a.RegisterExtCall(gs.Adjust)
|
||||
a.RegisterExtCall(zlc.Adjust)
|
||||
a.RegisterExtCall(lh.Populate)
|
||||
a.RegisterExtCall(sync.SetConfig)
|
||||
a.RegisterExtCall(simgosdb.SetInstance)
|
||||
|
||||
r := http.NewServeMux()
|
||||
@@ -67,9 +74,14 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/approve-switch-unit": encounter.O.ApproveSwitchUnit,
|
||||
"PATCH /{id}/cancel-switch-unit": encounter.O.CancelSwitchUnit,
|
||||
})
|
||||
hc.SyncCrud(r, prefixnew+"/v1/soapi", soapi.O)
|
||||
|
||||
/******************** SvcToNew ******************/
|
||||
//prefixold := "/old-to-new"
|
||||
|
||||
prefixold := "/old-to-new"
|
||||
hk.GroupRoutes(prefixold+"/v1/patient", r, oauth.OldGuardMW, hk.MapHandlerFunc{
|
||||
"POST /": oldpatient.O.Create,
|
||||
"PATCH /{id}": oldpatient.O.Update,
|
||||
"DELETE /{id}": oldpatient.O.Delete,
|
||||
}) // FINISH THIS
|
||||
return cmw.SetCors(handlerlogger.SetLog(r))
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ type AuthInfo struct {
|
||||
Pharmachist_Code *string
|
||||
Intern_Position_Code *string
|
||||
Roles []string
|
||||
Sync bool
|
||||
// User_DivisionPositions []DivisionPosition
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package authentication
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
rw "github.com/karincake/risoles"
|
||||
sr "github.com/karincake/serabi"
|
||||
|
||||
e "simrs-vx/internal/domain/sync-entities/authentication"
|
||||
)
|
||||
|
||||
func CheckCredentialData(input *e.CredentialDto, r *http.Request, w http.ResponseWriter) bool {
|
||||
input.Source = r.Header.Get("X-Sync-Source")
|
||||
input.SecretKey = r.Header.Get("X-Sync-SecretKey")
|
||||
input.UserName = r.Header.Get("X-Sync-UserName")
|
||||
if err := sr.Validate(input); err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.II{"errors": err}, nil)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
package apmcuorder
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/ap-mcu-order"
|
||||
"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 = "device"
|
||||
|
||||
func Create(input e.CreateDto) (*d.Data, error) {
|
||||
data := e.ApMcuOrder{}
|
||||
|
||||
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.ApMcuOrder
|
||||
var dataList []e.ApMcuOrder
|
||||
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),
|
||||
"record_currentCount": strconv.Itoa(len(dataList)),
|
||||
},
|
||||
Data: e.ToResponseList(dataList),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
|
||||
var data *e.ApMcuOrder
|
||||
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: input.Id}
|
||||
var data *e.ApMcuOrder
|
||||
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: input.Id}
|
||||
var data *e.ApMcuOrder
|
||||
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
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Any functions that are used internally by the use-case
|
||||
*/
|
||||
package apmcuorder
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/ap-mcu-order"
|
||||
)
|
||||
|
||||
func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ApMcuOrder) {
|
||||
var inputSrc *e.CreateDto
|
||||
if inputT, ok := any(input).(*e.CreateDto); ok {
|
||||
inputSrc = inputT
|
||||
} else {
|
||||
inputTemp := any(input).(*e.UpdateDto)
|
||||
inputSrc = &inputTemp.CreateDto
|
||||
}
|
||||
|
||||
data.Substances = inputSrc.Substances
|
||||
data.Fictations = inputSrc.Fictations
|
||||
data.Localization = inputSrc.Localization
|
||||
data.ClinicalDiagnoses = inputSrc.ClinicalDiagnoses
|
||||
data.Stadium = inputSrc.Stadium
|
||||
data.PastHistory = inputSrc.PastHistory
|
||||
data.CurrentHistory = inputSrc.CurrentHistory
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package apmcuorder
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/ap-mcu-order"
|
||||
|
||||
plh "simrs-vx/pkg/lib-helper"
|
||||
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.ApMcuOrder, error) {
|
||||
pl.SetLogInfo(event, nil, "started", "DBCreate")
|
||||
|
||||
data := e.ApMcuOrder{}
|
||||
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 {
|
||||
return nil, plh.HandleCreateError(input, event, err)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(event, nil, "complete")
|
||||
return &data, nil
|
||||
}
|
||||
|
||||
func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.ApMcuOrder, *e.MetaDto, error) {
|
||||
pl.SetLogInfo(event, input, "started", "DBReadList")
|
||||
data := []e.ApMcuOrder{}
|
||||
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.ApMcuOrder{}).
|
||||
Scopes(gh.Preload(input.Includes)).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Scopes(gh.Sort(input.Sort))
|
||||
|
||||
if err := tx.Find(&data).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil, &meta, nil
|
||||
}
|
||||
return nil, nil, plh.HandleListError(input, event, err)
|
||||
}
|
||||
|
||||
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.ApMcuOrder, error) {
|
||||
pl.SetLogInfo(event, input, "started", "DBReadDetail")
|
||||
data := e.ApMcuOrder{}
|
||||
|
||||
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.ApMcuOrder, 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.ApMcuOrder, 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
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package apmcuorder
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/ap-mcu-order"
|
||||
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.ApMcuOrder) 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.ApMcuOrder) 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.ApMcuOrder) 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.ApMcuOrder) 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.ApMcuOrder) 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
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package apmcuorder
|
||||
|
||||
// example of middleware
|
||||
// func init() {
|
||||
// createPreMw = append(createPreMw,
|
||||
// CreateMw{Name: "modif-input", Func: pm.ModifInput},
|
||||
// CreateMw{Name: "check-data", Func: pm.CheckData},
|
||||
// )
|
||||
// }
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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 apmcuorder
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/ap-mcu-order"
|
||||
)
|
||||
|
||||
type createMw struct {
|
||||
Name string
|
||||
Func func(input *e.CreateDto, data *e.ApMcuOrder, tx *gorm.DB) error
|
||||
}
|
||||
|
||||
type readListMw struct {
|
||||
Name string
|
||||
Func func(input *e.ReadListDto, data *e.ApMcuOrder, tx *gorm.DB) error
|
||||
}
|
||||
|
||||
type readDetailMw struct {
|
||||
Name string
|
||||
Func func(input *e.ReadDetailDto, data *e.ApMcuOrder, 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
|
||||
@@ -179,6 +179,10 @@ func VerifyToken(r *http.Request, tokenType TokenType) (data *jwt.Token, errCode
|
||||
return token, "", ""
|
||||
}
|
||||
|
||||
func GetAuthInfoByUserName(userName string) (data *pa.AuthInfo, err error) {
|
||||
return getAuthByUserName(userName)
|
||||
}
|
||||
|
||||
func ExtractToken(r *http.Request, tokenType TokenType) (data *pa.AuthInfo, err error) {
|
||||
token, errCode, errDetail := VerifyToken(r, tokenType)
|
||||
if errCode != "" {
|
||||
|
||||
@@ -2,6 +2,7 @@ package authentication
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -10,10 +11,13 @@ import (
|
||||
dg "github.com/karincake/apem/db-gorm-pg"
|
||||
ms "github.com/karincake/apem/ms-redis"
|
||||
d "github.com/karincake/dodol"
|
||||
gh "github.com/karincake/getuk"
|
||||
l "github.com/karincake/lepet"
|
||||
|
||||
pl "simrs-vx/pkg/logger"
|
||||
|
||||
erg "simrs-vx/internal/domain/references/organization"
|
||||
|
||||
edp "simrs-vx/internal/domain/main-entities/division-position"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/employee"
|
||||
@@ -26,7 +30,6 @@ import (
|
||||
essp "simrs-vx/internal/domain/main-entities/subspecialist-position"
|
||||
eup "simrs-vx/internal/domain/main-entities/unit-position"
|
||||
eu "simrs-vx/internal/domain/main-entities/user"
|
||||
erg "simrs-vx/internal/domain/references/organization"
|
||||
|
||||
udp "simrs-vx/internal/use-case/main-use-case/division-position"
|
||||
uip "simrs-vx/internal/use-case/main-use-case/installation-position"
|
||||
@@ -334,3 +337,71 @@ func populateRoles(user *eu.User, input eu.LoginDto, atClaims jwt.MapClaims, out
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getAuthByUserName(username string) (auth *pa.AuthInfo, err error) {
|
||||
// get employee
|
||||
emp := ee.Employee{}
|
||||
if err = dg.I.
|
||||
Joins(`JOIN "User" u ON u."Id" = "Employee"."User_Id"`).
|
||||
Where(`u."Name" = ?`, username).
|
||||
Scopes(gh.Preload("User")).
|
||||
First(&emp).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
auth = &pa.AuthInfo{
|
||||
User_Id: *emp.User_Id,
|
||||
User_Name: emp.User.Name,
|
||||
User_ContractPosition_Code: string(emp.User.ContractPosition_Code),
|
||||
Employee_Position_Code: strPtr(string(*emp.Position_Code)),
|
||||
Employee_Id: &emp.Id,
|
||||
Sync: true,
|
||||
}
|
||||
|
||||
// set map table
|
||||
tableMap := map[erg.EmployeePositionCode]string{
|
||||
erg.EPCDoc: "Doctor",
|
||||
erg.EPCNur: "Nurse",
|
||||
erg.EPCMwi: "Midwife",
|
||||
erg.EPCNut: "Nutritionist",
|
||||
erg.EPCLab: "Laborant",
|
||||
erg.EPCPha: "Pharmachist",
|
||||
}
|
||||
|
||||
table := tableMap[*emp.Position_Code]
|
||||
if table == "" {
|
||||
return
|
||||
}
|
||||
|
||||
type CodeResult struct {
|
||||
Code string
|
||||
}
|
||||
var result CodeResult
|
||||
|
||||
err = dg.I.Table(table).
|
||||
Select("Code").
|
||||
Where("\"Employee_Id\" = ?", emp.Id).
|
||||
First(&result).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// set map for code
|
||||
setterMap := map[erg.EmployeePositionCode]func(string){
|
||||
erg.EPCDoc: func(v string) { auth.Doctor_Code = &v },
|
||||
erg.EPCNur: func(v string) { auth.Nurse_Code = &v },
|
||||
erg.EPCMwi: func(v string) { auth.Midwife_Code = &v },
|
||||
erg.EPCNut: func(v string) { auth.Nutritionist_Code = &v },
|
||||
erg.EPCLab: func(v string) { auth.Laborant_Code = &v },
|
||||
erg.EPCPha: func(v string) { auth.Pharmachist_Code = &v },
|
||||
}
|
||||
|
||||
setter := setterMap[*emp.Position_Code]
|
||||
setter(result.Code)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func strPtr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
@@ -17,12 +17,9 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ChemoProtocol) {
|
||||
inputSrc = &inputTemp.CreateDto
|
||||
}
|
||||
|
||||
data.Encounter_Id = inputSrc.Encounter_Id
|
||||
data.Patient_Weight = inputSrc.Patient_Weight
|
||||
data.Patient_Height = inputSrc.Patient_Height
|
||||
data.Diagnoses = inputSrc.Diagnoses
|
||||
data.Duration = inputSrc.Duration
|
||||
data.DurationUnit_Code = inputSrc.DurationUnit_Code
|
||||
data.StartDate = inputSrc.StartDate
|
||||
data.EndDate = inputSrc.EndDate
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
sync "simrs-vx/internal/infra/sync-cfg"
|
||||
sync "simrs-vx/internal/infra/sync-consumer-cfg"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/division"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
|
||||
@@ -94,7 +94,7 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
input.NewStatus, err = identifyPatientStatus(input)
|
||||
input.Adm_Employee_Id = input.AuthInfo.Employee_Id
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
// create encounter
|
||||
@@ -124,7 +124,8 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
|
||||
dataEncounter, err := ReadDetailData(e.ReadDetailDto{
|
||||
Id: data.Id,
|
||||
Includes: "Adm_Employee.User,Patient.Person.Relatives," +
|
||||
Includes: "Adm_Employee.User,Adm_Employee.Person," +
|
||||
"Patient.Person.Relatives," +
|
||||
"Patient.Person.VclaimMember,VclaimReference," +
|
||||
"Patient.Person.Contacts,Patient.Person.Addresses"},
|
||||
&event, tx)
|
||||
@@ -158,7 +159,6 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
var data *e.Encounter
|
||||
var dataList []e.Encounter
|
||||
var metaList *e.MetaDto
|
||||
var err error
|
||||
@@ -172,23 +172,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
pl.SetLogInfo(&event, input, "started", "readList")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
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
|
||||
})
|
||||
|
||||
@@ -223,23 +209,9 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
|
||||
pl.SetLogInfo(&event, input, "started", "readDetail")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
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
|
||||
})
|
||||
|
||||
@@ -277,7 +249,7 @@ func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
}
|
||||
input.Adm_Employee_Id = input.AuthInfo.Employee_Id
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
@@ -352,7 +324,7 @@ func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
@@ -436,7 +408,7 @@ func CheckOut(input e.DischargeDto) (*d.Data, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
@@ -554,14 +526,13 @@ func UpdateStatusCode(input e.UpdateStatusDto) (*d.Data, error) {
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "update")
|
||||
|
||||
// TODO: Only "supervisi pendaftaran" could cancel encounter
|
||||
roleAllowed := []string{string(erg.EPCReg), string(erg.EPCNur), string(erg.EPCDoc)}
|
||||
err = validateAuth(input.AuthInfo, roleAllowed, "update-status-encounter", &event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
@@ -604,9 +575,14 @@ func UpdateStatusCode(input e.UpdateStatusDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if input.StatusCode == erc.DSCProcess || input.StatusCode == erc.DSCCancel {
|
||||
data.Status_Code = input.StatusCode
|
||||
// get data encounter
|
||||
if data, err = ReadDetailData(e.ReadDetailDto{
|
||||
Id: input.Id,
|
||||
Includes: "Adm_Employee.User"}, &event, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if input.StatusCode == erc.DSCProcess || input.StatusCode == erc.DSCCancel {
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err := mwRunner.RunUpdateStatusMiddleware(updatestatusEncounter, data); err != nil {
|
||||
@@ -664,7 +640,7 @@ func CheckIn(input e.CheckinDto) (*d.Data, error) {
|
||||
input.StartedAt = &now
|
||||
}
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
@@ -767,7 +743,7 @@ func RequestSwitchUnit(input e.SwitchUnitDto) (*d.Data, error) {
|
||||
}
|
||||
input.Src_Nurse_Code = input.AuthInfo.Nurse_Code
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
@@ -795,7 +771,7 @@ func RequestSwitchUnit(input e.SwitchUnitDto) (*d.Data, error) {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "missing-soapi",
|
||||
Detail: fmt.Sprintf("Missing soapi from latest responsible doctor"),
|
||||
Detail: "Missing soapi from latest responsible doctor",
|
||||
}
|
||||
return pl.SetLogError(&event, input)
|
||||
}
|
||||
@@ -861,7 +837,7 @@ func ApproveSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
@@ -905,7 +881,7 @@ func ApproveSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "missing-soapi",
|
||||
Detail: fmt.Sprintf("Missing soapi from latest responsible doctor"),
|
||||
Detail: "Missing soapi from latest responsible doctor",
|
||||
}
|
||||
return pl.SetLogError(&event, input)
|
||||
}
|
||||
@@ -976,7 +952,7 @@ func CancelSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
|
||||
@@ -65,44 +65,71 @@ import (
|
||||
us "simrs-vx/internal/use-case/main-use-case/soapi"
|
||||
)
|
||||
|
||||
func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Encounter) {
|
||||
var inputSrc *e.CreateDto
|
||||
if inputT, ok := any(input).(*e.CreateDto); ok {
|
||||
inputSrc = inputT
|
||||
data.Status_Code = erc.DSCNew
|
||||
} else {
|
||||
inputTemp := any(input).(*e.UpdateDto)
|
||||
inputSrc = &inputTemp.CreateDto
|
||||
}
|
||||
|
||||
data.Patient_Id = inputSrc.Patient_Id
|
||||
data.RegisteredAt = inputSrc.RegisteredAt
|
||||
data.Class_Code = inputSrc.Class_Code
|
||||
data.Unit_Code = inputSrc.Unit_Code
|
||||
data.Specialist_Code = inputSrc.Specialist_Code
|
||||
data.Subspecialist_Code = inputSrc.Subspecialist_Code
|
||||
data.VisitDate = inputSrc.VisitDate
|
||||
data.PaymentMethod_Code = inputSrc.PaymentMethod_Code
|
||||
data.InsuranceCompany_Code = inputSrc.InsuranceCompany_Code
|
||||
data.Member_Number = inputSrc.Member_Number
|
||||
data.Ref_Number = inputSrc.Ref_Number
|
||||
data.Trx_Number = inputSrc.Trx_Number
|
||||
data.Appointment_Doctor_Code = inputSrc.Appointment_Doctor_Code
|
||||
data.Adm_Employee_Id = inputSrc.Adm_Employee_Id
|
||||
data.Responsible_Doctor_Code = inputSrc.Responsible_Doctor_Code
|
||||
data.RefSource_Name = inputSrc.RefSource_Name
|
||||
data.Appointment_Id = inputSrc.Appointment_Id
|
||||
data.RefType_Code = &inputSrc.RefTypeCode
|
||||
data.NewStatus = inputSrc.NewStatus
|
||||
func setDataCreate(input *e.CreateDto, data *e.Encounter) {
|
||||
data.Patient_Id = input.Patient_Id
|
||||
data.RegisteredAt = input.RegisteredAt
|
||||
data.Class_Code = input.Class_Code
|
||||
data.Unit_Code = input.Unit_Code
|
||||
data.Specialist_Code = input.Specialist_Code
|
||||
data.Subspecialist_Code = input.Subspecialist_Code
|
||||
data.VisitDate = input.VisitDate
|
||||
data.PaymentMethod_Code = input.PaymentMethod_Code
|
||||
data.InsuranceCompany_Code = input.InsuranceCompany_Code
|
||||
data.Member_Number = input.Member_Number
|
||||
data.RefType_Code = &input.RefTypeCode
|
||||
data.Ref_Number = input.Ref_Number
|
||||
data.Trx_Number = input.Trx_Number
|
||||
data.Appointment_Doctor_Code = input.Appointment_Doctor_Code
|
||||
data.Adm_Employee_Id = input.Adm_Employee_Id
|
||||
data.RefSource_Name = input.RefSource_Name
|
||||
data.Appointment_Id = input.Appointment_Id
|
||||
data.Status_Code = erc.DSCNew
|
||||
data.NewStatus = input.NewStatus
|
||||
}
|
||||
|
||||
func setDataUpdate(src e.UpdateDto, dst *e.Encounter) {
|
||||
dst.Appointment_Doctor_Code = src.Appointment_Doctor_Code
|
||||
dst.Responsible_Doctor_Code = src.Responsible_Doctor_Code
|
||||
dst.Unit_Code = src.Unit_Code
|
||||
dst.Specialist_Code = src.Specialist_Code
|
||||
dst.Subspecialist_Code = src.Subspecialist_Code
|
||||
dst.VisitDate = src.VisitDate
|
||||
dst.Appointment_Doctor_Code = src.Appointment_Doctor_Code
|
||||
dst.Adm_Employee_Id = src.Adm_Employee_Id
|
||||
dst.Appointment_Id = src.Appointment_Id
|
||||
dst.RefSource_Name = src.RefSource_Name
|
||||
dst.Trx_Number = src.Trx_Number
|
||||
dst.Ref_Number = src.Ref_Number
|
||||
dst.Member_Number = src.Member_Number
|
||||
}
|
||||
|
||||
func setDataUpdateFromSource(input *e.UpdateDto, data *e.Encounter) {
|
||||
data.Patient_Id = input.Patient_Id
|
||||
data.RegisteredAt = input.RegisteredAt
|
||||
data.Unit_Code = input.Unit_Code
|
||||
data.Specialist_Code = input.Specialist_Code
|
||||
data.Subspecialist_Code = input.Subspecialist_Code
|
||||
data.VisitDate = input.VisitDate
|
||||
data.StartedAt = input.StartedAt
|
||||
data.FinishedAt = input.FinishedAt
|
||||
data.PaymentMethod_Code = input.PaymentMethod_Code
|
||||
data.InsuranceCompany_Code = input.InsuranceCompany_Code
|
||||
data.Member_Number = input.Member_Number
|
||||
data.RefType_Code = &input.RefTypeCode
|
||||
data.Ref_Number = input.Ref_Number
|
||||
data.Trx_Number = input.Trx_Number
|
||||
data.Appointment_Doctor_Code = input.Appointment_Doctor_Code
|
||||
data.Adm_Employee_Id = input.Adm_Employee_Id
|
||||
data.Responsible_Doctor_Code = input.Responsible_Doctor_Code
|
||||
data.Discharge_Method_Code = input.Discharge_Method_Code
|
||||
data.RefSource_Name = input.RefSource_Name
|
||||
data.Appointment_Id = input.Appointment_Id
|
||||
data.EarlyEducation = input.EarlyEducation
|
||||
data.MedicalDischargeEducation = input.MedicalDischargeEducation
|
||||
data.AdmDischargeEducation = input.AdmDischargeEducation
|
||||
data.DischargeReason = input.DischargeReason
|
||||
data.Status_Code = input.Status_Code
|
||||
data.Discharge_Date = input.Discharge_Date
|
||||
data.NewStatus = input.NewStatus
|
||||
data.Responsible_Nurse_Code = input.Responsible_Nurse_Code
|
||||
}
|
||||
|
||||
func setDataDischarge(src e.DischargeDto, dst *e.Encounter) {
|
||||
@@ -610,7 +637,7 @@ func getSoapiEncounterAdm(enc e.Encounter, event *pl.Event) (dataSoapi []es.Crea
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "missing-soapi",
|
||||
Detail: fmt.Sprintf("Missing required Soapi types"),
|
||||
Detail: "Missing required Soapi types",
|
||||
}
|
||||
return nil, pl.SetLogError(event, enc)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.Encount
|
||||
pl.SetLogInfo(event, nil, "started", "DBCreate")
|
||||
|
||||
data := e.Encounter{}
|
||||
setData(&input, &data)
|
||||
setDataCreate(&input, &data)
|
||||
|
||||
var tx *gorm.DB
|
||||
if len(dbx) > 0 {
|
||||
@@ -140,7 +140,12 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
|
||||
|
||||
func UpdateData(input e.UpdateDto, data *e.Encounter, event *pl.Event, dbx ...*gorm.DB) error {
|
||||
pl.SetLogInfo(event, data, "started", "DBUpdate")
|
||||
setDataUpdate(input, data)
|
||||
|
||||
if input.Sync {
|
||||
setDataUpdateFromSource(&input, data)
|
||||
} else {
|
||||
setDataUpdate(input, data)
|
||||
}
|
||||
|
||||
var tx *gorm.DB
|
||||
if len(dbx) > 0 {
|
||||
@@ -247,7 +252,10 @@ func UpdateStatusData(input e.UpdateStatusDto, event *pl.Event, dbx ...*gorm.DB)
|
||||
|
||||
if err := tx.Model(&e.Encounter{}).
|
||||
Where("\"Id\" = ?", input.Id).
|
||||
Update("Status_Code", input.StatusCode).Error; err != nil {
|
||||
Updates(map[string]interface{}{
|
||||
"Status_Code": input.StatusCode,
|
||||
"Adm_Employee_Id": input.Employee_Id,
|
||||
}).Error; err != nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "update-fail",
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
sync "simrs-vx/internal/infra/sync-cfg"
|
||||
sync "simrs-vx/internal/infra/sync-consumer-cfg"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/encounter"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
@@ -20,10 +20,15 @@ type middlewareRunner struct {
|
||||
}
|
||||
|
||||
// NewMiddlewareExecutor creates a new middleware executor
|
||||
func newMiddlewareRunner(event *pl.Event) *middlewareRunner {
|
||||
func newMiddlewareRunner(event *pl.Event, syncFromOldSource bool) *middlewareRunner {
|
||||
activateSync := sync.O.Enable
|
||||
if syncFromOldSource {
|
||||
activateSync = false
|
||||
}
|
||||
|
||||
return &middlewareRunner{
|
||||
Event: event,
|
||||
SyncOn: sync.O.Enable,
|
||||
SyncOn: activateSync,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
sync "simrs-vx/internal/infra/sync-cfg"
|
||||
sync "simrs-vx/internal/infra/sync-consumer-cfg"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/installation"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
|
||||
@@ -37,7 +37,7 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "create")
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
if !input.AuthInfo.IsReg() && !input.AuthInfo.IsSys() {
|
||||
event.Status = "failed"
|
||||
@@ -142,7 +142,6 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
}
|
||||
|
||||
func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
var data *e.Patient
|
||||
var dataList []e.Patient
|
||||
var metaList *e.MetaDto
|
||||
var err error
|
||||
@@ -156,23 +155,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
|
||||
pl.SetLogInfo(&event, input, "started", "readList")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
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
|
||||
})
|
||||
|
||||
@@ -207,23 +192,9 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
|
||||
pl.SetLogInfo(&event, input, "started", "readDetail")
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
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
|
||||
})
|
||||
|
||||
@@ -253,7 +224,7 @@ func Update(input e.UpdateDto) (*d.Data, error) {
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "update")
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
if !input.AuthInfo.IsReg() && !input.AuthInfo.IsSys() {
|
||||
event.Status = "failed"
|
||||
@@ -352,7 +323,7 @@ func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "delete")
|
||||
mwRunner := newMiddlewareRunner(&event)
|
||||
mwRunner := newMiddlewareRunner(&event, input.Sync)
|
||||
|
||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||
pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail")
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
sync "simrs-vx/internal/infra/sync-cfg"
|
||||
sync "simrs-vx/internal/infra/sync-consumer-cfg"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/patient"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
@@ -20,10 +20,15 @@ type middlewareRunner struct {
|
||||
}
|
||||
|
||||
// NewMiddlewareExecutor creates a new middleware executor
|
||||
func newMiddlewareRunner(event *pl.Event) *middlewareRunner {
|
||||
func newMiddlewareRunner(event *pl.Event, syncFromOldSource bool) *middlewareRunner {
|
||||
activateSync := sync.O.Enable
|
||||
if syncFromOldSource {
|
||||
activateSync = false
|
||||
}
|
||||
|
||||
return &middlewareRunner{
|
||||
Event: event,
|
||||
SyncOn: sync.O.Enable,
|
||||
SyncOn: activateSync,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package personaddress
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/person-address"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
plh "simrs-vx/pkg/lib-helper"
|
||||
pl "simrs-vx/pkg/logger"
|
||||
@@ -179,10 +181,19 @@ func CreateOrUpdateBatch(input []e.UpdateDto, event *pl.Event, tx ...*gorm.DB) e
|
||||
}
|
||||
setData(&input[idx], &data[idx])
|
||||
if err := dbx.Create(&data[idx]).Error; err != nil {
|
||||
errMsg := err.Error()
|
||||
additionalMessage := ""
|
||||
// FK error
|
||||
if strings.Contains(errMsg, "violates foreign key") {
|
||||
pos := strings.Index(errMsg, "violates foreign key")
|
||||
additionalMessage = ", " + errMsg[pos:]
|
||||
}
|
||||
// Got another errot, put it down below
|
||||
// ....
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-create-fail",
|
||||
Detail: "Database insert failed",
|
||||
Detail: "data insert failed at PersonAddres[" + strconv.Itoa(idx) + "]" + additionalMessage,
|
||||
Raw: err,
|
||||
}
|
||||
return pl.SetLogError(event, input)
|
||||
|
||||
@@ -0,0 +1,276 @@
|
||||
package doctor
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
dg "github.com/karincake/apem/db-gorm-pg"
|
||||
d "github.com/karincake/dodol"
|
||||
"gorm.io/gorm"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/registration"
|
||||
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
)
|
||||
|
||||
const source = "doctor"
|
||||
|
||||
func Create(input e.CreateDto) (*d.Data, error) {
|
||||
data := e.Registration{}
|
||||
|
||||
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.Registration
|
||||
var dataList []e.Registration
|
||||
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),
|
||||
"record_currentCount": strconv.Itoa(len(dataList)),
|
||||
},
|
||||
Data: e.ToResponseList(dataList),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
|
||||
var data *e.Registration
|
||||
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: input.Id}
|
||||
var data *e.Registration
|
||||
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: &input.Id}
|
||||
var data *e.Registration
|
||||
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
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Any functions that are used internally by the use-case
|
||||
*/
|
||||
package doctor
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/registration"
|
||||
)
|
||||
|
||||
func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Registration) {
|
||||
var inputSrc *e.CreateDto
|
||||
if inputT, ok := any(input).(*e.CreateDto); ok {
|
||||
inputSrc = inputT
|
||||
} else {
|
||||
inputTemp := any(input).(*e.UpdateDto)
|
||||
inputSrc = &inputTemp.CreateDto
|
||||
}
|
||||
|
||||
data.Employee_Id = inputSrc.Employee_Id
|
||||
data.Installation_Code = inputSrc.Installation_Code
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package doctor
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
e "simrs-vx/internal/domain/main-entities/registration"
|
||||
|
||||
plh "simrs-vx/pkg/lib-helper"
|
||||
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.Registration, error) {
|
||||
pl.SetLogInfo(event, nil, "started", "DBCreate")
|
||||
|
||||
data := e.Registration{}
|
||||
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 {
|
||||
return nil, plh.HandleCreateError(input, event, err)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(event, nil, "complete")
|
||||
return &data, nil
|
||||
}
|
||||
|
||||
func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Registration, *e.MetaDto, error) {
|
||||
pl.SetLogInfo(event, input, "started", "DBReadList")
|
||||
data := []e.Registration{}
|
||||
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.Registration{}).
|
||||
Scopes(gh.Preload(input.Includes)).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Order("\"CreatedAt\" DESC")
|
||||
|
||||
if err := tx.Find(&data).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil, &meta, nil
|
||||
}
|
||||
return nil, nil, plh.HandleListError(input, event, err)
|
||||
}
|
||||
|
||||
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.Registration, error) {
|
||||
pl.SetLogInfo(event, input, "started", "DBReadDetail")
|
||||
data := e.Registration{}
|
||||
|
||||
var tx *gorm.DB
|
||||
if len(dbx) > 0 {
|
||||
tx = dbx[0]
|
||||
} else {
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
if input.Employee_Id != nil {
|
||||
tx = tx.Where("\"Employee_Id\" = ?", *input.Employee_Id)
|
||||
}
|
||||
if input.Id != nil {
|
||||
tx = tx.Where("\"Id\" = ?", input.Id)
|
||||
}
|
||||
fmt.Println(input.Includes)
|
||||
if err := tx.Scopes(gh.Preload(input.Includes)).First(&data).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.Registration, 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.Registration, 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
|
||||
}
|
||||
|
||||
func GetIdByUserId(user_id *uint, event *pl.Event, dbx ...*gorm.DB) (*uint, error) {
|
||||
pl.SetLogInfo(event, nil, "started", "DBGetIdByUserId")
|
||||
var tx *gorm.DB
|
||||
if len(dbx) > 0 {
|
||||
tx = dbx[0]
|
||||
} else {
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
var doctor_id uint
|
||||
|
||||
err := tx.Model(&e.Registration{}).
|
||||
Select("\"Doctor\".\"Id\" as doctor_id").
|
||||
Joins("JOIN \"Employee\" as e ON e.\"Id\" = \"Doctor\".\"Employee_Id\"").
|
||||
Where("e.\"User_Id\" = ?", user_id).
|
||||
Scan(&doctor_id).Error
|
||||
|
||||
if err != nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-get-fail",
|
||||
Detail: "Database get failed",
|
||||
Raw: err,
|
||||
}
|
||||
return nil, pl.SetLogError(event, user_id)
|
||||
}
|
||||
|
||||
pl.SetLogInfo(event, nil, "complete")
|
||||
return &doctor_id, nil
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package doctor
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/registration"
|
||||
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.Registration) 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.Registration) 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.Registration) 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.Registration) 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.Registration) 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
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package doctor
|
||||
|
||||
// example of middleware
|
||||
// func init() {
|
||||
// createPreMw = append(createPreMw,
|
||||
// CreateMw{Name: "modif-input", Func: pm.ModifInput},
|
||||
// CreateMw{Name: "check-data", Func: pm.CheckData},
|
||||
// )
|
||||
// }
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user