From f2bedd0de88d9506cd67bda027323e5141f40268 Mon Sep 17 00:00:00 2001 From: vanilia Date: Wed, 26 Nov 2025 18:56:30 +0700 Subject: [PATCH] add internalreference sync --- .../migrations/20251126115527.sql | 36 +++++++++++++++++++ .../migrations/atlas.sum | 7 ++-- .../internal-reference/entity.go | 29 +++++++++++++++ .../migration/simgossync-entities.go | 4 +++ 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 cmd/simgos-sync-migration/migrations/20251126115527.sql create mode 100644 internal/domain/sync-entities/internal-reference/entity.go diff --git a/cmd/simgos-sync-migration/migrations/20251126115527.sql b/cmd/simgos-sync-migration/migrations/20251126115527.sql new file mode 100644 index 00000000..49ca1e5c --- /dev/null +++ b/cmd/simgos-sync-migration/migrations/20251126115527.sql @@ -0,0 +1,36 @@ +-- Create "InternalReferenceLink" table +CREATE TABLE "public"."InternalReferenceLink" ( + "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_InternalReferenceLink_Simgos_Id" UNIQUE ("Simgos_Id"), + CONSTRAINT "uni_InternalReferenceLink_Simx_Id" UNIQUE ("Simx_Id") +); +-- Create "InternalReferenceSimgosLog" table +CREATE TABLE "public"."InternalReferenceSimgosLog" ( + "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 "InternalReferenceSimxLog" table +CREATE TABLE "public"."InternalReferenceSimxLog" ( + "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") +); diff --git a/cmd/simgos-sync-migration/migrations/atlas.sum b/cmd/simgos-sync-migration/migrations/atlas.sum index 07e5fbaf..497ac414 100644 --- a/cmd/simgos-sync-migration/migrations/atlas.sum +++ b/cmd/simgos-sync-migration/migrations/atlas.sum @@ -1,6 +1,7 @@ -h1:keVmwgYtvwxSqkq+7nB0BA25JFYRAVBpBBu5eA4Q9Hw= +h1:UdPzQZ17yyNN9HVuyrFFHj5KjLj4m6/e7s9frkdpQVU= 20251113035508.sql h1:rjDlu6yDdy5xv6nrCOr7NialrLSLT23pzduYNq29Hf0= 20251114071129.sql h1:Z0GQ5bJo3C+tplaWzxT8n3J9HLkEaVsRVp5nn7bmYow= 20251117041601.sql h1:l/RPG5mObqCSBjO4mzG+wTq2ieSycvlfOSz4czpUdWY= -20251118082246.sql h1:VFnYls2DBC8tJm2aw0iBcbWGLsKezYdOHJJV9iS7MjI= -20251118082915.sql h1:tAm67fXrH+8IJCjKbJroIqc1uQyqCnuGJnQtLmw7D20= +20251118082246.sql h1:xLUwA+EvKWIg3X/TJvu7rqbtBzONiINfag5NJpMV29E= +20251118082915.sql h1:hP6FmUVFuADIN2cDg2Z1l7Wx7PQRb+IYQDvKD7J8VAM= +20251126115527.sql h1:+2bp2nWTTqaPpKKfy5ZYSr6b1nEUXFG3tIw4r3OEnAQ= diff --git a/internal/domain/sync-entities/internal-reference/entity.go b/internal/domain/sync-entities/internal-reference/entity.go new file mode 100644 index 00000000..567e6489 --- /dev/null +++ b/internal/domain/sync-entities/internal-reference/entity.go @@ -0,0 +1,29 @@ +package internal_reference + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + erc "simrs-vx/internal/domain/references/common" + "time" +) + +type InternalReferenceLink struct { + ecore.Main + Simx_Id uint `json:"simx_id" gorm:"unique"` + Simgos_Id uint `json:"simgos_id" gorm:"unique"` +} + +type InternalReferenceSimxLog struct { + ecore.Main + Value *string `json:"value"` + Date *time.Time `json:"date"` + Status erc.ProcessStatusCode `json:"status"` + ErrMessage *string `json:"errMessage"` +} + +type InternalReferenceSimgosLog struct { + ecore.Main + Value *string `json:"value"` + Date *time.Time `json:"date"` + Status erc.ProcessStatusCode `json:"status"` + ErrMessage *string `json:"errMessage"` +} diff --git a/internal/interface/migration/simgossync-entities.go b/internal/interface/migration/simgossync-entities.go index b10c8607..7b37a842 100644 --- a/internal/interface/migration/simgossync-entities.go +++ b/internal/interface/migration/simgossync-entities.go @@ -5,6 +5,7 @@ import ( division "simrs-vx/internal/domain/sync-entities/division" encounter "simrs-vx/internal/domain/sync-entities/encounter" installation "simrs-vx/internal/domain/sync-entities/installation" + internalreference "simrs-vx/internal/domain/sync-entities/internal-reference" patient "simrs-vx/internal/domain/sync-entities/patient" specialist "simrs-vx/internal/domain/sync-entities/specialist" subspecialist "simrs-vx/internal/domain/sync-entities/subspecialist" @@ -34,5 +35,8 @@ func getSyncEntities() []any { &encounter.EncounterLink{}, &encounter.EncounterSimxLog{}, &encounter.EncounterSimgosLog{}, + &internalreference.InternalReferenceLink{}, + &internalreference.InternalReferenceSimxLog{}, + &internalreference.InternalReferenceSimgosLog{}, } }