From 70caef2602f4976c3f4184cd80af369d815619bb Mon Sep 17 00:00:00 2001 From: vanilia Date: Mon, 10 Nov 2025 08:55:01 +0700 Subject: [PATCH 1/7] adjustment new entity --- internal/use-case/main-use-case/ambulatory/helper.go | 1 - internal/use-case/main-use-case/rehab/helper.go | 1 - 2 files changed, 2 deletions(-) diff --git a/internal/use-case/main-use-case/ambulatory/helper.go b/internal/use-case/main-use-case/ambulatory/helper.go index a8a00e0d..912211c0 100644 --- a/internal/use-case/main-use-case/ambulatory/helper.go +++ b/internal/use-case/main-use-case/ambulatory/helper.go @@ -22,7 +22,6 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Ambulatory) { data.Encounter_Id = inputSrc.Encounter_Id data.Class_Code = inputSrc.Class_Code - data.VisitMode_Code = inputSrc.VisitMode_Code } func CheckClassCode(input *string) (ere.AmbulatoryClassCode, error) { diff --git a/internal/use-case/main-use-case/rehab/helper.go b/internal/use-case/main-use-case/rehab/helper.go index 5c06ca0a..c5774400 100644 --- a/internal/use-case/main-use-case/rehab/helper.go +++ b/internal/use-case/main-use-case/rehab/helper.go @@ -18,6 +18,5 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Rehab) { } data.Encounter_Id = inputSrc.Encounter_Id - data.Doctor_Id = inputSrc.Doctor_Id data.AllocatedVisitCount = inputSrc.AllocatedVisitCount } From f4268efc3fd756f24a44ced90ffe9fa2e8d87e9b Mon Sep 17 00:00:00 2001 From: vanilia Date: Mon, 10 Nov 2025 13:26:13 +0700 Subject: [PATCH 2/7] add encounter document --- .../main-entities/encounter-document/entity.go | 17 +++++++++++++++++ .../domain/main-entities/encounter/entity.go | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 internal/domain/main-entities/encounter-document/entity.go diff --git a/internal/domain/main-entities/encounter-document/entity.go b/internal/domain/main-entities/encounter-document/entity.go new file mode 100644 index 00000000..2aaec209 --- /dev/null +++ b/internal/domain/main-entities/encounter-document/entity.go @@ -0,0 +1,17 @@ +package encounter_document + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" +) + +type EncounterDocument struct { + ecore.Main + Encounter_Id *uint `json:"encounter_id"` + Name string `json:"name"` + DocumentType string `json:"documentType"` + FilePath *string `json:"filePath"` + FileName *string `json:"fileName"` + Upload_Employee_Id *string `json:"upload_employee_id"` + Upload_Employee *ee.Employee `json:"upload_employee,omitempty" gorm:"foreignKey:Upload_Employee_Id;references:Id"` +} diff --git a/internal/domain/main-entities/encounter/entity.go b/internal/domain/main-entities/encounter/entity.go index bfd70333..b62cd383 100644 --- a/internal/domain/main-entities/encounter/entity.go +++ b/internal/domain/main-entities/encounter/entity.go @@ -9,6 +9,7 @@ import ( ed "simrs-vx/internal/domain/main-entities/doctor" eem "simrs-vx/internal/domain/main-entities/emergency" ee "simrs-vx/internal/domain/main-entities/employee" + eed "simrs-vx/internal/domain/main-entities/encounter-document" eip "simrs-vx/internal/domain/main-entities/inpatient" ei "simrs-vx/internal/domain/main-entities/insurance-company" eir "simrs-vx/internal/domain/main-entities/internal-reference" @@ -70,6 +71,7 @@ type Encounter struct { Inpatient *eip.Inpatient `json:"inpatient,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` Rehab *er.Basic `json:"rehab,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` RehabChildren *[]er.Basic `json:"rehabChildren,omitempty" gorm:"foreignKey:Parent_Encounter_Id;references:Id"` + EncounterDocument *[]eed.EncounterDocument `json:"encounterDocument,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` } func (d Encounter) IsDone() bool { From d6426babaae3b0e96c329edeadfdda98fe598962 Mon Sep 17 00:00:00 2001 From: vanilia Date: Tue, 11 Nov 2025 15:37:52 +0700 Subject: [PATCH 3/7] update upload employee id --- cmd/main-migration/migrations/atlas.sum | 4 ++-- internal/domain/main-entities/file-attachment/entity.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index c29695a0..ceca9be1 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:l9TShSJKxWO7Ag2+PYB7DcVDd3pz/M2Sm0hpZYpUNBA= +h1:/ysf2SIdpKcuSzvAPNWONxzu08MCf8eE5krteU4Chas= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -108,4 +108,4 @@ h1:l9TShSJKxWO7Ag2+PYB7DcVDd3pz/M2Sm0hpZYpUNBA= 20251110093522.sql h1:nsz8jCxGjEdr/bz9g+4ozfZzIP803xONjVmucad1GMc= 20251110100258.sql h1:IBqt1VZj5WjQ+l9aAFGHOCCBtzb03KlLLihFLut7itg= 20251110100545.sql h1:6/LV7751iyKxE2xI6vO1zly+aHUwxXD/IBwLcVpKxqM= -20251111040358.sql h1:dbHqvkf0FWQVGpmTQAY0bdx6v2cXAxrPSH5byP0r/eU= +20251111040358.sql h1:c/RQSoA8yZl7cAcOv7n1RchmudPj7LdL3PEBdNvCUrA= diff --git a/internal/domain/main-entities/file-attachment/entity.go b/internal/domain/main-entities/file-attachment/entity.go index 8f224ce0..61b63e9e 100644 --- a/internal/domain/main-entities/file-attachment/entity.go +++ b/internal/domain/main-entities/file-attachment/entity.go @@ -14,6 +14,6 @@ type FileAttachment struct { Name string `json:"name"` FilePath *string `json:"filePath"` FileName *string `json:"fileName"` - Upload_Employee_Id *string `json:"upload_employee_id"` + Upload_Employee_Id *uint `json:"upload_employee_id"` Upload_Employee *ee.Employee `json:"upload_employee,omitempty" gorm:"foreignKey:Upload_Employee_Id;references:Id"` } From 9b7be9ca66fa9d492bba1449d908c59f48b5c159 Mon Sep 17 00:00:00 2001 From: vanilia Date: Tue, 11 Nov 2025 15:58:40 +0700 Subject: [PATCH 4/7] delete fk from encounter --- cmd/main-migration/migrations/20251111085815.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 3 ++- internal/domain/main-entities/encounter/entity.go | 2 -- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 cmd/main-migration/migrations/20251111085815.sql diff --git a/cmd/main-migration/migrations/20251111085815.sql b/cmd/main-migration/migrations/20251111085815.sql new file mode 100644 index 00000000..945c7329 --- /dev/null +++ b/cmd/main-migration/migrations/20251111085815.sql @@ -0,0 +1,2 @@ +-- Modify "FileAttachment" table +ALTER TABLE "public"."FileAttachment" DROP CONSTRAINT "fk_Encounter_FileAttachments"; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index ceca9be1..e1c7602d 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:/ysf2SIdpKcuSzvAPNWONxzu08MCf8eE5krteU4Chas= +h1:bPQtdFQustm+bzfbxrIgoD7sYhMS7+D4qaSmiyN6LUA= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -109,3 +109,4 @@ h1:/ysf2SIdpKcuSzvAPNWONxzu08MCf8eE5krteU4Chas= 20251110100258.sql h1:IBqt1VZj5WjQ+l9aAFGHOCCBtzb03KlLLihFLut7itg= 20251110100545.sql h1:6/LV7751iyKxE2xI6vO1zly+aHUwxXD/IBwLcVpKxqM= 20251111040358.sql h1:c/RQSoA8yZl7cAcOv7n1RchmudPj7LdL3PEBdNvCUrA= +20251111085815.sql h1:zY86Sl4p7yLEHvn9oJTjsK+yo5HfF4LsPa+uRHzsAeU= diff --git a/internal/domain/main-entities/encounter/entity.go b/internal/domain/main-entities/encounter/entity.go index dc7c2781..c9e9bb95 100644 --- a/internal/domain/main-entities/encounter/entity.go +++ b/internal/domain/main-entities/encounter/entity.go @@ -9,7 +9,6 @@ import ( ed "simrs-vx/internal/domain/main-entities/doctor" eem "simrs-vx/internal/domain/main-entities/emergency" ee "simrs-vx/internal/domain/main-entities/employee" - efa "simrs-vx/internal/domain/main-entities/file-attachment" eip "simrs-vx/internal/domain/main-entities/inpatient" ei "simrs-vx/internal/domain/main-entities/insurance-company" eir "simrs-vx/internal/domain/main-entities/internal-reference" @@ -71,7 +70,6 @@ type Encounter struct { Inpatient *eip.Inpatient `json:"inpatient,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` Rehab *er.Basic `json:"rehab,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` RehabChildren *[]er.Basic `json:"rehabChildren,omitempty" gorm:"foreignKey:Parent_Encounter_Id;references:Id"` - FileAttachments *[]efa.FileAttachment `json:"fileAttachments,omitempty" gorm:"foreignKey:Ref_Id;references:Id"` } func (d Encounter) IsDone() bool { From 62643ab6ce9df886c4016ba16123d930e622e8f6 Mon Sep 17 00:00:00 2001 From: vanilia Date: Tue, 11 Nov 2025 17:04:52 +0700 Subject: [PATCH 5/7] delete --- .../migrations/20251111040358.sql | 17 ----------------- .../migrations/20251111085815.sql | 2 -- 2 files changed, 19 deletions(-) delete mode 100644 cmd/main-migration/migrations/20251111040358.sql delete mode 100644 cmd/main-migration/migrations/20251111085815.sql diff --git a/cmd/main-migration/migrations/20251111040358.sql b/cmd/main-migration/migrations/20251111040358.sql deleted file mode 100644 index 8de43539..00000000 --- a/cmd/main-migration/migrations/20251111040358.sql +++ /dev/null @@ -1,17 +0,0 @@ --- Create "FileAttachment" table -CREATE TABLE "public"."FileAttachment" ( - "Id" bigserial NOT NULL, - "CreatedAt" timestamptz NULL, - "UpdatedAt" timestamptz NULL, - "DeletedAt" timestamptz NULL, - "EntityType_Code" text NULL, - "Ref_Id" bigint NULL, - "Type_Code" text NULL, - "Name" text NULL, - "FilePath" text NULL, - "FileName" text NULL, - "Upload_Employee_Id" bigint NULL, - PRIMARY KEY ("Id"), - CONSTRAINT "fk_Encounter_FileAttachments" FOREIGN KEY ("Ref_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, - CONSTRAINT "fk_FileAttachment_Upload_Employee" FOREIGN KEY ("Upload_Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION -); diff --git a/cmd/main-migration/migrations/20251111085815.sql b/cmd/main-migration/migrations/20251111085815.sql deleted file mode 100644 index 945c7329..00000000 --- a/cmd/main-migration/migrations/20251111085815.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Modify "FileAttachment" table -ALTER TABLE "public"."FileAttachment" DROP CONSTRAINT "fk_Encounter_FileAttachments"; From 34267255b68568ef3a8b52af3940fc7bd7b24b3f Mon Sep 17 00:00:00 2001 From: vanilia Date: Tue, 11 Nov 2025 17:19:39 +0700 Subject: [PATCH 6/7] update migration --- .../migrations/20251111100633.sql | 16 ++++ cmd/main-migration/migrations/atlas.sum | 79 ++++++++++--------- 2 files changed, 56 insertions(+), 39 deletions(-) create mode 100644 cmd/main-migration/migrations/20251111100633.sql diff --git a/cmd/main-migration/migrations/20251111100633.sql b/cmd/main-migration/migrations/20251111100633.sql new file mode 100644 index 00000000..73d12a54 --- /dev/null +++ b/cmd/main-migration/migrations/20251111100633.sql @@ -0,0 +1,16 @@ +-- Create "FileAttachment" table +CREATE TABLE "public"."FileAttachment" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "EntityType_Code" text NULL, + "Ref_Id" bigint NULL, + "Type_Code" text NULL, + "Name" text NULL, + "FilePath" text NULL, + "FileName" text NULL, + "Upload_Employee_Id" bigint NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_FileAttachment_Upload_Employee" FOREIGN KEY ("Upload_Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index fb7ec8eb..3e0a3ad9 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:3V3a/T/te8iQqsolgRAJKr99GePHgSN9miJHUNngJ74= +h1:SAwbbwLaFxoG+YGdeC3/EzQ+sb+CbZ4HEYhp5XOI918= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -75,41 +75,42 @@ h1:3V3a/T/te8iQqsolgRAJKr99GePHgSN9miJHUNngJ74= 20251106040137.sql h1:ppcqkVoT0o9jZcjI/TN7LuaPxXhJQhnIXEJtloP/46o= 20251106041333.sql h1:2JkxyelQ/EeB+boL5bfpnzefw32ttEGKvKchtQjWmAU= 20251106042006.sql h1:ruppYa1kAJQUU3ufQBbKGMcXrGbGJJiRPclT+dNc/YQ= -20251106050412.sql h1:MiEMJ1HCFYnalKuq3Z38xJeogfBAMqsTv2sG4EF8dDw= -20251106063418.sql h1:y3veDJPjKekOWLCZek/LgQwXPRhZtOppTfUXiqoL95s= -20251106071906.sql h1:/TUZA3XpMY23qEJXdkTwlzrNMvSSl6JJniPcgAttBaw= -20251106073157.sql h1:78txeibJ602DMD7huD618ZSMt6phSRzDNPTlo0PGyrc= -20251106074218.sql h1:8Xz7WywrtUnSxOHhlal53gG9rE7r86LFUt5zBFe/mIs= -20251106081846.sql h1:jp91Bf5bxGXMiUB1VIuN6y768vb2iWwow44WfCE5J5k= -20251106082844.sql h1:RHYzRO4G1fSWwf+xc/3QezZ/Iil67cZPIgNpNz3TNhQ= -20251106090021.sql h1:dFDk6mq+zjbYWmfWIrHf9DiKvvoXHjrr0++zssMTWP8= -20251106144745.sql h1:aHcr23iBFqCHer5D/SsPMXBCLjGqUYvWYfRU8jSJgIw= -20251107012049.sql h1:hu/7NHhnAkT4xK0RNtqmMDdH1Bo5EZbl7itDRjiCT+g= -20251107064812.sql h1:sfCXDQYnMf0ddrQ9oYljWJLLSt9NJjJV6o8VS3p7aZE= -20251107064937.sql h1:DlYGJ9LZFwZyR7jBP5zaGB128aIc4HAixBKPYCz9EkY= -20251107071420.sql h1:ynCdZAd2utLl+FhtWZwtahNXgIVOvuk3s/rOq7lfXA4= -20251107074318.sql h1:WE9cPhibWtZ0dbu1VEGirTeY6ijFYGMNhHdBtM32kOc= -20251107075050.sql h1:8tvneruqdynDOaJK1+0z4CH7YXZStZpGdqwIeOMLik4= -20251107080604.sql h1:8c4jd4Tql7tcdhbI9NS0tgvN+ADu9FnCf8wMUbmW7A0= -20251107081830.sql h1:SAAe3lmsm9vGXuSEsDdl7ad0EAxP5CMmFRDEgp9M7yY= -20251107091033.sql h1:JLdX/u7GUdBfjrPrMSNAqc8HtSoj0YA9iW9Vc6FJZdw= -20251107091209.sql h1:CzhYtwAwT+GHrbqcagnJE+v3mbl/rObf1IJaLCKlzrs= -20251107091541.sql h1:+3ZyWJTftDY2JeWThXuIxGWpUBnyMPyOyY4jBjdWYJI= -20251110012217.sql h1:f4Z8TuGc+XMSJ+Ekn4/PeHRE2FlHWkc5gKPJB0hAX7c= -20251110012306.sql h1:ENPyI6Kjdk6qKJQb0yJ6MCTDPAmO1WD/uhKuCSl+jYo= -20251110052049.sql h1:OrQ0acnyoQLKnTitZfnBcVr5jDslF59OFLaqT7SpdVs= -20251110062042.sql h1:9KwldQt0NpVPR86L0T4hlkfHAGau+7CiZYgu5rF+yhg= -20251110063202.sql h1:A117DuZmZ6U0jWHA3DISnr+yvBjKIr1ObrUr047YezQ= -20251110063633.sql h1:qTiC0F19JnhUIXF4LGJQ21jEV6kKGyhTr1x2kimFqPQ= -20251110085551.sql h1:HZcJM0RSC6HBaUSjKBE8MgDG8Vn9f3LmwA/OnT9Cp7I= -20251110091516.sql h1:W3AQhQLgirEWuCObbLl+Prdrbq6k6EEY1xcoWsmbog4= -20251110091948.sql h1:3tsITMrZr/T+L4wqUMz8sHS229jCJl4T0Nu3dMccxH8= -20251110092729.sql h1:uU+k88RH/e0Ns4/SmJl03RVYPscBAPuiLfxR6CJqaf0= -20251110093522.sql h1:O7upSj8VNjzvroL4IU59bfxKATOkAVGBArcUbVNq9aM= -20251110100258.sql h1://JSArUMNI3/gAtYDx2VN94C198SFW0ANjgs+p6eCRM= -20251110100545.sql h1:ENPOqeJYRpMI4e8VCKwaQgaql8se6pIidAhG2cjskBg= -20251111072601.sql h1:6p2qynJ2vr3C18peYciAbOIWOoj/+PnNcobU3wNHboQ= -20251111073546.sql h1:BORlFReAZTDLUfpS/eIf5qGkJ+FNznMGK47HRiPkfL8= -20251111074148.sql h1:qzjLGQRWo1Gg8LkJFgTb5Ak7h53tdz+eQrpJqC9+Gc0= -20251111074652.sql h1:uuThrt4wjdq4qEbvS67fF0Nfw/dlj7vGnLqywWBznqk= -20251111082257.sql h1:eUfu0tDtl9KqX7UK8is6Qc04NSQs4BXwKsykZwnVH1w= +20251106050412.sql h1:1002KYtHd8AwrQTMewbs/PPHDylHDghigE/3S7PVdMA= +20251106063418.sql h1:jPW/gBnbFl4RO39lQ0ZMDtYA6xbhyD6CgQupT50HmaY= +20251106071906.sql h1:leYGKxR3EQn794aOehf0sd/ZPmOnvBMZPy5/anGmRB4= +20251106073157.sql h1:KASMzjjjk5UB7Zj8lCRtM1utc4ZnDjlnpZbtTe3vONE= +20251106074218.sql h1:Z5q5deOvLaZDPhiVTN9st3/s56RepBa2YOyrMXBdj4A= +20251106081846.sql h1:P+VsWwhGt60adDIZuE/Aa38JVp/yX1rnsdpXpxASodw= +20251106082844.sql h1:Dmi5A8i9frQZvdXYPwc7f8CisZtBH8liSXq1rI6z1iM= +20251106090021.sql h1:4JwdKgO8T46YhyWVJUxpRIwudBDlG8QN1brSOYmgQ20= +20251106144745.sql h1:nqnQCzGrVJaq8ilOEOGXeRUL1dolj+OPWKuP8A92FRA= +20251107012049.sql h1:Pff4UqltGS3clSlGr0qq8CQM56L29wyxY0FC/N/YAhU= +20251107064812.sql h1:GB9a0ZfMYTIoGNmKUG+XcYUsTnRMFfT4/dAD71uCPc4= +20251107064937.sql h1:IC5pw1Ifj30hiE6dr5NMHXaSHoQI+vRd40N5ABgBHRI= +20251107071420.sql h1:9NO3iyLEXEtWa2kSRjM/8LyzuVIk6pdFL2SuheWjB08= +20251107074318.sql h1:7fHbSRrdjOmHh/xwnjCLwoiB5cW5zeH+uxLV0vZbkIA= +20251107075050.sql h1:np+3uTOnU9QNtK7Knaw8eRMhkyB9AwrtSNHphOBxbHY= +20251107080604.sql h1:cXDBLPJDVWLTG6yEJqkJsOQ7p7VYxLM2SY+mwO8qSHo= +20251107081830.sql h1:/S7OQZo4ZnK80t28g/JyiOTZtmWG/dP5Wg2zXNMQ/iE= +20251107091033.sql h1:/cbkF1nO/IjNSIfDJJx456KJtQ9rWFXOBFAkR/M2xiE= +20251107091209.sql h1:jrLQOUeV8ji2fg0pnEcs1bw4ANUxzTSMXC/rrHLIY+M= +20251107091541.sql h1:6UqbhQQRmzA2+eKu5lIvkwOkk+lH70QLZC8Pjpjcq68= +20251110012217.sql h1:C9HpX0iyHzKjyNv/5DSAn2MCHj6MX4p5UQ/NrY7QD0w= +20251110012306.sql h1:J54yb27d30LBbYp9n1P66gFVRlxPguKu0kxmWIBBG8g= +20251110052049.sql h1:232T2x8xTczJl9nk4jxJpZXhoOGYthhxjJ7nK8Jd8vg= +20251110062042.sql h1:WnfVUXrzYoj8qdkkjO9/JQQ8agGd4GfSHQdMjo7LDAg= +20251110063202.sql h1:hSzGfwVMWa6q3vwIQZUkxKgBNCzHjB+6GKy54zfV+oQ= +20251110063633.sql h1:/VpofIAqNS1CnazEnpW/+evbzn9Kew3xDW48r57M+Xg= +20251110085551.sql h1:bFZwSmfvVbTUr/enWB82WqjG88gpqcZ6s45btUvO0uo= +20251110091516.sql h1:KkJMwPQuaZQhiqnKrNQrgP12gw9rV8T3P2o3mtGTcvY= +20251110091948.sql h1:I4odAYrJdvNf1jPw6ppDC0XdI7v6vKBACg/ABwUgA7I= +20251110092729.sql h1:l1out8soEmVP6dNjaIOtGYo6QDcoJZRI8X1sjZ5ZGmo= +20251110093522.sql h1:nsz8jCxGjEdr/bz9g+4ozfZzIP803xONjVmucad1GMc= +20251110100258.sql h1:IBqt1VZj5WjQ+l9aAFGHOCCBtzb03KlLLihFLut7itg= +20251110100545.sql h1:6/LV7751iyKxE2xI6vO1zly+aHUwxXD/IBwLcVpKxqM= +20251111072601.sql h1:dEhwrkT0hJ06/YcvQd5alvdskimcHcYT27QKAzVY5+8= +20251111073546.sql h1:JnJZ4SdOObSe6Jf8v/i/KiRxoCz5KMeXCYytQMZgkZM= +20251111074148.sql h1:95Ui1eo1P68itOz5kZDNFi2ha0ZhUF4gMYiYVcip6fo= +20251111074652.sql h1:vUZbN0qgktRQ2GAlCpdYrbld2grPiSbvcMePEQMfxPs= +20251111082257.sql h1:Zr3Xg5n+p4C8F6Evqm5PVC0pqUvPTBcq692PiUEJlT8= +20251111100633.sql h1:0z4WE0KP18j10gCd7nCltnP6u4NcLNJD5k9vTjq7J50= From 4f07f7f2a44a8cd208dc07a157b3a15599bf1934 Mon Sep 17 00:00:00 2001 From: vanilia Date: Tue, 11 Nov 2025 18:10:50 +0700 Subject: [PATCH 7/7] adjustment fileattachemnt to encounterDocument --- .../migrations/20251111100633.sql | 16 ---------------- .../migrations/20251111111017.sql | 16 ++++++++++++++++ cmd/main-migration/migrations/atlas.sum | 4 ++-- .../encounter-document/entity.go | 18 ++++++++++++++++++ .../domain/main-entities/encounter/entity.go | 2 ++ .../main-entities/file-attachment/entity.go | 19 ------------------- internal/interface/migration/main-entities.go | 4 ++-- 7 files changed, 40 insertions(+), 39 deletions(-) delete mode 100644 cmd/main-migration/migrations/20251111100633.sql create mode 100644 cmd/main-migration/migrations/20251111111017.sql create mode 100644 internal/domain/main-entities/encounter-document/entity.go delete mode 100644 internal/domain/main-entities/file-attachment/entity.go diff --git a/cmd/main-migration/migrations/20251111100633.sql b/cmd/main-migration/migrations/20251111100633.sql deleted file mode 100644 index 73d12a54..00000000 --- a/cmd/main-migration/migrations/20251111100633.sql +++ /dev/null @@ -1,16 +0,0 @@ --- Create "FileAttachment" table -CREATE TABLE "public"."FileAttachment" ( - "Id" bigserial NOT NULL, - "CreatedAt" timestamptz NULL, - "UpdatedAt" timestamptz NULL, - "DeletedAt" timestamptz NULL, - "EntityType_Code" text NULL, - "Ref_Id" bigint NULL, - "Type_Code" text NULL, - "Name" text NULL, - "FilePath" text NULL, - "FileName" text NULL, - "Upload_Employee_Id" bigint NULL, - PRIMARY KEY ("Id"), - CONSTRAINT "fk_FileAttachment_Upload_Employee" FOREIGN KEY ("Upload_Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION -); diff --git a/cmd/main-migration/migrations/20251111111017.sql b/cmd/main-migration/migrations/20251111111017.sql new file mode 100644 index 00000000..4adcb5ac --- /dev/null +++ b/cmd/main-migration/migrations/20251111111017.sql @@ -0,0 +1,16 @@ +-- Create "EncounterDocument" table +CREATE TABLE "public"."EncounterDocument" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Encounter_Id" bigint NULL, + "Type_Code" text NULL, + "Name" text NULL, + "FilePath" text NULL, + "FileName" text NULL, + "Upload_Employee_Id" bigint NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_EncounterDocument_Upload_Employee" FOREIGN KEY ("Upload_Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_Encounter_EncounterDocuments" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 3e0a3ad9..6bdc5512 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:SAwbbwLaFxoG+YGdeC3/EzQ+sb+CbZ4HEYhp5XOI918= +h1:G7XwMRXjqZGaTeOozryI7WRd+FUJqE+DYsSfura7viU= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -113,4 +113,4 @@ h1:SAwbbwLaFxoG+YGdeC3/EzQ+sb+CbZ4HEYhp5XOI918= 20251111074148.sql h1:95Ui1eo1P68itOz5kZDNFi2ha0ZhUF4gMYiYVcip6fo= 20251111074652.sql h1:vUZbN0qgktRQ2GAlCpdYrbld2grPiSbvcMePEQMfxPs= 20251111082257.sql h1:Zr3Xg5n+p4C8F6Evqm5PVC0pqUvPTBcq692PiUEJlT8= -20251111100633.sql h1:0z4WE0KP18j10gCd7nCltnP6u4NcLNJD5k9vTjq7J50= +20251111111017.sql h1:RNLwrUNguAy/m2h3oYwMd5VuL1juRJMS1Taqujvye08= diff --git a/internal/domain/main-entities/encounter-document/entity.go b/internal/domain/main-entities/encounter-document/entity.go new file mode 100644 index 00000000..6c98e1e2 --- /dev/null +++ b/internal/domain/main-entities/encounter-document/entity.go @@ -0,0 +1,18 @@ +package encounter_document + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" + eru "simrs-vx/internal/domain/references/upload" +) + +type EncounterDocument struct { + ecore.Main + Encounter_Id *uint `json:"encounter_id"` + Type_Code eru.UploadCode `json:"type_code"` + Name string `json:"name"` + FilePath *string `json:"filePath"` + FileName *string `json:"fileName"` + Upload_Employee_Id *uint `json:"upload_employee_id"` + Upload_Employee *ee.Employee `json:"upload_employee,omitempty" gorm:"foreignKey:Upload_Employee_Id;references:Id"` +} diff --git a/internal/domain/main-entities/encounter/entity.go b/internal/domain/main-entities/encounter/entity.go index c9e9bb95..3939f546 100644 --- a/internal/domain/main-entities/encounter/entity.go +++ b/internal/domain/main-entities/encounter/entity.go @@ -9,6 +9,7 @@ import ( ed "simrs-vx/internal/domain/main-entities/doctor" eem "simrs-vx/internal/domain/main-entities/emergency" ee "simrs-vx/internal/domain/main-entities/employee" + eed "simrs-vx/internal/domain/main-entities/encounter-document" eip "simrs-vx/internal/domain/main-entities/inpatient" ei "simrs-vx/internal/domain/main-entities/insurance-company" eir "simrs-vx/internal/domain/main-entities/internal-reference" @@ -70,6 +71,7 @@ type Encounter struct { Inpatient *eip.Inpatient `json:"inpatient,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` Rehab *er.Basic `json:"rehab,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` RehabChildren *[]er.Basic `json:"rehabChildren,omitempty" gorm:"foreignKey:Parent_Encounter_Id;references:Id"` + EncounterDocuments *[]eed.EncounterDocument `json:"encounterDocuments,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` } func (d Encounter) IsDone() bool { diff --git a/internal/domain/main-entities/file-attachment/entity.go b/internal/domain/main-entities/file-attachment/entity.go deleted file mode 100644 index 61b63e9e..00000000 --- a/internal/domain/main-entities/file-attachment/entity.go +++ /dev/null @@ -1,19 +0,0 @@ -package file_attachment - -import ( - ecore "simrs-vx/internal/domain/base-entities/core" - ee "simrs-vx/internal/domain/main-entities/employee" - eru "simrs-vx/internal/domain/references/upload" -) - -type FileAttachment struct { - ecore.Main - EntityType_Code eru.EntityTypeCode `json:"entityType_code"` - Ref_Id *uint `json:"ref_id"` - Type_Code eru.UploadCode `json:"type_code"` - Name string `json:"name"` - FilePath *string `json:"filePath"` - FileName *string `json:"fileName"` - Upload_Employee_Id *uint `json:"upload_employee_id"` - Upload_Employee *ee.Employee `json:"upload_employee,omitempty" gorm:"foreignKey:Upload_Employee_Id;references:Id"` -} diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index a88ef64f..272cd4ce 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -28,8 +28,8 @@ import ( emergency "simrs-vx/internal/domain/main-entities/emergency" employee "simrs-vx/internal/domain/main-entities/employee" encounter "simrs-vx/internal/domain/main-entities/encounter" + fileattachemnt "simrs-vx/internal/domain/main-entities/encounter-document" ethnic "simrs-vx/internal/domain/main-entities/ethnic" - fileattachemnt "simrs-vx/internal/domain/main-entities/file-attachment" generalconsent "simrs-vx/internal/domain/main-entities/general-consent" infra "simrs-vx/internal/domain/main-entities/infra" inpatient "simrs-vx/internal/domain/main-entities/inpatient" @@ -208,6 +208,6 @@ func getMainEntities() []any { &controlletter.ControlLetter{}, &rehab.Rehab{}, &chemoprotocol.ChemoProtocol{}, - &fileattachemnt.FileAttachment{}, + &fileattachemnt.EncounterDocument{}, } }