feat/prescription: updated entities

This commit is contained in:
2025-11-13 17:27:59 +07:00
parent 96d4f55925
commit a552e51fa7
5 changed files with 93 additions and 1 deletions
@@ -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")
);
+2 -1
View File
@@ -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=
@@ -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
}
@@ -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"`
}
@@ -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 {
&ethnic.Ethnic{},
&insurancecompany.InsuranceCompany{},
&medicine.Medicine{},
&medicineform.MedicineForm{},
&medicinemix.MedicineMix{},
&medicinemixitem.MedicineMixItem{},
&medicalactionsrc.MedicalActionSrc{},