From a552e51fa7506fae96aa254d24fc14c5f4dca9ae Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Thu, 13 Nov 2025 17:27:59 +0700 Subject: [PATCH] feat/prescription: updated entities --- .../migrations/20251113101344.sql | 11 +++ cmd/main-migration/migrations/atlas.sum | 3 +- .../domain/main-entities/medicine-form/dto.go | 67 +++++++++++++++++++ .../main-entities/medicine-form/entity.go | 11 +++ internal/interface/migration/main-entities.go | 2 + 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 cmd/main-migration/migrations/20251113101344.sql create mode 100644 internal/domain/main-entities/medicine-form/dto.go create mode 100644 internal/domain/main-entities/medicine-form/entity.go diff --git a/cmd/main-migration/migrations/20251113101344.sql b/cmd/main-migration/migrations/20251113101344.sql new file mode 100644 index 00000000..cda3abed --- /dev/null +++ b/cmd/main-migration/migrations/20251113101344.sql @@ -0,0 +1,11 @@ +-- Create "MedicineForm" table +CREATE TABLE "public"."MedicineForm" ( + "Id" serial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Code" character varying(20) NULL, + "Name" character varying(50) NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_MedicineForm_Code" UNIQUE ("Code") +); diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 8c3dedc2..12fe7e83 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:eTC10wvsOLnENRLwgViQvRs0NYu3w94Ah1fOaGCqFEg= +h1:6WOy+P2ZTzKcl82qh91tJo8GQlP7SQq7ijFoGqOnC14= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -115,3 +115,4 @@ h1:eTC10wvsOLnENRLwgViQvRs0NYu3w94Ah1fOaGCqFEg= 20251111074652.sql h1:ddfQ/sRKMezPM75xBFTGytUQX5AwZ3znrJVpg73gKPA= 20251111082257.sql h1:ZsdLY1ROouos0l3oS0lkeSiuKLEUGbVvBhpcM2AVhkw= 20251111111017.sql h1:qrJ93dNtQwcuAvpsP/lAK/H63C4cinXrsVaPmWsTqkU= +20251113101344.sql h1:oG4MVNBSZ5CiFS3CfhoLr5oqBFIGwhLo+QiVcZ6W25A= diff --git a/internal/domain/main-entities/medicine-form/dto.go b/internal/domain/main-entities/medicine-form/dto.go new file mode 100644 index 00000000..a7145a2f --- /dev/null +++ b/internal/domain/main-entities/medicine-form/dto.go @@ -0,0 +1,67 @@ +package medicineform + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" +) + +type CreateDto struct { + Code *string `json:"code" validate:"maxLength=20"` + Name string `json:"name" validate:"maxLength=50"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Sort string `json:"sort"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Code string `json:"code"` + Name string `json:"name"` + Search string `json:"search" gormhelper:"searchColumns=Code,Name"` +} + +type ReadDetailDto struct { + Id *uint16 `json:"id"` + Code *string `json:"code"` +} + +type UpdateDto struct { + Id *uint `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id *uint `json:"id"` + Code *string `json:"code"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.SmallMain + Code string `json:"code"` + Name string `json:"name"` +} + +func (d MedicineForm) ToResponse() ResponseDto { + resp := ResponseDto{ + Code: d.Code, + Name: d.Name, + } + resp.SmallMain = d.SmallMain + return resp +} + +func ToResponseList(data []MedicineForm) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/medicine-form/entity.go b/internal/domain/main-entities/medicine-form/entity.go new file mode 100644 index 00000000..75b1b104 --- /dev/null +++ b/internal/domain/main-entities/medicine-form/entity.go @@ -0,0 +1,11 @@ +package medicineform + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" +) + +type MedicineForm struct { + ecore.SmallMain // adjust this according to the needs + Code string `json:"code" gorm:"unique;size:20"` + Name string `json:"name" gorm:"size:50"` +} diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 272cd4ce..94b5d545 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -57,6 +57,7 @@ import ( medicationitem "simrs-vx/internal/domain/main-entities/medication-item" medicationitemdist "simrs-vx/internal/domain/main-entities/medication-item-dist" medicine "simrs-vx/internal/domain/main-entities/medicine" + medicineform "simrs-vx/internal/domain/main-entities/medicine-form" medicinegroup "simrs-vx/internal/domain/main-entities/medicine-group" medicinemethod "simrs-vx/internal/domain/main-entities/medicine-method" medicinemix "simrs-vx/internal/domain/main-entities/medicine-mix" @@ -145,6 +146,7 @@ func getMainEntities() []any { ðnic.Ethnic{}, &insurancecompany.InsuranceCompany{}, &medicine.Medicine{}, + &medicineform.MedicineForm{}, &medicinemix.MedicineMix{}, &medicinemixitem.MedicineMixItem{}, &medicalactionsrc.MedicalActionSrc{},