From 12108e11764cc299388650a10dea8493dbd93357 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Fri, 14 Nov 2025 13:43:27 +0700 Subject: [PATCH 1/9] add status code therapy protocol --- .../migrations/20251114062746.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 5 ++-- .../main-entities/therapy-protocol/entity.go | 25 ++++++++++--------- 3 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 cmd/main-migration/migrations/20251114062746.sql diff --git a/cmd/main-migration/migrations/20251114062746.sql b/cmd/main-migration/migrations/20251114062746.sql new file mode 100644 index 00000000..cdcfb350 --- /dev/null +++ b/cmd/main-migration/migrations/20251114062746.sql @@ -0,0 +1,2 @@ +-- Modify "TherapyProtocol" table +ALTER TABLE "public"."TherapyProtocol" ADD COLUMN "Status_Code" character varying(10) NULL; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 1c172e0c..d2484ac6 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:RvRW5FTVb8Zdn/J5rSwIrXB7cbCmWJBNaVsxqArNl4E= +h1:ZxTxK8LgNDXKTGBTF9olozXM0T7DDjK1+OJiwUwomeY= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -116,4 +116,5 @@ h1:RvRW5FTVb8Zdn/J5rSwIrXB7cbCmWJBNaVsxqArNl4E= 20251111082257.sql h1:ZsdLY1ROouos0l3oS0lkeSiuKLEUGbVvBhpcM2AVhkw= 20251111111017.sql h1:qrJ93dNtQwcuAvpsP/lAK/H63C4cinXrsVaPmWsTqkU= 20251113101344.sql h1:xaOZvAUP1fFfnO+syEFOzJUIg5lTfBe5AWHPbBWuCLA= -20251113120533.sql h1:MOk7YBwVLRCoqgPrC/mQAarp5WRl4aTk6NAzIoQPMNc= +20251113120533.sql h1:f3/U1Ve2yF2zSMhkt+xtwF8wUYfUKYwgbNeGfE37EW4= +20251114062746.sql h1:4ypWL0cP2AUJLVHhPKo3GAQ7uqolL6F8o4nUW32KnCI= diff --git a/internal/domain/main-entities/therapy-protocol/entity.go b/internal/domain/main-entities/therapy-protocol/entity.go index 7caaf0a6..1378eb25 100644 --- a/internal/domain/main-entities/therapy-protocol/entity.go +++ b/internal/domain/main-entities/therapy-protocol/entity.go @@ -16,16 +16,17 @@ 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"` } From b51606b408db18ed9e39ebac99ac69bae01f069e Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Fri, 14 Nov 2025 13:45:20 +0700 Subject: [PATCH 2/9] add makefile command --- cmd/main-migration/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/main-migration/Makefile b/cmd/main-migration/Makefile index f445a815..a93bb244 100644 --- a/cmd/main-migration/Makefile +++ b/cmd/main-migration/Makefile @@ -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 \ No newline at end of file From d03c1c7a93093e4eebe56a356343fb96d82d9946 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Fri, 14 Nov 2025 14:16:07 +0700 Subject: [PATCH 3/9] feat (therapy-protocol): add verification --- .../main-entities/therapy-protocol/dto.go | 74 +++++++++++-------- .../main-entities/therapy-protocol/entity.go | 4 + .../interface/main-handler/main-handler.go | 19 +++-- .../main-handler/therapy-protocol/handler.go | 46 ++++++++++++ .../main-use-case/therapy-protocol/case.go | 65 ++++++++++++++++ 5 files changed, 167 insertions(+), 41 deletions(-) diff --git a/internal/domain/main-entities/therapy-protocol/dto.go b/internal/domain/main-entities/therapy-protocol/dto.go index 40633b89..a1d311dc 100644 --- a/internal/domain/main-entities/therapy-protocol/dto.go +++ b/internal/domain/main-entities/therapy-protocol/dto.go @@ -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 diff --git a/internal/domain/main-entities/therapy-protocol/entity.go b/internal/domain/main-entities/therapy-protocol/entity.go index 1378eb25..e7607eea 100644 --- a/internal/domain/main-entities/therapy-protocol/entity.go +++ b/internal/domain/main-entities/therapy-protocol/entity.go @@ -30,3 +30,7 @@ type TherapyProtocol struct { 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 +} diff --git a/internal/interface/main-handler/main-handler.go b/internal/interface/main-handler/main-handler.go index a06c5c18..aa6f76fb 100644 --- a/internal/interface/main-handler/main-handler.go +++ b/internal/interface/main-handler/main-handler.go @@ -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, diff --git a/internal/interface/main-handler/therapy-protocol/handler.go b/internal/interface/main-handler/therapy-protocol/handler.go index 2d9efc3b..769e5677 100644 --- a/internal/interface/main-handler/therapy-protocol/handler.go +++ b/internal/interface/main-handler/therapy-protocol/handler.go @@ -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) +} diff --git a/internal/use-case/main-use-case/therapy-protocol/case.go b/internal/use-case/main-use-case/therapy-protocol/case.go index bc65325f..ed4f3a21 100644 --- a/internal/use-case/main-use-case/therapy-protocol/case.go +++ b/internal/use-case/main-use-case/therapy-protocol/case.go @@ -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 { From 12abbfa41a35e0de1babc47ed9a6c8e74d834bfe Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 14 Nov 2025 14:19:14 +0700 Subject: [PATCH 4/9] migration from server --- cmd/main-migration/migrations/atlas.sum | 88 ++++++++++++------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index d2484ac6..cac4826e 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:ZxTxK8LgNDXKTGBTF9olozXM0T7DDjK1+OJiwUwomeY= +h1:t3DFzssEf9liKwykDE17fo19llwCgpTgEuSUd9VGusk= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -75,46 +75,46 @@ h1:ZxTxK8LgNDXKTGBTF9olozXM0T7DDjK1+OJiwUwomeY= 20251106040137.sql h1:ppcqkVoT0o9jZcjI/TN7LuaPxXhJQhnIXEJtloP/46o= 20251106041333.sql h1:2JkxyelQ/EeB+boL5bfpnzefw32ttEGKvKchtQjWmAU= 20251106042006.sql h1:ruppYa1kAJQUU3ufQBbKGMcXrGbGJJiRPclT+dNc/YQ= -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= -20251110155448.sql h1:kFPobJB+cpflsXBAWUwy3lohuWvrb/VRlXnhJWl7i3Y= -20251111072601.sql h1:ch8F+yVhsSM5xY+TwMLY3PxdLa4Wuhtj76oyw79R7Js= -20251111073546.sql h1:cCv0NPscADAOBahRVqtDWFs6G2t7n+4a+RwlF8vk/c4= -20251111074148.sql h1:70TsV83u1gQ5TktI13K7NQiyCCa35Td2aR6CNtKUa4U= -20251111074652.sql h1:ddfQ/sRKMezPM75xBFTGytUQX5AwZ3znrJVpg73gKPA= -20251111082257.sql h1:ZsdLY1ROouos0l3oS0lkeSiuKLEUGbVvBhpcM2AVhkw= -20251111111017.sql h1:qrJ93dNtQwcuAvpsP/lAK/H63C4cinXrsVaPmWsTqkU= -20251113101344.sql h1:xaOZvAUP1fFfnO+syEFOzJUIg5lTfBe5AWHPbBWuCLA= -20251113120533.sql h1:f3/U1Ve2yF2zSMhkt+xtwF8wUYfUKYwgbNeGfE37EW4= -20251114062746.sql h1:4ypWL0cP2AUJLVHhPKo3GAQ7uqolL6F8o4nUW32KnCI= +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= +20251110155448.sql h1:VW9KE0jxWy4flZ28sdXmhY6JWd6eKAX/cVL8KWRVii4= +20251111072601.sql h1:99WWzGjcDDFNC2cHRfPu4MBLWNrgPMY5HAYUbmIcVRA= +20251111073546.sql h1:iIGwFNfUgStdczw/PXTH3SD84xAyxrbZICofc3M8TMk= +20251111074148.sql h1:mzkezSKwCV2bTZ/0BHiTCX5qAy4uHpwar1xzwAH15Ko= +20251111074652.sql h1:lYh4/3BHV24pgPC0pP4RUKb+XtL/6AsZGPItRpnzBiQ= +20251111082257.sql h1:+cIZ1lf8HYGSL6t6U88plLKk8nOO1YVdV7h3YOM84ds= +20251111111017.sql h1:xzlhR2xLfOj4ddYlesS+bpEeDrxiAf5ILNOspsbZjBU= +20251113101344.sql h1:vSzThY3p6XYTj0dJ2uFVkHmlytyrFAnGE58CJLx364I= +20251113120533.sql h1:lfjgdqRGo/EohrVw8sWlFbDjh3ASTsfQ6pr3qjafqvc= +20251114062746.sql h1:6DLYjfJ60PkAABZTXvOwSE+xrU25oyoX7gpYlBnA9cw= From c19965f4c31a11e3ff3c5826cd8857dfd1b363b2 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Sat, 15 Nov 2025 01:16:21 +0700 Subject: [PATCH 5/9] feat/things-munaja: device order items preload --- .../device-order-item/base/entity.go | 14 ++++++++++++++ .../main-entities/device-order-item/entity.go | 11 +++-------- .../domain/main-entities/device-order/entity.go | 15 ++++++++------- 3 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 internal/domain/main-entities/device-order-item/base/entity.go diff --git a/internal/domain/main-entities/device-order-item/base/entity.go b/internal/domain/main-entities/device-order-item/base/entity.go new file mode 100644 index 00000000..54cbe611 --- /dev/null +++ b/internal/domain/main-entities/device-order-item/base/entity.go @@ -0,0 +1,14 @@ +package base + +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"` + Count uint8 `json:"count"` +} diff --git a/internal/domain/main-entities/device-order-item/entity.go b/internal/domain/main-entities/device-order-item/entity.go index 27197125..a0743643 100644 --- a/internal/domain/main-entities/device-order-item/entity.go +++ b/internal/domain/main-entities/device-order-item/entity.go @@ -1,16 +1,11 @@ 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"` + eb.DeviceOrderItem + DeviceOrder *edo.DeviceOrder `json:"deviceOrder,omitempty" gorm:"foreignKey:DeviceOrder_Id;references:Id"` } diff --git a/internal/domain/main-entities/device-order/entity.go b/internal/domain/main-entities/device-order/entity.go index 7ff4fa34..d9ba5a59 100644 --- a/internal/domain/main-entities/device-order/entity.go +++ b/internal/domain/main-entities/device-order/entity.go @@ -2,19 +2,20 @@ package deviceorder import ( 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 { From 03210549bb470c260f0d6d0257bac5bb9f147fe3 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Mon, 17 Nov 2025 07:57:22 +0700 Subject: [PATCH 6/9] feat/things-munaja: adjust prescription --- .../prescription-item/base/entity.go | 25 +++++++++++++++++++ .../main-entities/prescription-item/dto.go | 1 + .../main-entities/prescription-item/entity.go | 22 +++------------- .../domain/main-entities/prescription/dto.go | 15 ++++++----- .../main-entities/prescription/entity.go | 16 ++++++------ .../main-handler/prescription/handler.go | 1 + .../main-use-case/prescription-item/lib.go | 4 +-- 7 files changed, 51 insertions(+), 33 deletions(-) create mode 100644 internal/domain/main-entities/prescription-item/base/entity.go diff --git a/internal/domain/main-entities/prescription-item/base/entity.go b/internal/domain/main-entities/prescription-item/base/entity.go new file mode 100644 index 00000000..a5cb5c44 --- /dev/null +++ b/internal/domain/main-entities/prescription-item/base/entity.go @@ -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"` +} diff --git a/internal/domain/main-entities/prescription-item/dto.go b/internal/domain/main-entities/prescription-item/dto.go index 6e871428..44619ec8 100644 --- a/internal/domain/main-entities/prescription-item/dto.go +++ b/internal/domain/main-entities/prescription-item/dto.go @@ -27,6 +27,7 @@ type ReadListDto struct { FilterDto Includes string `json:"includes"` Pagination ecore.Pagination + Sort string `json:"sort"` } type FilterDto struct { diff --git a/internal/domain/main-entities/prescription-item/entity.go b/internal/domain/main-entities/prescription-item/entity.go index 93174079..465059d7 100644 --- a/internal/domain/main-entities/prescription-item/entity.go +++ b/internal/domain/main-entities/prescription-item/entity.go @@ -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"` } diff --git a/internal/domain/main-entities/prescription/dto.go b/internal/domain/main-entities/prescription/dto.go index 9c73c0ee..7c4040fa 100644 --- a/internal/domain/main-entities/prescription/dto.go +++ b/internal/domain/main-entities/prescription/dto.go @@ -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 diff --git a/internal/domain/main-entities/prescription/entity.go b/internal/domain/main-entities/prescription/entity.go index 8c879b29..f7cc3597 100644 --- a/internal/domain/main-entities/prescription/entity.go +++ b/internal/domain/main-entities/prescription/entity.go @@ -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 { diff --git a/internal/interface/main-handler/prescription/handler.go b/internal/interface/main-handler/prescription/handler.go index 30d5998e..c7649d34 100644 --- a/internal/interface/main-handler/prescription/handler.go +++ b/internal/interface/main-handler/prescription/handler.go @@ -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) diff --git a/internal/use-case/main-use-case/prescription-item/lib.go b/internal/use-case/main-use-case/prescription-item/lib.go index aa6f97bf..aa5c9e2b 100644 --- a/internal/use-case/main-use-case/prescription-item/lib.go +++ b/internal/use-case/main-use-case/prescription-item/lib.go @@ -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 { From 65f5c6dc20229fc85d649489a7b055ce10495476 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Mon, 17 Nov 2025 07:58:22 +0700 Subject: [PATCH 7/9] feat/things-munaja: adjust DeviceOrder --- .../device-order-item/base/entity.go | 4 ++-- .../main-entities/device-order-item/dto.go | 10 +++++----- .../main-entities/device-order-item/entity.go | 2 ++ .../domain/main-entities/device-order/dto.go | 13 ++++++++----- .../domain/main-entities/device-order/entity.go | 17 +++++++++-------- .../main-use-case/device-order-item/helper.go | 2 +- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/internal/domain/main-entities/device-order-item/base/entity.go b/internal/domain/main-entities/device-order-item/base/entity.go index 54cbe611..95eaa895 100644 --- a/internal/domain/main-entities/device-order-item/base/entity.go +++ b/internal/domain/main-entities/device-order-item/base/entity.go @@ -1,4 +1,4 @@ -package base +package deviceorderitem import ( ecore "simrs-vx/internal/domain/base-entities/core" @@ -10,5 +10,5 @@ type DeviceOrderItem struct { DeviceOrder_Id *uint `json:"deviceOrder_id"` Device_Code *string `json:"device_code"` Device *ed.Device `json:"device,omitempty" gorm:"foreignKey:Device_Code;references:Code"` - Count uint8 `json:"count"` + Quantity uint8 `json:"quantity"` } diff --git a/internal/domain/main-entities/device-order-item/dto.go b/internal/domain/main-entities/device-order-item/dto.go index afa08ed8..4464c91d 100644 --- a/internal/domain/main-entities/device-order-item/dto.go +++ b/internal/domain/main-entities/device-order-item/dto.go @@ -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 diff --git a/internal/domain/main-entities/device-order-item/entity.go b/internal/domain/main-entities/device-order-item/entity.go index a0743643..f214ec6a 100644 --- a/internal/domain/main-entities/device-order-item/entity.go +++ b/internal/domain/main-entities/device-order-item/entity.go @@ -1,11 +1,13 @@ package deviceorderitem import ( + ecore "simrs-vx/internal/domain/base-entities/core" 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 eb.DeviceOrderItem DeviceOrder *edo.DeviceOrder `json:"deviceOrder,omitempty" gorm:"foreignKey:DeviceOrder_Id;references:Id"` } diff --git a/internal/domain/main-entities/device-order/dto.go b/internal/domain/main-entities/device-order/dto.go index 6371800c..cdff2a18 100644 --- a/internal/domain/main-entities/device-order/dto.go +++ b/internal/domain/main-entities/device-order/dto.go @@ -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 diff --git a/internal/domain/main-entities/device-order/entity.go b/internal/domain/main-entities/device-order/entity.go index d9ba5a59..7ed304e5 100644 --- a/internal/domain/main-entities/device-order/entity.go +++ b/internal/domain/main-entities/device-order/entity.go @@ -1,21 +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"` - Items []*edoi.DeviceOrderItem `json:"items" gorm:"foreignKey:DeviceOrder_Id;references:Id"` + 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 { diff --git a/internal/use-case/main-use-case/device-order-item/helper.go b/internal/use-case/main-use-case/device-order-item/helper.go index 8c0be91f..6f3f7ce8 100644 --- a/internal/use-case/main-use-case/device-order-item/helper.go +++ b/internal/use-case/main-use-case/device-order-item/helper.go @@ -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 } From 712de2fdb02190669728fd8fab516d162320ce81 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Mon, 17 Nov 2025 08:00:04 +0700 Subject: [PATCH 8/9] feat/things-munaja: migration --- .../migrations/20251117005942.sql | 2 + cmd/main-migration/migrations/atlas.sum | 89 ++++++++++--------- 2 files changed, 47 insertions(+), 44 deletions(-) create mode 100644 cmd/main-migration/migrations/20251117005942.sql diff --git a/cmd/main-migration/migrations/20251117005942.sql b/cmd/main-migration/migrations/20251117005942.sql new file mode 100644 index 00000000..84a34010 --- /dev/null +++ b/cmd/main-migration/migrations/20251117005942.sql @@ -0,0 +1,2 @@ +-- Rename a column from "Count" to "Quantity" +ALTER TABLE "public"."DeviceOrderItem" RENAME COLUMN "Count" TO "Quantity"; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index cac4826e..a6e1b68c 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:t3DFzssEf9liKwykDE17fo19llwCgpTgEuSUd9VGusk= +h1:fNeqUpbdIqGDiH68u1bwwMgHTEOmmEWeI+IIYEq6pto= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -75,46 +75,47 @@ h1:t3DFzssEf9liKwykDE17fo19llwCgpTgEuSUd9VGusk= 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= -20251110155448.sql h1:VW9KE0jxWy4flZ28sdXmhY6JWd6eKAX/cVL8KWRVii4= -20251111072601.sql h1:99WWzGjcDDFNC2cHRfPu4MBLWNrgPMY5HAYUbmIcVRA= -20251111073546.sql h1:iIGwFNfUgStdczw/PXTH3SD84xAyxrbZICofc3M8TMk= -20251111074148.sql h1:mzkezSKwCV2bTZ/0BHiTCX5qAy4uHpwar1xzwAH15Ko= -20251111074652.sql h1:lYh4/3BHV24pgPC0pP4RUKb+XtL/6AsZGPItRpnzBiQ= -20251111082257.sql h1:+cIZ1lf8HYGSL6t6U88plLKk8nOO1YVdV7h3YOM84ds= -20251111111017.sql h1:xzlhR2xLfOj4ddYlesS+bpEeDrxiAf5ILNOspsbZjBU= -20251113101344.sql h1:vSzThY3p6XYTj0dJ2uFVkHmlytyrFAnGE58CJLx364I= -20251113120533.sql h1:lfjgdqRGo/EohrVw8sWlFbDjh3ASTsfQ6pr3qjafqvc= -20251114062746.sql h1:6DLYjfJ60PkAABZTXvOwSE+xrU25oyoX7gpYlBnA9cw= +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= +20251110155448.sql h1:kFPobJB+cpflsXBAWUwy3lohuWvrb/VRlXnhJWl7i3Y= +20251111072601.sql h1:ch8F+yVhsSM5xY+TwMLY3PxdLa4Wuhtj76oyw79R7Js= +20251111073546.sql h1:cCv0NPscADAOBahRVqtDWFs6G2t7n+4a+RwlF8vk/c4= +20251111074148.sql h1:70TsV83u1gQ5TktI13K7NQiyCCa35Td2aR6CNtKUa4U= +20251111074652.sql h1:ddfQ/sRKMezPM75xBFTGytUQX5AwZ3znrJVpg73gKPA= +20251111082257.sql h1:ZsdLY1ROouos0l3oS0lkeSiuKLEUGbVvBhpcM2AVhkw= +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= From 49c82c957e9183c0761a2f64bcbb18b81b4125ec Mon Sep 17 00:00:00 2001 From: vanilia Date: Mon, 17 Nov 2025 11:17:43 +0700 Subject: [PATCH 9/9] add entity sync for division, specialist and subspecialist --- .../migrations/20251117041601.sql | 108 ++++++++++++++++++ .../migrations/atlas.sum | 5 +- .../domain/sync-entities/division/entity.go | 29 +++++ .../domain/sync-entities/specialist/entity.go | 29 +++++ .../sync-entities/subspecialist/entity.go | 29 +++++ internal/interface/migration/migration.go | 2 +- .../migration/simgossync-entities.go | 14 ++- 7 files changed, 212 insertions(+), 4 deletions(-) create mode 100644 cmd/simgos-sync-migration/migrations/20251117041601.sql create mode 100644 internal/domain/sync-entities/division/entity.go create mode 100644 internal/domain/sync-entities/specialist/entity.go create mode 100644 internal/domain/sync-entities/subspecialist/entity.go diff --git a/cmd/simgos-sync-migration/migrations/20251117041601.sql b/cmd/simgos-sync-migration/migrations/20251117041601.sql new file mode 100644 index 00000000..7c33b155 --- /dev/null +++ b/cmd/simgos-sync-migration/migrations/20251117041601.sql @@ -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") +); diff --git a/cmd/simgos-sync-migration/migrations/atlas.sum b/cmd/simgos-sync-migration/migrations/atlas.sum index e8418ec2..30f8c5dc 100644 --- a/cmd/simgos-sync-migration/migrations/atlas.sum +++ b/cmd/simgos-sync-migration/migrations/atlas.sum @@ -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= diff --git a/internal/domain/sync-entities/division/entity.go b/internal/domain/sync-entities/division/entity.go new file mode 100644 index 00000000..9841c208 --- /dev/null +++ b/internal/domain/sync-entities/division/entity.go @@ -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"` +} diff --git a/internal/domain/sync-entities/specialist/entity.go b/internal/domain/sync-entities/specialist/entity.go new file mode 100644 index 00000000..0eb8683c --- /dev/null +++ b/internal/domain/sync-entities/specialist/entity.go @@ -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"` +} diff --git a/internal/domain/sync-entities/subspecialist/entity.go b/internal/domain/sync-entities/subspecialist/entity.go new file mode 100644 index 00000000..76e16614 --- /dev/null +++ b/internal/domain/sync-entities/subspecialist/entity.go @@ -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"` +} diff --git a/internal/interface/migration/migration.go b/internal/interface/migration/migration.go index 31ec1840..15341164 100644 --- a/internal/interface/migration/migration.go +++ b/internal/interface/migration/migration.go @@ -32,7 +32,7 @@ func getEntities(input string) []any { case "satusehat": return getSatuSehatEntities() case "simgossync": - return getSimgosSyncEntities() + return getSyncEntities() } return nil } diff --git a/internal/interface/migration/simgossync-entities.go b/internal/interface/migration/simgossync-entities.go index d48cf699..efc4cce9 100644 --- a/internal/interface/migration/simgossync-entities.go +++ b/internal/interface/migration/simgossync-entities.go @@ -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{}, } }