Merge branch 'migration-vanilia' of https://github.com/dikstub-rssa/simrs-be into feat/sync-source
This commit is contained in:
@@ -16,3 +16,7 @@ apply:
|
||||
## Calculate the schema hash
|
||||
hash:
|
||||
atlas migrate hash
|
||||
|
||||
## Apply non-linear
|
||||
apply-non-linear:
|
||||
atlas migrate apply --env $(ENV) --exec-order non-linear
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Modify "TherapyProtocol" table
|
||||
ALTER TABLE "public"."TherapyProtocol" ADD COLUMN "Status_Code" character varying(10) NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Rename a column from "Count" to "Quantity"
|
||||
ALTER TABLE "public"."DeviceOrderItem" RENAME COLUMN "Count" TO "Quantity";
|
||||
@@ -1,4 +1,4 @@
|
||||
h1:hrZ5BrQCFCoyZbD1KKYCyR53xT2LTdRCIONnoNRierc=
|
||||
h1:fNeqUpbdIqGDiH68u1bwwMgHTEOmmEWeI+IIYEq6pto=
|
||||
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
|
||||
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
|
||||
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
|
||||
@@ -117,3 +117,5 @@ h1:hrZ5BrQCFCoyZbD1KKYCyR53xT2LTdRCIONnoNRierc=
|
||||
20251111111017.sql h1:qrJ93dNtQwcuAvpsP/lAK/H63C4cinXrsVaPmWsTqkU=
|
||||
20251113101344.sql h1:xaOZvAUP1fFfnO+syEFOzJUIg5lTfBe5AWHPbBWuCLA=
|
||||
20251113120533.sql h1:f3/U1Ve2yF2zSMhkt+xtwF8wUYfUKYwgbNeGfE37EW4=
|
||||
20251114062746.sql h1:FInLaEFQByESEwFJKuKnuUSTKmcDpi3ZXaxkKwz2+D8=
|
||||
20251117005942.sql h1:mW/TC8GgFgPLZ7PBVQnn9mChEekAcwfQMCbzXnoaw9w=
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
-- Create "DivisionLink" table
|
||||
CREATE TABLE "public"."DivisionLink" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Simx_Id" bigint NULL,
|
||||
"Simgos_Id" bigint NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_DivisionLink_Simgos_Id" UNIQUE ("Simgos_Id"),
|
||||
CONSTRAINT "uni_DivisionLink_Simx_Id" UNIQUE ("Simx_Id")
|
||||
);
|
||||
-- Create "DivisionSimgosLog" table
|
||||
CREATE TABLE "public"."DivisionSimgosLog" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Value" text NULL,
|
||||
"Date" timestamptz NULL,
|
||||
"Status" text NULL,
|
||||
"ErrMessage" text NULL,
|
||||
PRIMARY KEY ("Id")
|
||||
);
|
||||
-- Create "DivisionSimxLog" table
|
||||
CREATE TABLE "public"."DivisionSimxLog" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Value" text NULL,
|
||||
"Date" timestamptz NULL,
|
||||
"Status" text NULL,
|
||||
"ErrMessage" text NULL,
|
||||
PRIMARY KEY ("Id")
|
||||
);
|
||||
-- Create "SpecialistLink" table
|
||||
CREATE TABLE "public"."SpecialistLink" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Simx_Id" bigint NULL,
|
||||
"Simgos_Id" bigint NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_SpecialistLink_Simgos_Id" UNIQUE ("Simgos_Id"),
|
||||
CONSTRAINT "uni_SpecialistLink_Simx_Id" UNIQUE ("Simx_Id")
|
||||
);
|
||||
-- Create "SpecialistSimgosLog" table
|
||||
CREATE TABLE "public"."SpecialistSimgosLog" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Value" text NULL,
|
||||
"Date" timestamptz NULL,
|
||||
"Status" text NULL,
|
||||
"ErrMessage" text NULL,
|
||||
PRIMARY KEY ("Id")
|
||||
);
|
||||
-- Create "SpecialistSimxLog" table
|
||||
CREATE TABLE "public"."SpecialistSimxLog" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Value" text NULL,
|
||||
"Date" timestamptz NULL,
|
||||
"Status" text NULL,
|
||||
"ErrMessage" text NULL,
|
||||
PRIMARY KEY ("Id")
|
||||
);
|
||||
-- Create "SubspecialistLink" table
|
||||
CREATE TABLE "public"."SubspecialistLink" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Simx_Id" bigint NULL,
|
||||
"Simgos_Id" bigint NULL,
|
||||
PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "uni_SubspecialistLink_Simgos_Id" UNIQUE ("Simgos_Id"),
|
||||
CONSTRAINT "uni_SubspecialistLink_Simx_Id" UNIQUE ("Simx_Id")
|
||||
);
|
||||
-- Create "SubspecialistSimgosLog" table
|
||||
CREATE TABLE "public"."SubspecialistSimgosLog" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Value" text NULL,
|
||||
"Date" timestamptz NULL,
|
||||
"Status" text NULL,
|
||||
"ErrMessage" text NULL,
|
||||
PRIMARY KEY ("Id")
|
||||
);
|
||||
-- Create "SubspecialistSimxLog" table
|
||||
CREATE TABLE "public"."SubspecialistSimxLog" (
|
||||
"Id" bigserial NOT NULL,
|
||||
"CreatedAt" timestamptz NULL,
|
||||
"UpdatedAt" timestamptz NULL,
|
||||
"DeletedAt" timestamptz NULL,
|
||||
"Value" text NULL,
|
||||
"Date" timestamptz NULL,
|
||||
"Status" text NULL,
|
||||
"ErrMessage" text NULL,
|
||||
PRIMARY KEY ("Id")
|
||||
);
|
||||
@@ -1,3 +1,4 @@
|
||||
h1:xxkaO6rL13nwrZd1vrsoGJrrwCtXPgGRmwGEjWJ1V/c=
|
||||
h1:SN+f41iFH0m63kHeZHYricAjil5GJ9EC0LBOSdFDnmY=
|
||||
20251113035508.sql h1:rjDlu6yDdy5xv6nrCOr7NialrLSLT23pzduYNq29Hf0=
|
||||
20251114071129.sql h1:O4nfv4l9vcXpE2Kyu7vjnubD8kDZ7JltRaF2auOdMpc=
|
||||
20251114071129.sql h1:Z0GQ5bJo3C+tplaWzxT8n3J9HLkEaVsRVp5nn7bmYow=
|
||||
20251117041601.sql h1:mIxZ2luKQREXUBY36PwLNDFI/Wf1T6Z2DDoGOueXFwI=
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package deviceorderitem
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/device"
|
||||
)
|
||||
|
||||
type DeviceOrderItem struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
DeviceOrder_Id *uint `json:"deviceOrder_id"`
|
||||
Device_Code *string `json:"device_code"`
|
||||
Device *ed.Device `json:"device,omitempty" gorm:"foreignKey:Device_Code;references:Code"`
|
||||
Quantity uint8 `json:"quantity"`
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
type CreateDto struct {
|
||||
DeviceOrder_Id *uint `json:"deviceOrder_id"`
|
||||
Device_Code *string `json:"device_code"`
|
||||
Count uint8 `json:"count"`
|
||||
Quantity uint8 `json:"quantity"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
@@ -19,9 +19,9 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
DeviceOrder_Id *uint `json:"deviceOrder-id"`
|
||||
DeviceOrder_Id *uint `json:"device-order-id"`
|
||||
Device_Code *string `json:"device-code"`
|
||||
Count uint8 `json:"count"`
|
||||
Quantity uint8 `json:"quantity"`
|
||||
}
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
@@ -48,7 +48,7 @@ type ResponseDto struct {
|
||||
DeviceOrder *edo.DeviceOrder `json:"deviceOrder,omitempty"`
|
||||
Device_Code *string `json:"device_code"`
|
||||
Device *ed.Device `json:"device,omitempty"`
|
||||
Count uint8 `json:"count"`
|
||||
Quantity uint8 `json:"quantity"`
|
||||
}
|
||||
|
||||
func (d DeviceOrderItem) ToResponse() ResponseDto {
|
||||
@@ -57,7 +57,7 @@ func (d DeviceOrderItem) ToResponse() ResponseDto {
|
||||
DeviceOrder: d.DeviceOrder,
|
||||
Device_Code: d.Device_Code,
|
||||
Device: d.Device,
|
||||
Count: d.Count,
|
||||
Quantity: d.Quantity,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -2,15 +2,12 @@ package deviceorderitem
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/device"
|
||||
edo "simrs-vx/internal/domain/main-entities/device-order"
|
||||
eb "simrs-vx/internal/domain/main-entities/device-order-item/base"
|
||||
)
|
||||
|
||||
type DeviceOrderItem struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
DeviceOrder_Id *uint `json:"deviceOrder_id"`
|
||||
DeviceOrder *edo.DeviceOrder `json:"deviceOrder,omitempty" gorm:"foreignKey:DeviceOrder_Id;references:Id"`
|
||||
Device_Code *string `json:"device_code"`
|
||||
Device *ed.Device `json:"device,omitempty" gorm:"foreignKey:Device_Code;references:Code"`
|
||||
Count uint8 `json:"count"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
eb.DeviceOrderItem
|
||||
DeviceOrder *edo.DeviceOrder `json:"deviceOrder,omitempty" gorm:"foreignKey:DeviceOrder_Id;references:Id"`
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
|
||||
// internal - domain - main-entities
|
||||
edoi "simrs-vx/internal/domain/main-entities/device-order-item/base"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
)
|
||||
@@ -55,11 +56,12 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
Items []edoi.DeviceOrderItem `json:"items"`
|
||||
}
|
||||
|
||||
func (d DeviceOrder) ToResponse() ResponseDto {
|
||||
@@ -69,6 +71,7 @@ func (d DeviceOrder) ToResponse() ResponseDto {
|
||||
Doctor_Code: d.Doctor_Code,
|
||||
Doctor: d.Doctor,
|
||||
Status_Code: d.Status_Code,
|
||||
Items: d.Items,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package deviceorder
|
||||
|
||||
import (
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
edoi "simrs-vx/internal/domain/main-entities/device-order-item/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 DeviceOrder struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
Items []edoi.DeviceOrderItem `json:"items" gorm:"foreignKey:DeviceOrder_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d DeviceOrder) IsCompleted() bool {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package prescriptionitem
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
em "simrs-vx/internal/domain/main-entities/medicine"
|
||||
emm "simrs-vx/internal/domain/main-entities/medicine-mix"
|
||||
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
type PrescriptionItem struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Prescription_Id *uint `json:"prescription_id"`
|
||||
IsMix bool `json:"isMix"`
|
||||
Medicine_Code *string `json:"medicine_code"`
|
||||
Medicine *em.Medicine `json:"medicine,omitempty" gorm:"foreignKey:Medicine_Code;references:Code"`
|
||||
MedicineMix_Id *uint `json:"medicineMix_id"`
|
||||
MedicineMix *emm.MedicineMix `json:"medicineMix,omitempty" gorm:"foreignKey:MedicineMix_Id;references:Id"`
|
||||
Frequency *uint16 `json:"frequency"`
|
||||
Dose float64 `json:"dose"`
|
||||
Usage string `json:"usage" gorm:"size:255"`
|
||||
Interval uint8 `json:"interval"`
|
||||
IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
}
|
||||
@@ -27,6 +27,7 @@ type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Pagination ecore.Pagination
|
||||
Sort string `json:"sort"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
|
||||
@@ -2,26 +2,12 @@ package prescriptionitem
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
em "simrs-vx/internal/domain/main-entities/medicine"
|
||||
emm "simrs-vx/internal/domain/main-entities/medicine-mix"
|
||||
ep "simrs-vx/internal/domain/main-entities/prescription"
|
||||
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
epib "simrs-vx/internal/domain/main-entities/prescription-item/base"
|
||||
)
|
||||
|
||||
type PrescriptionItem struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Prescription_Id *uint `json:"prescription_id"`
|
||||
Prescription *ep.Prescription `json:"prescription,omitempty" gorm:"foreignKey:Prescription_Id;references:Id"`
|
||||
IsMix bool `json:"isMix"`
|
||||
Medicine_Code *string `json:"medicine_code"`
|
||||
Medicine *em.Medicine `json:"medicine,omitempty" gorm:"foreignKey:Medicine_Code;references:Code"`
|
||||
MedicineMix_Id *uint `json:"medicineMix_id"`
|
||||
MedicineMix *emm.MedicineMix `json:"medicineMix,omitempty" gorm:"foreignKey:MedicineMix_Id;references:Id"`
|
||||
Frequency *uint16 `json:"frequency"`
|
||||
Dose float64 `json:"dose"`
|
||||
Usage string `json:"usage" gorm:"size:255"`
|
||||
Interval uint8 `json:"interval"`
|
||||
IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
epib.PrescriptionItem
|
||||
Prescription *ep.Prescription `json:"prescription,omitempty" gorm:"foreignKey:Prescription_Id;references:Id"`
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
epi "simrs-vx/internal/domain/main-entities/prescription-item/base"
|
||||
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
|
||||
@@ -56,12 +57,13 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
IssuedAt *time.Time `json:"issuedAt"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
IssuedAt *time.Time `json:"issuedAt"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
Items []epi.PrescriptionItem `json:"items" gorm:"foreignKey:Prescription_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d Prescription) ToResponse() ResponseDto {
|
||||
@@ -72,6 +74,7 @@ func (d Prescription) ToResponse() ResponseDto {
|
||||
Doctor: d.Doctor,
|
||||
IssuedAt: d.IssuedAt,
|
||||
Status_Code: d.Status_Code,
|
||||
Items: d.Items,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
epi "simrs-vx/internal/domain/main-entities/prescription-item/base"
|
||||
|
||||
"time"
|
||||
|
||||
@@ -11,13 +12,14 @@ import (
|
||||
)
|
||||
|
||||
type Prescription struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Doctor_Code *string `json:"doctor_code" gorm:"size:20"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
IssuedAt *time.Time `json:"issuedAt"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Doctor_Code *string `json:"doctor_code" gorm:"size:20"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
IssuedAt *time.Time `json:"issuedAt"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
Items []epi.PrescriptionItem `json:"items" gorm:"foreignKey:Prescription_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d Prescription) IsNotNew() bool {
|
||||
|
||||
@@ -4,24 +4,27 @@ import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
"simrs-vx/internal/domain/references/common"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Anamnesis *string `json:"anamnesis" validate:"maxLength=2048"`
|
||||
MedicalDiagnoses *string `json:"medicalDiagnoses"`
|
||||
FunctionDiagnoses *string `json:"functionDiagnoses"`
|
||||
Procedures *string `json:"procedures"`
|
||||
SupportingExams *string `json:"supportingExams" validate:"maxLength=2048"`
|
||||
Instruction *string `json:"instruction" validate:"maxLength=2048"`
|
||||
Evaluation *string `json:"evaluation" validate:"maxLength=2048"`
|
||||
WorkCauseStatus *string `json:"workCauseStatus"`
|
||||
Frequency *uint `json:"frequency"`
|
||||
IntervalUnit_Code *common.TimeUnitCode `json:"intervalUnit_code" validate:"maxLength=10"`
|
||||
Duration *uint `json:"duration"`
|
||||
DurationUnit_Code *common.TimeUnitCode `json:"durationUnit_code" validate:"maxLength=10"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Anamnesis *string `json:"anamnesis" validate:"maxLength=2048"`
|
||||
MedicalDiagnoses *string `json:"medicalDiagnoses"`
|
||||
FunctionDiagnoses *string `json:"functionDiagnoses"`
|
||||
Procedures *string `json:"procedures"`
|
||||
SupportingExams *string `json:"supportingExams" validate:"maxLength=2048"`
|
||||
Instruction *string `json:"instruction" validate:"maxLength=2048"`
|
||||
Evaluation *string `json:"evaluation" validate:"maxLength=2048"`
|
||||
WorkCauseStatus *string `json:"workCauseStatus"`
|
||||
Frequency *uint `json:"frequency"`
|
||||
IntervalUnit_Code *erc.TimeUnitCode `json:"intervalUnit_code" validate:"maxLength=10"`
|
||||
Duration *uint `json:"duration"`
|
||||
DurationUnit_Code *erc.TimeUnitCode `json:"durationUnit_code" validate:"maxLength=10"`
|
||||
Status_Code *erc.DataVerifiedCode `json:"status_code"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
@@ -49,6 +52,13 @@ type DeleteDto struct {
|
||||
Id uint `json:"id"`
|
||||
}
|
||||
|
||||
type VerifyDto struct {
|
||||
Id uint `json:"id"`
|
||||
Status_Code erc.DataVerifiedCode `json:"status_code"`
|
||||
|
||||
pa.AuthInfo
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
PageNumber int `json:"page_number"`
|
||||
PageSize int `json:"page_size"`
|
||||
@@ -57,22 +67,23 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
Anamnesis *string `json:"anamnesis"`
|
||||
MedicalDiagnoses *string `json:"medicalDiagnoses"`
|
||||
FunctionDiagnoses *string `json:"functionDiagnoses"`
|
||||
Procedures *string `json:"procedures"`
|
||||
SupportingExams *string `json:"supportingExams"`
|
||||
Instruction *string `json:"instruction"`
|
||||
Evaluation *string `json:"evaluation"`
|
||||
WorkCauseStatus *string `json:"workCauseStatus"`
|
||||
Frequency *uint `json:"frequency"`
|
||||
IntervalUnit_Code *common.TimeUnitCode `json:"intervalUnit_code"`
|
||||
Duration *uint `json:"duration"`
|
||||
DurationUnit_Code *common.TimeUnitCode `json:"durationUnit_code"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
Anamnesis *string `json:"anamnesis"`
|
||||
MedicalDiagnoses *string `json:"medicalDiagnoses"`
|
||||
FunctionDiagnoses *string `json:"functionDiagnoses"`
|
||||
Procedures *string `json:"procedures"`
|
||||
SupportingExams *string `json:"supportingExams"`
|
||||
Instruction *string `json:"instruction"`
|
||||
Evaluation *string `json:"evaluation"`
|
||||
WorkCauseStatus *string `json:"workCauseStatus"`
|
||||
Frequency *uint `json:"frequency"`
|
||||
IntervalUnit_Code *erc.TimeUnitCode `json:"intervalUnit_code"`
|
||||
Duration *uint `json:"duration"`
|
||||
DurationUnit_Code *erc.TimeUnitCode `json:"durationUnit_code"`
|
||||
Status_Code *erc.DataVerifiedCode `json:"status_code"`
|
||||
}
|
||||
|
||||
func (d TherapyProtocol) ToResponse() ResponseDto {
|
||||
@@ -93,6 +104,7 @@ func (d TherapyProtocol) ToResponse() ResponseDto {
|
||||
IntervalUnit_Code: d.IntervalUnit_Code,
|
||||
Duration: d.Duration,
|
||||
DurationUnit_Code: d.DurationUnit_Code,
|
||||
Status_Code: d.Status_Code,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -16,16 +16,21 @@ type TherapyProtocol struct {
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
|
||||
Anamnesis *string `json:"anamnesis" gorm:"size:2048"`
|
||||
MedicalDiagnoses *string `json:"medicalDiagnoses"`
|
||||
FunctionDiagnoses *string `json:"functionDiagnoses"`
|
||||
Procedures *string `json:"procedures"`
|
||||
SupportingExams *string `json:"supportingExams" gorm:"size:2048"`
|
||||
Instruction *string `json:"instruction" gorm:"size:2048"`
|
||||
Evaluation *string `json:"evaluation" gorm:"size:2048"`
|
||||
WorkCauseStatus *string `json:"workCauseStatus" gorm:"size:2048"`
|
||||
Frequency *uint `json:"frequency"`
|
||||
IntervalUnit_Code *common.TimeUnitCode `json:"intervalUnit_code" gorm:"size:10"`
|
||||
Duration *uint `json:"duration"`
|
||||
DurationUnit_Code *common.TimeUnitCode `json:"durationUnit_code" gorm:"size:10"`
|
||||
Anamnesis *string `json:"anamnesis" gorm:"size:2048"`
|
||||
MedicalDiagnoses *string `json:"medicalDiagnoses"`
|
||||
FunctionDiagnoses *string `json:"functionDiagnoses"`
|
||||
Procedures *string `json:"procedures"`
|
||||
SupportingExams *string `json:"supportingExams" gorm:"size:2048"`
|
||||
Instruction *string `json:"instruction" gorm:"size:2048"`
|
||||
Evaluation *string `json:"evaluation" gorm:"size:2048"`
|
||||
WorkCauseStatus *string `json:"workCauseStatus" gorm:"size:2048"`
|
||||
Frequency *uint `json:"frequency"`
|
||||
IntervalUnit_Code *common.TimeUnitCode `json:"intervalUnit_code" gorm:"size:10"`
|
||||
Duration *uint `json:"duration"`
|
||||
DurationUnit_Code *common.TimeUnitCode `json:"durationUnit_code" gorm:"size:10"`
|
||||
Status_Code *common.DataVerifiedCode `json:"status_code" gorm:"size:10"`
|
||||
}
|
||||
|
||||
func (d TherapyProtocol) IsNew() bool {
|
||||
return d.Status_Code != nil && *d.Status_Code == common.DVCNew
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package division
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
type DivisionLink struct {
|
||||
ecore.Main
|
||||
Simx_Id uint `json:"simx_id" gorm:"unique"`
|
||||
Simgos_Id uint `json:"simgos_id" gorm:"unique"`
|
||||
}
|
||||
|
||||
type DivisionSimxLog struct {
|
||||
ecore.Main
|
||||
Value *string `json:"value"`
|
||||
Date *time.Time `json:"date"`
|
||||
Status erc.ProcessStatusCode `json:"status"`
|
||||
ErrMessage *string `json:"errMessage"`
|
||||
}
|
||||
|
||||
type DivisionSimgosLog struct {
|
||||
ecore.Main
|
||||
Value *string `json:"value"`
|
||||
Date *time.Time `json:"date"`
|
||||
Status erc.ProcessStatusCode `json:"status"`
|
||||
ErrMessage *string `json:"errMessage"`
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package specialist
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SpecialistLink struct {
|
||||
ecore.Main
|
||||
Simx_Id uint `json:"simx_id" gorm:"unique"`
|
||||
Simgos_Id uint `json:"simgos_id" gorm:"unique"`
|
||||
}
|
||||
|
||||
type SpecialistSimxLog struct {
|
||||
ecore.Main
|
||||
Value *string `json:"value"`
|
||||
Date *time.Time `json:"date"`
|
||||
Status erc.ProcessStatusCode `json:"status"`
|
||||
ErrMessage *string `json:"errMessage"`
|
||||
}
|
||||
|
||||
type SpecialistSimgosLog struct {
|
||||
ecore.Main
|
||||
Value *string `json:"value"`
|
||||
Date *time.Time `json:"date"`
|
||||
Status erc.ProcessStatusCode `json:"status"`
|
||||
ErrMessage *string `json:"errMessage"`
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package subspecialist
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SubspecialistLink struct {
|
||||
ecore.Main
|
||||
Simx_Id uint `json:"simx_id" gorm:"unique"`
|
||||
Simgos_Id uint `json:"simgos_id" gorm:"unique"`
|
||||
}
|
||||
|
||||
type SubspecialistSimxLog struct {
|
||||
ecore.Main
|
||||
Value *string `json:"value"`
|
||||
Date *time.Time `json:"date"`
|
||||
Status erc.ProcessStatusCode `json:"status"`
|
||||
ErrMessage *string `json:"errMessage"`
|
||||
}
|
||||
|
||||
type SubspecialistSimgosLog struct {
|
||||
ecore.Main
|
||||
Value *string `json:"value"`
|
||||
Date *time.Time `json:"date"`
|
||||
Status erc.ProcessStatusCode `json:"status"`
|
||||
ErrMessage *string `json:"errMessage"`
|
||||
}
|
||||
@@ -152,7 +152,6 @@ func SetRoutes() http.Handler {
|
||||
hc.RegCrud(r, "/v1/prescription-item", prescriptionitem.O)
|
||||
hc.RegCrud(r, "/v1/device-order-item", deviceorderitem.O)
|
||||
hc.RegCrud(r, "/v1/material-order-item", materialorderitem.O)
|
||||
|
||||
hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": encounter.O.GetList,
|
||||
"GET /{id}": encounter.O.GetDetail,
|
||||
@@ -211,7 +210,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": medication.O.Delete,
|
||||
"PATCH /{id}/complete": medication.O.Complete,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/medication-item", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": medicationitem.O.GetList,
|
||||
"GET /{id}": medicationitem.O.GetDetail,
|
||||
@@ -220,7 +218,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": medicationitem.O.Delete,
|
||||
"PATCH /{id}/redeem": medicationitem.O.Redeem,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/medication-item-dist", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": medicationitemdist.O.GetList,
|
||||
"GET /{id}": medicationitemdist.O.GetDetail,
|
||||
@@ -229,7 +226,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": medicationitemdist.O.Delete,
|
||||
"PATCH /{id}/consume": medicationitemdist.O.Consume,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/device-order", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": deviceorder.O.GetList,
|
||||
"GET /{id}": deviceorder.O.GetDetail,
|
||||
@@ -238,7 +234,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": deviceorder.O.Delete,
|
||||
"PATCH /{id}/complete": deviceorder.O.Complete,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/material-order", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": materialorder.O.GetList,
|
||||
"GET /{id}": materialorder.O.GetDetail,
|
||||
@@ -247,7 +242,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": materialorder.O.Delete,
|
||||
"PATCH /{id}/complete": materialorder.O.Complete,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/consultation", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": consultation.O.GetList,
|
||||
"GET /{id}": consultation.O.GetDetail,
|
||||
@@ -256,7 +250,6 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": consultation.O.Delete,
|
||||
"PATCH /{id}/reply": consultation.O.Reply,
|
||||
})
|
||||
|
||||
hk.GroupRoutes("/v1/chemo", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": chemo.O.GetList,
|
||||
"GET /{id}": chemo.O.GetDetail,
|
||||
@@ -266,13 +259,20 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/verify": chemo.O.Verify,
|
||||
"PATCH /{id}/reject": chemo.O.Reject,
|
||||
})
|
||||
|
||||
hc.RegCrud(r, "/v1/control-letter", controlletter.O)
|
||||
hc.RegCrud(r, "/v1/internal-reference", internalreference.O)
|
||||
hc.RegCrud(r, "/v1/ambulance-transport-req", ambulancetransportrequest.O)
|
||||
hc.RegCrud(r, "/v1/responsible-doctor-hist", responsibledoctorhist.O)
|
||||
hc.RegCrud(r, "/v1/adm-employee-hist", admemployeehist.O)
|
||||
hc.RegCrud(r, "/v1/therapy-protocol", therapyprotocol.O)
|
||||
hk.GroupRoutes("/v1/therapy-protocol", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": therapyprotocol.O.GetList,
|
||||
"GET /{id}": therapyprotocol.O.GetDetail,
|
||||
"POST /": therapyprotocol.O.Create,
|
||||
"PATCH /{id}": therapyprotocol.O.Update,
|
||||
"DELETE /{id}": therapyprotocol.O.Delete,
|
||||
"PATCH /{id}/verify": therapyprotocol.O.Verify,
|
||||
"PATCH /{id}/reject": therapyprotocol.O.Reject,
|
||||
})
|
||||
hc.RegCrud(r, "/v1/chemo-protocol", chemoprotocol.O)
|
||||
hc.RegCrud(r, "/v1/upload", upload.O)
|
||||
hc.RegCrud(r, "/v1/encounter-document", encounterdocument.O)
|
||||
@@ -297,7 +297,6 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/active": user.O.Active,
|
||||
})
|
||||
hc.RegCrud(r, "/v1/user-fes", userfes.O)
|
||||
|
||||
hk.GroupRoutes("/v1/patient", r, hk.MapHandlerFunc{
|
||||
"GET /": patient.O.GetList,
|
||||
"GET /{id}": patient.O.GetDetail,
|
||||
|
||||
@@ -46,6 +46,7 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
dto.Id = uint(id)
|
||||
res, err := u.ReadDetail(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
|
||||
@@ -9,7 +9,12 @@ import (
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/therapy-protocol"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
u "simrs-vx/internal/use-case/main-use-case/therapy-protocol"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
@@ -71,3 +76,44 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Verify(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.VerifyDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
dto.Id = uint(id)
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
|
||||
dto.AuthInfo = *authInfo
|
||||
dto.Status_Code = erc.DVCVerified
|
||||
res, err := u.Verify(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Reject(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.VerifyDto{}
|
||||
dto.Id = uint(id)
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
dto.AuthInfo = *authInfo
|
||||
dto.Status_Code = erc.DVCRejected
|
||||
res, err := u.Verify(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func getEntities(input string) []any {
|
||||
case "satusehat":
|
||||
return getSatuSehatEntities()
|
||||
case "simgossync":
|
||||
return getSimgosSyncEntities()
|
||||
return getSyncEntities()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package migration
|
||||
|
||||
import (
|
||||
/************** Source ***************/
|
||||
division "simrs-vx/internal/domain/sync-entities/division"
|
||||
installation "simrs-vx/internal/domain/sync-entities/installation"
|
||||
specialist "simrs-vx/internal/domain/sync-entities/specialist"
|
||||
subspecialist "simrs-vx/internal/domain/sync-entities/subspecialist"
|
||||
unit "simrs-vx/internal/domain/sync-entities/unit"
|
||||
)
|
||||
|
||||
func getSimgosSyncEntities() []any {
|
||||
func getSyncEntities() []any {
|
||||
return []any{
|
||||
&installation.InstallationLink{},
|
||||
&installation.InstallationSimxLog{},
|
||||
@@ -14,5 +17,14 @@ func getSimgosSyncEntities() []any {
|
||||
&unit.UnitLink{},
|
||||
&unit.UnitSimxLog{},
|
||||
&unit.UnitSimgosLog{},
|
||||
&division.DivisionLink{},
|
||||
&division.DivisionSimxLog{},
|
||||
&division.DivisionSimgosLog{},
|
||||
&specialist.SpecialistLink{},
|
||||
&specialist.SpecialistSimxLog{},
|
||||
&specialist.SpecialistSimgosLog{},
|
||||
&subspecialist.SubspecialistLink{},
|
||||
&subspecialist.SubspecialistSimxLog{},
|
||||
&subspecialist.SubspecialistSimgosLog{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.DeviceOrderItem) {
|
||||
|
||||
data.DeviceOrder_Id = inputSrc.DeviceOrder_Id
|
||||
data.Device_Code = inputSrc.Device_Code
|
||||
data.Count = inputSrc.Count
|
||||
data.Quantity = inputSrc.Quantity
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Pr
|
||||
tx = dg.I
|
||||
}
|
||||
|
||||
tx = tx.
|
||||
tx = tx.Debug().
|
||||
Model(&e.PrescriptionItem{}).
|
||||
Scopes(gh.Preload(input.Includes)).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Order("\"CreatedAt\" DESC")
|
||||
Scopes(gh.Sort(input.Sort))
|
||||
|
||||
if err := tx.Find(&data).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package therapy_protocol
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -15,6 +16,8 @@ import (
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
e "simrs-vx/internal/domain/main-entities/therapy-protocol"
|
||||
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
|
||||
ud "simrs-vx/internal/use-case/main-use-case/doctor"
|
||||
ue "simrs-vx/internal/use-case/main-use-case/encounter"
|
||||
)
|
||||
@@ -45,6 +48,8 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
statusNew := erc.DVCNew
|
||||
input.Status_Code = &statusNew
|
||||
if resData, err := CreateData(input, &event, tx); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -291,6 +296,66 @@ func Delete(input e.DeleteDto) (*d.Data, error) {
|
||||
|
||||
}
|
||||
|
||||
func Verify(input e.VerifyDto) (*d.Data, error) {
|
||||
rdDto := e.ReadDetailDto{Id: input.Id}
|
||||
var data *e.TherapyProtocol
|
||||
var err error
|
||||
|
||||
event := pl.Event{
|
||||
Feature: "Verify",
|
||||
Source: source,
|
||||
}
|
||||
|
||||
// Start log
|
||||
pl.SetLogInfo(&event, input, "started", "verify")
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
if !data.IsNew() {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "data-state-mismatch",
|
||||
Detail: "data is not new",
|
||||
Raw: errors.New("data is not new"),
|
||||
}
|
||||
return pl.SetLogError(&event, input)
|
||||
}
|
||||
|
||||
data.Status_Code = &input.Status_Code
|
||||
err = tx.Save(&data).Error
|
||||
if 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
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &d.Data{
|
||||
Meta: d.IS{
|
||||
"source": source,
|
||||
"structure": "single-data",
|
||||
"status": "verify",
|
||||
},
|
||||
Data: data.ToResponse(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func validateForeignKey(input e.CreateDto) error {
|
||||
// validate encounter
|
||||
if input.Encounter_Id != nil {
|
||||
|
||||
Reference in New Issue
Block a user