From 7a9784b4fb35c3ea64ceebd26af8f1c35623af89 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Mon, 1 Dec 2025 14:50:46 +0700 Subject: [PATCH 01/45] add therapy protocol template, not checked yet --- assets/docs/therapy-protocol-1.html | 312 ++++++++++++++++++++++++++++ assets/docs/therapy-protocol-2.html | 217 +++++++++++++++++++ assets/docs/therapy-protocol-3.html | 241 +++++++++++++++++++++ 3 files changed, 770 insertions(+) create mode 100644 assets/docs/therapy-protocol-1.html create mode 100644 assets/docs/therapy-protocol-2.html create mode 100644 assets/docs/therapy-protocol-3.html diff --git a/assets/docs/therapy-protocol-1.html b/assets/docs/therapy-protocol-1.html new file mode 100644 index 00000000..1e3949d8 --- /dev/null +++ b/assets/docs/therapy-protocol-1.html @@ -0,0 +1,312 @@ + + + + + General Consent + + + + + + + + + + +
+ logo + +
+ PEMERINTAH PROVINSI JAWA TIMUR +
+
+ RUMAH SAKIT UMUM DAERAH Dr. SAIFUL ANWAR +
+
+ TERAKREDITASI KARS VERSI 2012 TINGKAT PARIPURNA +
+
+ Jl. Jaksa Agung Suprapto No. 2 MALANG 65111 +
+
Telp. (0341) 362101, Fax. (0341) 362110
+
Email: rsu-drsaifulanwar@jatimprov.go.id
+
Website: www.rsudsaifulanwar.jatimprov.go.id
+
+ logo +
+ +
+ +
+

+ Protokol Terapi +

+

Layanan Kedokteran Fisik dan Rehabilitasi +

+
+Terapi Ke

+{{ .Repalcable }} +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ No RM + {{ .Repalcable }}
+ Nama Pasien + {{ .Repalcable }}
+ Tanggal Lahir + {{ .Repalcable }}
+ Diagnosa + {{ .Repalcable }}
+ Permintaan Terapi + {{ .Repalcable }}
+ Frekuensi Terapi + + 2 x Per Minggu       + Evaluasi: 1 Bulan +
+ Target Terapi + {{ .Repalcable }}
+ Waktu Mencapai Target + {{ .Repalcable }}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ NO + + Tanggal + + Dokter + + Fisioterapi + + Terapi Wicara + + Okupansi Terapi + + Ortotik Prostetik + + PSM + + TTD Pasien +
+ 1 + {{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}
+ 2 + {{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}
+ 3 + {{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}
+ 4 + {{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}
+ 5 + {{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}
+ 6 + {{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}
+ 7 + {{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}
+ 8 + {{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}{{ .Repalcable }}
+ + + + + + + + + + + +
+ Evaluasi + {{ .Repalcable }}
+ Rencana Selanjutnya + {{ .Repalcable }}
+ + + + + + + + + + + +
+ Malang,
+ Cap dan TTD Dr. SpKFR +
+ (........................................................) +
+ +
+ + + \ No newline at end of file diff --git a/assets/docs/therapy-protocol-2.html b/assets/docs/therapy-protocol-2.html new file mode 100644 index 00000000..b468bd43 --- /dev/null +++ b/assets/docs/therapy-protocol-2.html @@ -0,0 +1,217 @@ + + + + + General Consent + + + + + + + + + +
+ logo + +
+ PEMERINTAH PROVINSI JAWA TIMUR +
+
+ RUMAH SAKIT UMUM DAERAH Dr. SAIFUL ANWAR +
+
+ TERAKREDITASI KARS VERSI 2012 TINGKAT PARIPURNA +
+
+ Jl. Jaksa Agung Suprapto No. 2 MALANG 65111 +
+
Telp. (0341) 362101, Fax. (0341) 362110
+
Email: rsu-drsaifulanwar@jatimprov.go.id
+
Website: www.rsudsaifulanwar.jatimprov.go.id
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ No RM: + {{ .Repalcable }}
+ Nama Pasien + {{ .Repalcable }}
+ Diagnosa + {{ .Repalcable }}
+ Permintaan Terapi + {{ .Repalcable }}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ PELAKSANAAN PROGRAM + + Tanggal + + TTD +
+ PASIEN + + DOKTER + + TERAPIS +
1. {{ .Repalcable }}{{ .Repalcable }}
2. {{ .Repalcable }}{{ .Repalcable }}
3. {{ .Repalcable }}{{ .Repalcable }}
4. {{ .Repalcable }}{{ .Repalcable }}
5. {{ .Repalcable }}{{ .Repalcable }}
6. {{ .Repalcable }}{{ .Repalcable }}
7. {{ .Repalcable }}{{ .Repalcable }}
8. {{ .Repalcable }}{{ .Repalcable }}
9. {{ .Repalcable }}{{ .Repalcable }}
10. {{ .Repalcable }}{{ .Repalcable }}
11. {{ .Repalcable }}{{ .Repalcable }}
12. {{ .Repalcable }}{{ .Repalcable }}
13. {{ .Repalcable }}{{ .Repalcable }}
14. {{ .Repalcable }}{{ .Repalcable }}
15. {{ .Repalcable }}{{ .Repalcable }}
16. {{ .Repalcable }}{{ .Repalcable }}
17. {{ .Repalcable }}{{ .Repalcable }}
18. {{ .Repalcable }}{{ .Repalcable }}
19. {{ .Repalcable }}{{ .Repalcable }}
20. {{ .Repalcable }}{{ .Repalcable }}
+ + + + + + + + + + + + + +
+ Tempat & Tanggal
+ Cap dan TTD Dr. SpKFR +
+ (.................................................) +
+ +
+ + + \ No newline at end of file diff --git a/assets/docs/therapy-protocol-3.html b/assets/docs/therapy-protocol-3.html new file mode 100644 index 00000000..6623fb9e --- /dev/null +++ b/assets/docs/therapy-protocol-3.html @@ -0,0 +1,241 @@ + + + + + General Consent + + + + + + + + + +
+ logo + +
+ PEMERINTAH PROVINSI JAWA TIMUR +
+
+ RUMAH SAKIT UMUM DAERAH Dr. SAIFUL ANWAR +
+
+ TERAKREDITASI KARS VERSI 2012 TINGKAT PARIPURNA +
+
+ Jl. Jaksa Agung Suprapto No. 2 MALANG 65111 +
+
Telp. (0341) 362101, Fax. (0341) 362110
+
Email: rsu-drsaifulanwar@jatimprov.go.id
+
Website: www.rsudsaifulanwar.jatimprov.go.id
+
+ +
+ +
+

+ Lembar Formulir Rawat Jalan
Layanan Kedokteran Fisik dan Rehabilitasi +

+
+ +
+ + + + + + + +
I. Identitas PasienNo. RM: {{ .Repalcable }}
+ + + + + + + + + + + + + + + + + + + + + + + +
+ Nama Pasien + : {{ .Repalcable }}
+ Tanggal Lahir + : {{ .Repalcable }}
+ Aalamat + : {{ .Repalcable }}
+ Telp / HP + : {{ .Repalcable }}
+ Hubungan dengan Tertanggung + : + ☑ Suami / Istri +    + ▢ Anak +
+
+ + +
+ + + + +
II. Diisi oleh Dokter SpKFR
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Tanggal Pelayanan + : {{ .Repalcable }}
+ Anamnesa + : {{ .Repalcable }}
+ Pemeriksaan Fisik dan Uji Fungsi + : {{ .Repalcable }}
+ Diagnosis Medis (ICD-10) + : {{ .Repalcable }}
+ Diagnosis Fungsi (ICD-10) + : {{ .Repalcable }}
+ Pemeriksaan Penunjang + : {{ .Repalcable }}
+ Tata Laksana KFR (ICD 9 CM) + : {{ .Repalcable }}
+ Anjuran + : {{ .Repalcable }}
+ Evaluasi + : {{ .Repalcable }}
+ Suspek Penyakit Akibat Kerja + : + ☑ Ya   ( {{ .Repalcable }} ) + +
+ ▢ Tidak +
+
+ + + + + + + + + + + +
+ TTD Pasien + + Tempat & Tanggal
+ Cap dan TTD Dr. SpKFR +
+ (........................................................) + + (........................................................) +
+ +
+ + + \ No newline at end of file From f8f6a88ff6172f3c9e7ebf6b9910a9de3feb9a3e Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Mon, 1 Dec 2025 15:36:59 +0700 Subject: [PATCH 02/45] feat (screening): wip --- .../interface/main-handler/main-handler.go | 5 +- .../main-handler/screening/handler.go | 80 +++++ .../use-case/main-use-case/screening/case.go | 307 ++++++++++++++++++ .../main-use-case/screening/helper.go | 24 ++ .../use-case/main-use-case/screening/lib.go | 140 ++++++++ .../screening/middleware-runner.go | 103 ++++++ .../main-use-case/screening/middleware.go | 9 + .../main-use-case/screening/tycovar.go | 44 +++ 8 files changed, 711 insertions(+), 1 deletion(-) create mode 100644 internal/interface/main-handler/screening/handler.go create mode 100644 internal/use-case/main-use-case/screening/case.go create mode 100644 internal/use-case/main-use-case/screening/helper.go create mode 100644 internal/use-case/main-use-case/screening/lib.go create mode 100644 internal/use-case/main-use-case/screening/middleware-runner.go create mode 100644 internal/use-case/main-use-case/screening/middleware.go create mode 100644 internal/use-case/main-use-case/screening/tycovar.go diff --git a/internal/interface/main-handler/main-handler.go b/internal/interface/main-handler/main-handler.go index 646bf053..93b645ad 100644 --- a/internal/interface/main-handler/main-handler.go +++ b/internal/interface/main-handler/main-handler.go @@ -36,6 +36,7 @@ import ( responsibledoctorhist "simrs-vx/internal/interface/main-handler/responsible-doctor-hist" resume "simrs-vx/internal/interface/main-handler/resume" sbar "simrs-vx/internal/interface/main-handler/sbar" + screening "simrs-vx/internal/interface/main-handler/screening" soapi "simrs-vx/internal/interface/main-handler/soapi" uploadfile "simrs-vx/internal/interface/main-handler/upload-file" @@ -310,7 +311,9 @@ func SetRoutes() http.Handler { "PATCH /{id}/verify": resume.Verify, "PATCH /{id}/validate": resume.Validate, }) - + hk.GroupRoutes("/v1/screening", r, auth.GuardMW, hk.MapHandlerFunc{ + "POST /": screening.O.Create, + }) /******************** actor ********************/ hc.RegCrud(r, "/v1/person", person.O) hc.RegCrud(r, "/v1/person-address", personaddress.O) diff --git a/internal/interface/main-handler/screening/handler.go b/internal/interface/main-handler/screening/handler.go new file mode 100644 index 00000000..28ca7027 --- /dev/null +++ b/internal/interface/main-handler/screening/handler.go @@ -0,0 +1,80 @@ +package screening + +import ( + "net/http" + + rw "github.com/karincake/risoles" + sf "github.com/karincake/semprit" + + // ua "github.com/karincake/tumpeng/auth/svc" + + e "simrs-vx/internal/domain/main-entities/screening" + u "simrs-vx/internal/use-case/main-use-case/screening" + + pa "simrs-vx/internal/lib/auth" + + d "github.com/karincake/dodol" +) + +type myBase struct{} + +var O myBase + +func (obj myBase) Create(w http.ResponseWriter, r *http.Request) { + authInfo, err := pa.GetAuthInfo(r) + if err != nil { + rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil) + } + dto := e.CreateDto{} + if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { + return + } + dto.AuthInfo = *authInfo + res, err := u.Create(dto) + rw.DataResponse(w, res, err) +} + +func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { + dto := e.ReadListDto{} + sf.UrlQueryParam(&dto, *r.URL) + res, err := u.ReadList(dto) + rw.DataResponse(w, res, err) +} + +func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { + id := rw.ValidateInt(w, "id", r.PathValue("id")) + if id <= 0 { + return + } + dto := e.ReadDetailDto{} + dto.Id = uint16(id) + res, err := u.ReadDetail(dto) + rw.DataResponse(w, res, err) +} + +func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { + id := rw.ValidateInt(w, "id", r.PathValue("id")) + if id <= 0 { + return + } + + dto := e.UpdateDto{} + if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { + return + } + dto.Id = uint16(id) + res, err := u.Update(dto) + rw.DataResponse(w, res, err) +} + +func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { + id := rw.ValidateInt(w, "id", r.PathValue("id")) + if id <= 0 { + return + } + + dto := e.DeleteDto{} + dto.Id = uint16(id) + res, err := u.Delete(dto) + rw.DataResponse(w, res, err) +} diff --git a/internal/use-case/main-use-case/screening/case.go b/internal/use-case/main-use-case/screening/case.go new file mode 100644 index 00000000..84ae4727 --- /dev/null +++ b/internal/use-case/main-use-case/screening/case.go @@ -0,0 +1,307 @@ +package screening + +import ( + "errors" + "strconv" + + e "simrs-vx/internal/domain/main-entities/screening" + + erc "simrs-vx/internal/domain/references/clinical" + + dg "github.com/karincake/apem/db-gorm-pg" + d "github.com/karincake/dodol" + + pl "simrs-vx/pkg/logger" + pu "simrs-vx/pkg/use-case-helper" + + "gorm.io/gorm" +) + +const source = "screening" + +func Create(input e.CreateDto) (*d.Data, error) { + data := e.Screening{} + + event := pl.Event{ + Feature: "Create", + Source: source, + } + + // Start log + pl.SetLogInfo(&event, input, "started", "create") + + err := dg.I.Transaction(func(tx *gorm.DB) error { + mwRunner := newMiddlewareRunner(&event, tx) + mwRunner.setMwType(pu.MWTPre) + // Run pre-middleware + if err := mwRunner.RunCreateMiddleware(createPreMw, &input, &data); err != nil { + return err + } + + if !input.AuthInfo.IsDoctor() && !input.AuthInfo.IsNurse() { + event.Status = "failed" + event.ErrInfo = pl.ErrorInfo{ + Code: "auth-forbidden", + Detail: "user position is not allowed", + Raw: errors.New("authentication failed"), + } + return pl.SetLogError(&event, input) + } + + if input.AuthInfo.Employee_Id != nil { + v := uint(*input.AuthInfo.Employee_Id) + input.Employee_Id = &v + } else { + input.Employee_Id = nil + } + + if input.Type == erc.SFTCB { + s, _, err := ReadListData(e.ReadListDto{FilterDto: e.FilterDto{Type: erc.SFTCA}}, &event, tx) + if err != nil { + return err + } + if len(s) != 0 { + return errors.New("screening form type A is not created yet, please create it first") + } + } + + if resData, err := CreateData(input, &event, tx); err != nil { + return err + } else { + data = *resData + } + + mwRunner.setMwType(pu.MWTPost) + // Run post-middleware + if err := mwRunner.RunCreateMiddleware(createPostMw, &input, &data); err != nil { + return err + } + + pl.SetLogInfo(&event, nil, "complete") + + return nil + }) + + if err != nil { + return nil, err + } + + return &d.Data{ + Meta: d.II{ + "source": source, + "structure": "single-data", + "status": "created", + }, + Data: data.ToResponse(), + }, nil +} + +func ReadList(input e.ReadListDto) (*d.Data, error) { + var data *e.Screening + var dataList []e.Screening + var metaList *e.MetaDto + var err error + + event := pl.Event{ + Feature: "ReadList", + Source: source, + } + + // Start log + pl.SetLogInfo(&event, input, "started", "readList") + + err = dg.I.Transaction(func(tx *gorm.DB) error { + mwRunner := newMiddlewareRunner(&event, tx) + mwRunner.setMwType(pu.MWTPre) + // Run pre-middleware + if err := mwRunner.RunReadListMiddleware(readListPreMw, &input, data); err != nil { + return err + } + + if dataList, metaList, err = ReadListData(input, &event, tx); err != nil { + return err + } + + mwRunner.setMwType(pu.MWTPost) + // Run post-middleware + if err := mwRunner.RunReadListMiddleware(readListPostMw, &input, data); err != nil { + return err + } + + return nil + }) + + if err != nil { + return nil, err + } + + return &d.Data{ + Meta: d.IS{ + "source": source, + "structure": "list-data", + "status": "fetched", + "page_number": strconv.Itoa(metaList.PageNumber), + "page_size": strconv.Itoa(metaList.PageSize), + "record_totalCount": strconv.Itoa(metaList.Count), + "record_currentCount": strconv.Itoa(len(dataList)), + }, + Data: e.ToResponseList(dataList), + }, nil +} + +func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { + var data *e.Screening + var err error + + event := pl.Event{ + Feature: "ReadDetail", + Source: source, + } + + // Start log + pl.SetLogInfo(&event, input, "started", "readDetail") + + err = dg.I.Transaction(func(tx *gorm.DB) error { + mwRunner := newMiddlewareRunner(&event, tx) + mwRunner.setMwType(pu.MWTPre) + // Run pre-middleware + if err := mwRunner.RunReadDetailMiddleware(readDetailPreMw, &input, data); err != nil { + return err + } + + if data, err = ReadDetailData(input, &event, tx); err != nil { + return err + } + + mwRunner.setMwType(pu.MWTPost) + // Run post-middleware + if err := mwRunner.RunReadDetailMiddleware(readDetailPostMw, &input, data); err != nil { + return err + } + + return nil + }) + + if err != nil { + return nil, err + } + + return &d.Data{ + Meta: d.IS{ + "source": source, + "structure": "single-data", + "status": "fetched", + }, + Data: data.ToResponse(), + }, nil +} + +func Update(input e.UpdateDto) (*d.Data, error) { + rdDto := e.ReadDetailDto{Id: input.Id} + var data *e.Screening + var err error + + event := pl.Event{ + Feature: "Update", + Source: source, + } + + // Start log + pl.SetLogInfo(&event, input, "started", "update") + + 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 + } + + mwRunner := newMiddlewareRunner(&event, tx) + mwRunner.setMwType(pu.MWTPre) + // Run pre-middleware + if err := mwRunner.RunUpdateMiddleware(readDetailPreMw, &rdDto, data); err != nil { + return err + } + + if err := UpdateData(input, data, &event, tx); err != nil { + return err + } + + pl.SetLogInfo(&event, nil, "complete") + + mwRunner.setMwType(pu.MWTPost) + // Run post-middleware + if err := mwRunner.RunUpdateMiddleware(readDetailPostMw, &rdDto, data); err != nil { + return err + } + + return nil + }) + + if err != nil { + return nil, err + } + + return &d.Data{ + Meta: d.IS{ + "source": source, + "structure": "single-data", + "status": "updated", + }, + Data: data.ToResponse(), + }, nil + +} + +func Delete(input e.DeleteDto) (*d.Data, error) { + rdDto := e.ReadDetailDto{Id: input.Id} + var data *e.Screening + var err error + + event := pl.Event{ + Feature: "Delete", + Source: source, + } + + // Start log + pl.SetLogInfo(&event, input, "started", "delete") + + 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 + } + + mwRunner := newMiddlewareRunner(&event, tx) + mwRunner.setMwType(pu.MWTPre) + // Run pre-middleware + if err := mwRunner.RunDeleteMiddleware(readDetailPreMw, &rdDto, data); err != nil { + return err + } + + if err := DeleteData(data, &event, tx); err != nil { + return err + } + + mwRunner.setMwType(pu.MWTPost) + // Run post-middleware + if err := mwRunner.RunDeleteMiddleware(readDetailPostMw, &rdDto, data); err != nil { + return err + } + + return nil + }) + + if err != nil { + return nil, err + } + + return &d.Data{ + Meta: d.IS{ + "source": source, + "structure": "single-data", + "status": "deleted", + }, + Data: data.ToResponse(), + }, nil + +} diff --git a/internal/use-case/main-use-case/screening/helper.go b/internal/use-case/main-use-case/screening/helper.go new file mode 100644 index 00000000..5174d753 --- /dev/null +++ b/internal/use-case/main-use-case/screening/helper.go @@ -0,0 +1,24 @@ +/* +DESCRIPTION: +Any functions that are used internally by the use-case +*/ +package screening + +import ( + e "simrs-vx/internal/domain/main-entities/screening" +) + +func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Screening) { + var inputSrc *e.CreateDto + if inputT, ok := any(input).(*e.CreateDto); ok { + inputSrc = inputT + } else { + inputTemp := any(input).(*e.UpdateDto) + inputSrc = &inputTemp.CreateDto + } + + data.Encounter_Id = inputSrc.Encounter_Id + data.Employee_Id = inputSrc.Employee_Id + data.Type = inputSrc.Type + data.Value = inputSrc.Value +} diff --git a/internal/use-case/main-use-case/screening/lib.go b/internal/use-case/main-use-case/screening/lib.go new file mode 100644 index 00000000..413e84d2 --- /dev/null +++ b/internal/use-case/main-use-case/screening/lib.go @@ -0,0 +1,140 @@ +package screening + +import ( + e "simrs-vx/internal/domain/main-entities/screening" + + plh "simrs-vx/pkg/lib-helper" + pl "simrs-vx/pkg/logger" + pu "simrs-vx/pkg/use-case-helper" + + dg "github.com/karincake/apem/db-gorm-pg" + gh "github.com/karincake/getuk" + "gorm.io/gorm" +) + +func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.Screening, error) { + pl.SetLogInfo(event, nil, "started", "DBCreate") + + data := e.Screening{} + setData(&input, &data) + + var tx *gorm.DB + if len(dbx) > 0 { + tx = dbx[0] + } else { + tx = dg.I + } + + if err := tx.Create(&data).Error; err != nil { + return nil, plh.HandleCreateError(input, event, err) + } + + pl.SetLogInfo(event, nil, "complete") + return &data, nil +} + +func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Screening, *e.MetaDto, error) { + pl.SetLogInfo(event, input, "started", "DBReadList") + data := []e.Screening{} + pagination := gh.Pagination{} + count := int64(0) + meta := e.MetaDto{} + + var tx *gorm.DB + if len(dbx) > 0 { + tx = dbx[0] + } else { + tx = dg.I + } + + tx = tx. + Model(&e.Screening{}). + Scopes(gh.Preload(input.Includes)). + Scopes(gh.Filter(input.FilterDto)). + Count(&count). + Scopes(gh.Paginate(input, &pagination)). + Order("\"CreatedAt\" DESC") + + if err := tx.Find(&data).Error; err != nil { + if err == gorm.ErrRecordNotFound { + return nil, &meta, nil + } + return nil, nil, plh.HandleListError(input, event, err) + } + + meta.Count = int(count) + meta.PageNumber = pagination.PageNumber + meta.PageSize = pagination.PageSize + + pl.SetLogInfo(event, nil, "complete") + return data, &meta, nil +} + +func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e.Screening, error) { + pl.SetLogInfo(event, input, "started", "DBReadDetail") + data := e.Screening{} + + var tx *gorm.DB + if len(dbx) > 0 { + tx = dbx[0] + } else { + tx = dg.I + } + + if err := tx.First(&data, input.Id).Error; err != nil { + if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil { + return nil, processedErr + } + } + + pl.SetLogInfo(event, nil, "complete") + return &data, nil +} + +func UpdateData(input e.UpdateDto, data *e.Screening, event *pl.Event, dbx ...*gorm.DB) error { + pl.SetLogInfo(event, data, "started", "DBUpdate") + setData(&input, data) + + var tx *gorm.DB + if len(dbx) > 0 { + tx = dbx[0] + } else { + tx = dg.I + } + + if err := tx.Save(&data).Error; 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 +} + +func DeleteData(data *e.Screening, event *pl.Event, dbx ...*gorm.DB) error { + pl.SetLogInfo(event, data, "started", "DBDelete") + var tx *gorm.DB + if len(dbx) > 0 { + tx = dbx[0] + } else { + tx = dg.I + } + + if err := tx.Delete(&data).Error; err != nil { + event.Status = "failed" + event.ErrInfo = pl.ErrorInfo{ + Code: "data-delete-fail", + Detail: "Database delete failed", + Raw: err, + } + return pl.SetLogError(event, data) + } + + pl.SetLogInfo(event, nil, "complete") + return nil +} diff --git a/internal/use-case/main-use-case/screening/middleware-runner.go b/internal/use-case/main-use-case/screening/middleware-runner.go new file mode 100644 index 00000000..9eb1b4a2 --- /dev/null +++ b/internal/use-case/main-use-case/screening/middleware-runner.go @@ -0,0 +1,103 @@ +package screening + +import ( + e "simrs-vx/internal/domain/main-entities/screening" + pl "simrs-vx/pkg/logger" + pu "simrs-vx/pkg/use-case-helper" + + "gorm.io/gorm" +) + +type middlewareRunner struct { + Event *pl.Event + Tx *gorm.DB + MwType pu.MWType +} + +// NewMiddlewareExecutor creates a new middleware executor +func newMiddlewareRunner(event *pl.Event, tx *gorm.DB) *middlewareRunner { + return &middlewareRunner{ + Event: event, + Tx: tx, + } +} + +// ExecuteCreateMiddleware executes create middleware +func (me *middlewareRunner) RunCreateMiddleware(middlewares []createMw, input *e.CreateDto, data *e.Screening) error { + for _, middleware := range middlewares { + logData := pu.GetLogData(input, data) + + pl.SetLogInfo(me.Event, logData, "started", middleware.Name) + + if err := middleware.Func(input, data, me.Tx); err != nil { + return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err) + } + + pl.SetLogInfo(me.Event, nil, "complete") + } + return nil +} + +func (me *middlewareRunner) RunReadListMiddleware(middlewares []readListMw, input *e.ReadListDto, data *e.Screening) error { + for _, middleware := range middlewares { + logData := pu.GetLogData(input, data) + + pl.SetLogInfo(me.Event, logData, "started", middleware.Name) + + if err := middleware.Func(input, data, me.Tx); err != nil { + return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err) + } + + pl.SetLogInfo(me.Event, nil, "complete") + } + return nil +} + +func (me *middlewareRunner) RunReadDetailMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.Screening) error { + for _, middleware := range middlewares { + logData := pu.GetLogData(input, data) + + pl.SetLogInfo(me.Event, logData, "started", middleware.Name) + + if err := middleware.Func(input, data, me.Tx); err != nil { + return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err) + } + + pl.SetLogInfo(me.Event, nil, "complete") + } + return nil +} + +func (me *middlewareRunner) RunUpdateMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.Screening) error { + for _, middleware := range middlewares { + logData := pu.GetLogData(input, data) + + pl.SetLogInfo(me.Event, logData, "started", middleware.Name) + + if err := middleware.Func(input, data, me.Tx); err != nil { + return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err) + } + + pl.SetLogInfo(me.Event, nil, "complete") + } + return nil +} + +func (me *middlewareRunner) RunDeleteMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.Screening) error { + for _, middleware := range middlewares { + logData := pu.GetLogData(input, data) + + pl.SetLogInfo(me.Event, logData, "started", middleware.Name) + + if err := middleware.Func(input, data, me.Tx); err != nil { + return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err) + } + + pl.SetLogInfo(me.Event, nil, "complete") + } + return nil +} + +func (me *middlewareRunner) setMwType(mwType pu.MWType) { + me.MwType = mwType +} diff --git a/internal/use-case/main-use-case/screening/middleware.go b/internal/use-case/main-use-case/screening/middleware.go new file mode 100644 index 00000000..6ec8140c --- /dev/null +++ b/internal/use-case/main-use-case/screening/middleware.go @@ -0,0 +1,9 @@ +package screening + +// example of middleware +// func init() { +// createPreMw = append(createPreMw, +// CreateMw{Name: "modif-input", Func: pm.ModifInput}, +// CreateMw{Name: "check-data", Func: pm.CheckData}, +// ) +// } diff --git a/internal/use-case/main-use-case/screening/tycovar.go b/internal/use-case/main-use-case/screening/tycovar.go new file mode 100644 index 00000000..481f3d3e --- /dev/null +++ b/internal/use-case/main-use-case/screening/tycovar.go @@ -0,0 +1,44 @@ +/* +DESCRIPTION: +A sample, part of the package that contains type, constants, and/or variables. + +In this sample it also provides type and variable regarding the needs of the +middleware to separate from main use-case which has the basic CRUD +functionality. The purpose of this is to make the code more maintainable. +*/ +package screening + +import ( + "gorm.io/gorm" + + e "simrs-vx/internal/domain/main-entities/screening" +) + +type createMw struct { + Name string + Func func(input *e.CreateDto, data *e.Screening, tx *gorm.DB) error +} + +type readListMw struct { + Name string + Func func(input *e.ReadListDto, data *e.Screening, tx *gorm.DB) error +} + +type readDetailMw struct { + Name string + Func func(input *e.ReadDetailDto, data *e.Screening, tx *gorm.DB) error +} + +type UpdateMw = readDetailMw +type DeleteMw = readDetailMw + +var createPreMw []createMw // preprocess middleware +var createPostMw []createMw // postprocess middleware +var readListPreMw []readListMw // .. +var readListPostMw []readListMw // .. +var readDetailPreMw []readDetailMw +var readDetailPostMw []readDetailMw +var updatePreMw []readDetailMw +var updatePostMw []readDetailMw +var deletePreMw []readDetailMw +var deletePostMw []readDetailMw From 7e454b0a2d72b55a6aba982f71401a8d66f5fb5e Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Tue, 2 Dec 2025 10:17:06 +0700 Subject: [PATCH 03/45] feat (user): add screening role --- internal/use-case/main-use-case/user/case.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/use-case/main-use-case/user/case.go b/internal/use-case/main-use-case/user/case.go index 50b676af..f6faec22 100644 --- a/internal/use-case/main-use-case/user/case.go +++ b/internal/use-case/main-use-case/user/case.go @@ -166,7 +166,7 @@ func Create(input e.CreateDto) (*d.Data, error) { if _, err := umw.CreateData(createMidWife, &event, tx); err != nil { return err } - case ero.EPCReg: + case ero.EPCReg, ero.EPCScr: // do nothing default: return errors.New("invalid employee position") @@ -523,6 +523,8 @@ func Update(input e.UpdateDto) (*d.Data, error) { if _, err := umw.CreateData(createMidWife, &event, tx); err != nil { return err } + case ero.EPCReg, ero.EPCScr: + // do nothing default: return errors.New("invalid employee position") } From 5adb4e566699ce02177d08f9e227cbcea250c81f Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Tue, 2 Dec 2025 13:37:26 +0700 Subject: [PATCH 04/45] wip --- assets/docs/screening-form-a.html | 131 ++++++++++++++++++ assets/docs/screening-form-b.html | 127 +++++++++++++++++ .../domain/main-entities/screening/dto.go | 36 +++++ .../domain/main-entities/screening/entity.go | 2 + .../main-handler/screening/handler.go | 80 +++++------ internal/lib/auth/tycovar.go | 7 + .../use-case/main-use-case/screening/case.go | 19 ++- .../main-use-case/screening/helper.go | 2 + 8 files changed, 361 insertions(+), 43 deletions(-) create mode 100644 assets/docs/screening-form-a.html create mode 100644 assets/docs/screening-form-b.html diff --git a/assets/docs/screening-form-a.html b/assets/docs/screening-form-a.html new file mode 100644 index 00000000..768eb183 --- /dev/null +++ b/assets/docs/screening-form-a.html @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Tanggal Terbit + : {{ .Repalcable }}
+ No. RM + : {{ .Repalcable }}
+ Nama + : {{ .Repalcable }}
+ Tanggal Lahir + : {{ .Repalcable }}
+ +
+

+ FORM A +

+ +
+

Kajian Awal Medis:

+ + + + + + + +
+ ☑ Kasus Dengan Penyakit Kronis, Katastropik (memerlukan Pembiayaan Tinggi), Terminal +
+ ▢ Status Fungsional Rendah, Kebutuhan Bantuan ADL(Activity Daily Living) Yang Tinggi +
+
+ +
+

ASSESMEN:

+ + +
+
+ +
+

IDENTIFIKASI MASALAH:

+ + +
+
+ +
+

PERENCANAAN:

+ + +
+
+ + + + + + + + + + +
+ 2025-10-08 16:06:22 +
+ GATOT SUBROTO,AMd.Kep +
+ +
+ + + \ No newline at end of file diff --git a/assets/docs/screening-form-b.html b/assets/docs/screening-form-b.html new file mode 100644 index 00000000..1ae8a07c --- /dev/null +++ b/assets/docs/screening-form-b.html @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Tanggal Terbit + : {{ .Repalcable }}
+ No. RM + : {{ .Repalcable }}
+ Nama + : {{ .Repalcable }}
+ Tanggal Lahir + : {{ .Repalcable }}
+ +
+

+ FORM B +

+ + + + + + + + + + + + + + +
+ NO + + Tanggal/jam + + Implementasi, Monitoring, Fasilitasi, koordinasi, komunikasi dan kolaborasi, advokasi, hasil pelayanan, + Terminasi + + MPP +
+ 1 + + 2025-10-08 16:08:18 + +
    +
  • Implementasi: Pemantauan harian terhadap penggunaan alat medis (oksigen dan alat bantu + jalan) serta kepatuhan terapi.
  • +
  • Monitoring: Observasi respon pasien terhadap terapi dan edukasi keluarga untuk perawatan + mandiri di rumah.
  • +
  • Fasilitasi: Menyediakan alat bantu sesuai kebutuhan dan menghubungkan pasien dengan + layanan rehabilitasi medik.
  • +
  • Koordinasi: Melibatkan dokter penanggung jawab, perawat, dan keluarga dalam penyusunan + rencana tindak lanjut.
  • +
  • Komunikasi dan Kolaborasi: Diskusi rutin antar profesi untuk evaluasi perkembangan + pasien.
  • +
  • Advokasi: Memberikan dukungan informasi dan hak pasien terkait rencana pulang dan + kesinambungan terapi.
  • +
  • Hasil Pelayanan: Pasien menunjukkan perbaikan fungsi mobilitas, tingkat kepatuhan terapi + meningkat.
  • +
+
+ GATOT SUBROTO,AMd.Kep +
+ +
+ + + \ No newline at end of file diff --git a/internal/domain/main-entities/screening/dto.go b/internal/domain/main-entities/screening/dto.go index 5dfed2c7..cdcc96dc 100644 --- a/internal/domain/main-entities/screening/dto.go +++ b/internal/domain/main-entities/screening/dto.go @@ -84,3 +84,39 @@ func ToResponseList(data []Screening) []ResponseDto { } return resp } + +type FormA struct { + AgeAtRisk bool `json:"ageAtRisk"` // Usia Dengan Risiko + LowCognitiveFunction bool `json:"lowCognitiveFunction"` // Pasien Dengan Fungsi Kognitif Rendah + HighRiskPatient bool `json:"highRiskPatient"` // Pasien Dengan Risiko Tinggi + HighComplaintPotential bool `json:"highComplaintPotential"` // Potensi Komplain Tinggi (Medik dan Non Medik) + ChronicOrCatastrophicOrTerminal bool `json:"chronicOrCatastrophicOrTerminal"` // Kasus Dengan Penyakit Kronis, Katastropik, Terminal + LowFunctionalStatus bool `json:"lowFunctionalStatus"` // Status Fungsional Rendah, Kebutuhan Bantuan ADL Tinggi + HistoryOfMedicalDeviceUse bool `json:"historyOfMedicalDeviceUse"` // Pasien Dengan Riwayat Penggunaan Peralatan Medis Masa Lalu + MentalOrSocialIssues bool `json:"mentalOrSocialIssues"` // Riwayat Gangguan Mental, Bunuh Diri, Krisis Keluarga, Isu Sosial + FrequentERVisitsOrReadmission bool `json:"frequentERVisitsOrReadmission"` // Sering Masuk IGD, Readmisi RS + HighCareCostEstimate bool `json:"highCareCostEstimate"` // Perkiraan Asuhan Dengan Biaya Tinggi + ComplexFinancingSystem bool `json:"complexFinancingSystem"` // Kemungkinan Sistem Pembiayaan Yang Kompleks + AboveAverageLengthOfStay bool `json:"aboveAverageLengthOfStay"` // Kasus Yang Melebihi Rata-Rata Lama Dirawat + ImportantOrHighRiskDischargePlanning bool `json:"importantOrHighRiskDischargePlanning"` // Rencana Pemulangan Penting / Kontinuitas Pelayanan + Stagnation bool `json:"stagnation"` // Stagnasi +} + +type ProblemIdentification struct { + CareNotFollowingGuidelines bool `json:"careNotFollowingGuidelines"` // Tingkat Asuhan Tidak Sesuai Panduan/ Norma + OverUtilization bool `json:"overUtilization"` // Over Utilization Pelayanan + UnderUtilization bool `json:"underUtilization"` // Under Utilization Pelayanan + PatientNonCompliance bool `json:"patientNonCompliance"` // Ketidakpatuhan Pasien + InadequateEducation bool `json:"inadequateEducation"` // Edukasi Kurang Memadai + LackOfFamilySupport bool `json:"lackOfFamilySupport"` // Kurang Dukungan Keluarga + DecreasedDetermination bool `json:"decreasedDetermination"` // Penurunan Determinasi Ketika Komplikasi Meningkat + FinancialDifficultyDuringComplications bool `json:"financialDifficultyDuringComplications"` // Kendala Keuangan Ketika Komplikasi Meningkat + DischargeCriteriaNotMetOrDelayed bool `json:"dischargeCriteriaNotMetOrDelayed"` // Pemulangan/ Rujukan Belum Memenuhi Kriteria/ Ditunda +} + +type AssessmentForm struct { + Screening Screening `json:"screening"` + AssessmentDetail string `json:"assessmentDetail"` // Masukkan detail assesmen + ProblemIdentification ProblemIdentification `json:"problemIdentification"` + PlanningDetail string `json:"planningDetail"` // Masukkan detail perencanaan +} diff --git a/internal/domain/main-entities/screening/entity.go b/internal/domain/main-entities/screening/entity.go index a6284c16..fa650165 100644 --- a/internal/domain/main-entities/screening/entity.go +++ b/internal/domain/main-entities/screening/entity.go @@ -18,3 +18,5 @@ type Screening struct { Value *string `json:"value"` FileUrl *string `json:"fileUrl" gorm:"size:1024"` } + +// func (d Screening) UnMarshal(data []byte) (error {} diff --git a/internal/interface/main-handler/screening/handler.go b/internal/interface/main-handler/screening/handler.go index 28ca7027..29ea5c73 100644 --- a/internal/interface/main-handler/screening/handler.go +++ b/internal/interface/main-handler/screening/handler.go @@ -4,7 +4,7 @@ import ( "net/http" rw "github.com/karincake/risoles" - sf "github.com/karincake/semprit" + // sf "github.com/karincake/semprit" // ua "github.com/karincake/tumpeng/auth/svc" @@ -34,47 +34,47 @@ func (obj myBase) Create(w http.ResponseWriter, r *http.Request) { rw.DataResponse(w, res, err) } -func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { - dto := e.ReadListDto{} - sf.UrlQueryParam(&dto, *r.URL) - res, err := u.ReadList(dto) - rw.DataResponse(w, res, err) -} +// func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { +// dto := e.ReadListDto{} +// sf.UrlQueryParam(&dto, *r.URL) +// res, err := u.ReadList(dto) +// rw.DataResponse(w, res, err) +// } -func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { - return - } - dto := e.ReadDetailDto{} - dto.Id = uint16(id) - res, err := u.ReadDetail(dto) - rw.DataResponse(w, res, err) -} +// func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { +// id := rw.ValidateInt(w, "id", r.PathValue("id")) +// if id <= 0 { +// return +// } +// dto := e.ReadDetailDto{} +// dto.Id = uint16(id) +// res, err := u.ReadDetail(dto) +// rw.DataResponse(w, res, err) +// } -func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { - return - } +// func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { +// id := rw.ValidateInt(w, "id", r.PathValue("id")) +// if id <= 0 { +// return +// } - dto := e.UpdateDto{} - if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { - return - } - dto.Id = uint16(id) - res, err := u.Update(dto) - rw.DataResponse(w, res, err) -} +// dto := e.UpdateDto{} +// if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { +// return +// } +// dto.Id = uint16(id) +// res, err := u.Update(dto) +// rw.DataResponse(w, res, err) +// } -func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { - id := rw.ValidateInt(w, "id", r.PathValue("id")) - if id <= 0 { - return - } +// func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { +// id := rw.ValidateInt(w, "id", r.PathValue("id")) +// if id <= 0 { +// return +// } - dto := e.DeleteDto{} - dto.Id = uint16(id) - res, err := u.Delete(dto) - rw.DataResponse(w, res, err) -} +// dto := e.DeleteDto{} +// dto.Id = uint16(id) +// res, err := u.Delete(dto) +// rw.DataResponse(w, res, err) +// } diff --git a/internal/lib/auth/tycovar.go b/internal/lib/auth/tycovar.go index 117d0c73..c673eb04 100644 --- a/internal/lib/auth/tycovar.go +++ b/internal/lib/auth/tycovar.go @@ -65,6 +65,13 @@ func (a AuthInfo) IsPharmacist() bool { return *a.Employee_Position_Code == string(ero.EPCPha) } +func (a AuthInfo) IsScreener() bool { // MPP, petugas skrining + if a.Employee_Position_Code == nil { + return false + } + return *a.Employee_Position_Code == string(ero.EPCScr) +} + // func (a AuthInfo) IsPayment() bool { // if a.Employee_Position_Code == nil { // return false diff --git a/internal/use-case/main-use-case/screening/case.go b/internal/use-case/main-use-case/screening/case.go index 84ae4727..f6673450 100644 --- a/internal/use-case/main-use-case/screening/case.go +++ b/internal/use-case/main-use-case/screening/case.go @@ -38,7 +38,11 @@ func Create(input e.CreateDto) (*d.Data, error) { return err } - if !input.AuthInfo.IsDoctor() && !input.AuthInfo.IsNurse() { + if !pu.Contains([]erc.ScreeningFormTypeCode{erc.SFTCB, erc.SFTCA}, input.Type) { + return errors.New("invalid screening form type") + } + + if !input.AuthInfo.IsScreener() { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ Code: "auth-forbidden", @@ -55,12 +59,21 @@ func Create(input e.CreateDto) (*d.Data, error) { input.Employee_Id = nil } - if input.Type == erc.SFTCB { + switch input.Type { + case erc.SFTCA: s, _, err := ReadListData(e.ReadListDto{FilterDto: e.FilterDto{Type: erc.SFTCA}}, &event, tx) if err != nil { return err } - if len(s) != 0 { + if len(s) > 0 { + return errors.New("screening form type A is already created for this encounter") + } + case erc.SFTCB: + s, _, err := ReadListData(e.ReadListDto{FilterDto: e.FilterDto{Type: erc.SFTCA}}, &event, tx) + if err != nil { + return err + } + if len(s) < 1 { return errors.New("screening form type A is not created yet, please create it first") } } diff --git a/internal/use-case/main-use-case/screening/helper.go b/internal/use-case/main-use-case/screening/helper.go index 5174d753..94692281 100644 --- a/internal/use-case/main-use-case/screening/helper.go +++ b/internal/use-case/main-use-case/screening/helper.go @@ -6,12 +6,14 @@ package screening import ( e "simrs-vx/internal/domain/main-entities/screening" + erc "simrs-vx/internal/domain/references/common" ) func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Screening) { var inputSrc *e.CreateDto if inputT, ok := any(input).(*e.CreateDto); ok { inputSrc = inputT + data.Status = erc.DVCValidated } else { inputTemp := any(input).(*e.UpdateDto) inputSrc = &inputTemp.CreateDto From 821c99833eb78c3cc687a486553f33cd905172f4 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Tue, 2 Dec 2025 16:12:13 +0700 Subject: [PATCH 05/45] fix template screening form a --- assets/docs/screening-form-a.html | 110 ++++++++++++------ .../domain/main-entities/screening/dto.go | 89 +++++++++++++- .../main-use-case/generate-file/helper.go | 40 +++++++ .../main-use-case/generate-file/tycovar.go | 15 +++ 4 files changed, 214 insertions(+), 40 deletions(-) diff --git a/assets/docs/screening-form-a.html b/assets/docs/screening-form-a.html index 768eb183..a838c111 100644 --- a/assets/docs/screening-form-a.html +++ b/assets/docs/screening-form-a.html @@ -32,34 +32,43 @@ - + +
+ Tanggal Terbit : {{ .IssuedDate }} +
+ + +
- - - + + + - - - + + + - - - - - - - - + + +
- Tanggal Terbit - : {{ .Repalcable }}No. RM:{{ .MedicalRecord }}
- No. RM - : {{ .Repalcable }}Nama:{{ .Name }}
- Nama - : {{ .Repalcable }}
- Tanggal Lahir - : {{ .Repalcable }}Tanggal Lahir:{{ .BirthDate }}
@@ -69,58 +78,85 @@ font-weight: bold; font-size: 1rem; margin: 0; - "> + "> FORM A

Kajian Awal Medis:

+ + {{ if gt (len .EarlyMedic) 0 }} + {{ range .EarlyMedic }} + {{ end }} + {{ else }} - + -
- ☑ Kasus Dengan Penyakit Kronis, Katastropik (memerlukan Pembiayaan Tinggi), Terminal + ☑ {{ . }}
- ▢ Status Fungsional Rendah, Kebutuhan Bantuan ADL(Activity Daily Living) Yang Tinggi -
+ {{ end }} + +

ASSESMEN:

- + + +
+ {{ .Assessment }} +

IDENTIFIKASI MASALAH:

- -
+ {{ if gt (len .ProblemIdentification) 0 }} + {{ range .ProblemIdentification }} + + + ☑ {{ . }} + + + {{ end }} + {{ else }} + + + + {{ end }} + +

PERENCANAAN:

- + + +
+ {{ .Planning }} +
- + -
- 2025-10-08 16:06:22 + + {{ .Date }}
- GATOT SUBROTO,AMd.Kep + + ({{ .Employee_Name }})
diff --git a/internal/domain/main-entities/screening/dto.go b/internal/domain/main-entities/screening/dto.go index cdcc96dc..b001af39 100644 --- a/internal/domain/main-entities/screening/dto.go +++ b/internal/domain/main-entities/screening/dto.go @@ -85,7 +85,7 @@ func ToResponseList(data []Screening) []ResponseDto { return resp } -type FormA struct { +type ScreeningEntry struct { AgeAtRisk bool `json:"ageAtRisk"` // Usia Dengan Risiko LowCognitiveFunction bool `json:"lowCognitiveFunction"` // Pasien Dengan Fungsi Kognitif Rendah HighRiskPatient bool `json:"highRiskPatient"` // Pasien Dengan Risiko Tinggi @@ -114,9 +114,92 @@ type ProblemIdentification struct { DischargeCriteriaNotMetOrDelayed bool `json:"dischargeCriteriaNotMetOrDelayed"` // Pemulangan/ Rujukan Belum Memenuhi Kriteria/ Ditunda } -type AssessmentForm struct { - Screening Screening `json:"screening"` +type FormA struct { + Screening ScreeningEntry `json:"screening"` AssessmentDetail string `json:"assessmentDetail"` // Masukkan detail assesmen ProblemIdentification ProblemIdentification `json:"problemIdentification"` PlanningDetail string `json:"planningDetail"` // Masukkan detail perencanaan } + +func (s ScreeningEntry) SelectedScreeningLabels() []string { + result := []string{} + + if s.AgeAtRisk { + result = append(result, "Usia Dengan Risiko") + } + if s.LowCognitiveFunction { + result = append(result, "Pasien Dengan Fungsi Kognitif Rendah") + } + if s.HighRiskPatient { + result = append(result, "Pasien Dengan Risiko Tinggi") + } + if s.HighComplaintPotential { + result = append(result, "Potensi Komplain Tinggi (Medik dan Non Medik)") + } + if s.ChronicOrCatastrophicOrTerminal { + result = append(result, "Kasus Dengan Penyakit Kronis, Katastropik, Terminal") + } + if s.LowFunctionalStatus { + result = append(result, "Status Fungsional Rendah, Kebutuhan Bantuan ADL Tinggi") + } + if s.HistoryOfMedicalDeviceUse { + result = append(result, "Pasien Dengan Riwayat Penggunaan Peralatan Medis Masa Lalu") + } + if s.MentalOrSocialIssues { + result = append(result, "Riwayat Gangguan Mental, Bunuh Diri, Krisis Keluarga, Isu Sosial") + } + if s.FrequentERVisitsOrReadmission { + result = append(result, "Sering Masuk IGD, Readmisi RS") + } + if s.HighCareCostEstimate { + result = append(result, "Perkiraan Asuhan Dengan Biaya Tinggi") + } + if s.ComplexFinancingSystem { + result = append(result, "Kemungkinan Sistem Pembiayaan Yang Kompleks") + } + if s.AboveAverageLengthOfStay { + result = append(result, "Kasus Yang Melebihi Rata-Rata Lama Dirawat") + } + if s.ImportantOrHighRiskDischargePlanning { + result = append(result, "Rencana Pemulangan Penting / Kontinuitas Pelayanan") + } + if s.Stagnation { + result = append(result, "Stagnasi") + } + + return result +} + +func (p ProblemIdentification) SelectedProblemLabels() []string { + result := []string{} + + if p.CareNotFollowingGuidelines { + result = append(result, "Tingkat Asuhan Tidak Sesuai Panduan/ Norma") + } + if p.OverUtilization { + result = append(result, "Over Utilization Pelayanan") + } + if p.UnderUtilization { + result = append(result, "Under Utilization Pelayanan") + } + if p.PatientNonCompliance { + result = append(result, "Ketidakpatuhan Pasien") + } + if p.InadequateEducation { + result = append(result, "Edukasi Kurang Memadai") + } + if p.LackOfFamilySupport { + result = append(result, "Kurang Dukungan Keluarga") + } + if p.DecreasedDetermination { + result = append(result, "Penurunan Determinasi Ketika Komplikasi Meningkat") + } + if p.FinancialDifficultyDuringComplications { + result = append(result, "Kendala Keuangan Ketika Komplikasi Meningkat") + } + if p.DischargeCriteriaNotMetOrDelayed { + result = append(result, "Pemulangan/ Rujukan Belum Memenuhi Kriteria/ Ditunda") + } + + return result +} diff --git a/internal/use-case/main-use-case/generate-file/helper.go b/internal/use-case/main-use-case/generate-file/helper.go index 6edd34d8..76e4f5ee 100644 --- a/internal/use-case/main-use-case/generate-file/helper.go +++ b/internal/use-case/main-use-case/generate-file/helper.go @@ -13,6 +13,7 @@ import ( ee "simrs-vx/internal/domain/main-entities/encounter" egc "simrs-vx/internal/domain/main-entities/general-consent" er "simrs-vx/internal/domain/main-entities/resume" + es "simrs-vx/internal/domain/main-entities/screening" uvs "simrs-vx/internal/use-case/bpjs-use-case/vclaim-sep" uvscl "simrs-vx/internal/use-case/bpjs-use-case/vclaim-sep-control-letter" @@ -339,3 +340,42 @@ func generateResumeTemplateData(resume er.Resume, event pl.Event, tx *gorm.DB) ( return &templateData, nil } + +func generateScreeningFormATemplateData(screening es.Screening, event pl.Event, tx *gorm.DB) (*ScreeningPDF, error) { + // get encounter + includes := "Patient,Patient.Person" + encounter, err := ue.ReadDetailData(ee.ReadDetailDto{Id: *screening.Encounter_Id, Includes: includes}, &event) + if err != nil { + return nil, err + } + + // map template data + sData := es.FormA{} + if screening.Value != nil { + err := json.Unmarshal([]byte(*screening.Value), &sData) + if err != nil { + event.ErrInfo = pl.ErrorInfo{ + Code: "data-unmarshal-fail", + Detail: err.Error(), + Raw: err, + } + return nil, err + } + } else { + return nil, errors.New("there is no data to be used") + } + + templateData := ScreeningPDF{} + templateData.IssuedDate = pu.GetTimeNow().Format("2006-01-02 15:04:05") + templateData.MedicalRecord = *encounter.Patient.Number + templateData.Name = encounter.Patient.Person.FullName() + templateData.BirthDate = encounter.Patient.Person.BirthDate.Format("2006-01-02 15:04:05") + templateData.Employee_Name = screening.Employee.Person.FullName() + templateData.EarlyMedic = sData.Screening.SelectedScreeningLabels() + templateData.Assessment = sData.AssessmentDetail + templateData.ProblemIdentification = sData.ProblemIdentification.SelectedProblemLabels() + templateData.Planning = sData.PlanningDetail + templateData.Date = screening.CreatedAt.Format("2006-01-02 15:04:05") + + return &templateData, nil +} diff --git a/internal/use-case/main-use-case/generate-file/tycovar.go b/internal/use-case/main-use-case/generate-file/tycovar.go index a242f476..d5a7220e 100644 --- a/internal/use-case/main-use-case/generate-file/tycovar.go +++ b/internal/use-case/main-use-case/generate-file/tycovar.go @@ -72,6 +72,19 @@ type ResumePDF struct { Date string } +type ScreeningPDF struct { + IssuedDate string + Date string + MedicalRecord string + Name string + BirthDate string + Employee_Name string + EarlyMedic []string + Assessment string + ProblemIdentification []string + Planning string +} + type GenerateDto struct { EntityType_Code ere.EntityTypeCode `json:"entityType_code" validate:"required"` Ref_Id *string `json:"ref_id" validate:"required"` @@ -124,6 +137,8 @@ const ( TDNGC TemplateDocsName = "general-consent.html" TDNCL TemplateDocsName = "control-letter.html" TDNR TemplateDocsName = "resume.html" + TDNSA TemplateDocsName = "screening-form-a.html" + TDNSB TemplateDocsName = "screening-form-b.html" ) func (v VclaimControlLetter) generateTemplateData() ControlLetterPDF { From 5975721daf1defff62cbb93efce8b23025a27c7d Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Wed, 3 Dec 2025 16:10:23 +0700 Subject: [PATCH 06/45] feat (generate-file): screening form a tested and ok, form b not fully tested --- assets/docs/screening-form-a.html | 8 +- assets/docs/screening-form-b.html | 142 ++++++++---------- .../domain/main-entities/screening/dto.go | 8 +- .../domain/main-entities/screening/entity.go | 4 +- .../interface/main-handler/main-handler.go | 4 +- .../main-handler/screening/handler.go | 34 ++--- .../main-use-case/generate-file/case.go | 6 + .../main-use-case/generate-file/helper.go | 139 ++++++++++++++--- .../main-use-case/generate-file/tycovar.go | 8 + .../use-case/main-use-case/screening/lib.go | 4 +- pkg/pdf-helper/pdf-helper.go | 3 + 11 files changed, 228 insertions(+), 132 deletions(-) diff --git a/assets/docs/screening-form-a.html b/assets/docs/screening-form-a.html index a838c111..4f34b876 100644 --- a/assets/docs/screening-form-a.html +++ b/assets/docs/screening-form-a.html @@ -56,17 +56,17 @@ " > - No. RM + No. RM : - {{ .MedicalRecord }} + {{ .MedicalRecord }} - Nama + Nama : {{ .Name }} - Tanggal Lahir + Tanggal Lahir : {{ .BirthDate }} diff --git a/assets/docs/screening-form-b.html b/assets/docs/screening-form-b.html index 1ae8a07c..9abc94ce 100644 --- a/assets/docs/screening-form-b.html +++ b/assets/docs/screening-form-b.html @@ -33,94 +33,76 @@ - - - - - - - - - - - - - - - - - - - - - -
- Tanggal Terbit - : {{ .Repalcable }}
- No. RM - : {{ .Repalcable }}
- Nama - : {{ .Repalcable }}
- Tanggal Lahir - : {{ .Repalcable }}
- -
-

- FORM B -

+ Tanggal Terbit : {{ .IssuedDate }} + - + +
- - - - + + + - - - - + + + + + + + +
- NO - - Tanggal/jam - - Implementasi, Monitoring, Fasilitasi, koordinasi, komunikasi dan kolaborasi, advokasi, hasil pelayanan, - Terminasi - - MPP - No. RM:{{ .MedicalRecord }}
- 1 - - 2025-10-08 16:08:18 - -
    -
  • Implementasi: Pemantauan harian terhadap penggunaan alat medis (oksigen dan alat bantu - jalan) serta kepatuhan terapi.
  • -
  • Monitoring: Observasi respon pasien terhadap terapi dan edukasi keluarga untuk perawatan - mandiri di rumah.
  • -
  • Fasilitasi: Menyediakan alat bantu sesuai kebutuhan dan menghubungkan pasien dengan - layanan rehabilitasi medik.
  • -
  • Koordinasi: Melibatkan dokter penanggung jawab, perawat, dan keluarga dalam penyusunan - rencana tindak lanjut.
  • -
  • Komunikasi dan Kolaborasi: Diskusi rutin antar profesi untuk evaluasi perkembangan - pasien.
  • -
  • Advokasi: Memberikan dukungan informasi dan hak pasien terkait rencana pulang dan - kesinambungan terapi.
  • -
  • Hasil Pelayanan: Pasien menunjukkan perbaikan fungsi mobilitas, tingkat kepatuhan terapi - meningkat.
  • -
-
- GATOT SUBROTO,AMd.Kep - Nama:{{ .Name }}
Tanggal Lahir:{{ .BirthDate }}
+ + + + + + + + + + {{ range .FormB }} + + + + + + + + + {{ end }} + +
NOTanggal/jam + Implementasi, Monitoring, Fasilitasi, koordinasi, komunikasi dan kolaborasi, + advokasi, hasil pelayanan, Terminasi + MPP
{{ .Number }}{{ .Date }} + {{ .Value }} + + {{ .Employee_Name }} +
+
diff --git a/internal/domain/main-entities/screening/dto.go b/internal/domain/main-entities/screening/dto.go index b001af39..0c4310ed 100644 --- a/internal/domain/main-entities/screening/dto.go +++ b/internal/domain/main-entities/screening/dto.go @@ -27,6 +27,7 @@ type CreateDto struct { type ReadListDto struct { FilterDto Includes string `json:"includes"` + Sort string `json:"sort"` Pagination ecore.Pagination } @@ -38,16 +39,17 @@ type FilterDto struct { } type ReadDetailDto struct { - Id uint16 `json:"id"` + Id uint `json:"id"` + Includes string `json:"includes"` } type UpdateDto struct { - Id uint16 `json:"id"` + Id uint `json:"id"` CreateDto } type DeleteDto struct { - Id uint16 `json:"id"` + Id uint `json:"id"` } type MetaDto struct { diff --git a/internal/domain/main-entities/screening/entity.go b/internal/domain/main-entities/screening/entity.go index fa650165..007573c4 100644 --- a/internal/domain/main-entities/screening/entity.go +++ b/internal/domain/main-entities/screening/entity.go @@ -19,4 +19,6 @@ type Screening struct { FileUrl *string `json:"fileUrl" gorm:"size:1024"` } -// func (d Screening) UnMarshal(data []byte) (error {} +func (d Screening) IsFormA() bool { + return d.Type == erc.SFTCA +} diff --git a/internal/interface/main-handler/main-handler.go b/internal/interface/main-handler/main-handler.go index 8864fcbb..55342b0f 100644 --- a/internal/interface/main-handler/main-handler.go +++ b/internal/interface/main-handler/main-handler.go @@ -316,7 +316,9 @@ func SetRoutes() http.Handler { "PATCH /{id}/validate": resume.Validate, }) hk.GroupRoutes("/v1/screening", r, auth.GuardMW, hk.MapHandlerFunc{ - "POST /": screening.O.Create, + "POST /": screening.O.Create, + "GET /": screening.O.GetList, + "GET /{id}": screening.O.GetDetail, }) /******************** actor ********************/ hc.RegCrud(r, "/v1/person", person.O) diff --git a/internal/interface/main-handler/screening/handler.go b/internal/interface/main-handler/screening/handler.go index 29ea5c73..a6866cc9 100644 --- a/internal/interface/main-handler/screening/handler.go +++ b/internal/interface/main-handler/screening/handler.go @@ -4,7 +4,7 @@ import ( "net/http" rw "github.com/karincake/risoles" - // sf "github.com/karincake/semprit" + sf "github.com/karincake/semprit" // ua "github.com/karincake/tumpeng/auth/svc" @@ -34,23 +34,23 @@ func (obj myBase) Create(w http.ResponseWriter, r *http.Request) { rw.DataResponse(w, res, err) } -// func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { -// dto := e.ReadListDto{} -// sf.UrlQueryParam(&dto, *r.URL) -// res, err := u.ReadList(dto) -// rw.DataResponse(w, res, err) -// } +func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { + dto := e.ReadListDto{} + sf.UrlQueryParam(&dto, *r.URL) + res, err := u.ReadList(dto) + rw.DataResponse(w, res, err) +} -// func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { -// id := rw.ValidateInt(w, "id", r.PathValue("id")) -// if id <= 0 { -// return -// } -// dto := e.ReadDetailDto{} -// dto.Id = uint16(id) -// res, err := u.ReadDetail(dto) -// rw.DataResponse(w, res, err) -// } +func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { + id := rw.ValidateInt(w, "id", r.PathValue("id")) + if id <= 0 { + return + } + dto := e.ReadDetailDto{} + dto.Id = uint(id) + res, err := u.ReadDetail(dto) + rw.DataResponse(w, res, err) +} // func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { // id := rw.ValidateInt(w, "id", r.PathValue("id")) diff --git a/internal/use-case/main-use-case/generate-file/case.go b/internal/use-case/main-use-case/generate-file/case.go index 7c657640..b5103746 100644 --- a/internal/use-case/main-use-case/generate-file/case.go +++ b/internal/use-case/main-use-case/generate-file/case.go @@ -51,6 +51,12 @@ func Generate(input GenerateDto) (*d.Data, error) { return err } + // screening + case ere.DTCScreening: + response, err = generateScreening(input, event, tx) + if err != nil { + return err + } default: return errors.New("invalid type code") } diff --git a/internal/use-case/main-use-case/generate-file/helper.go b/internal/use-case/main-use-case/generate-file/helper.go index 76e4f5ee..a0e7c1e2 100644 --- a/internal/use-case/main-use-case/generate-file/helper.go +++ b/internal/use-case/main-use-case/generate-file/helper.go @@ -20,7 +20,9 @@ import ( ue "simrs-vx/internal/use-case/main-use-case/encounter" ugc "simrs-vx/internal/use-case/main-use-case/general-consent" ur "simrs-vx/internal/use-case/main-use-case/resume" + us "simrs-vx/internal/use-case/main-use-case/screening" + ercl "simrs-vx/internal/domain/references/clinical" erc "simrs-vx/internal/domain/references/common" docscfg "simrs-vx/internal/infra/docs-cfg" @@ -341,41 +343,130 @@ func generateResumeTemplateData(resume er.Resume, event pl.Event, tx *gorm.DB) ( return &templateData, nil } -func generateScreeningFormATemplateData(screening es.Screening, event pl.Event, tx *gorm.DB) (*ScreeningPDF, error) { +func generateScreeningTemplateData(screenings []es.Screening, event pl.Event, tx *gorm.DB) (*ScreeningPDF, error) { // get encounter includes := "Patient,Patient.Person" - encounter, err := ue.ReadDetailData(ee.ReadDetailDto{Id: *screening.Encounter_Id, Includes: includes}, &event) + encounter, err := ue.ReadDetailData(ee.ReadDetailDto{Id: *screenings[0].Encounter_Id, Includes: includes}, &event) if err != nil { return nil, err } - // map template data - sData := es.FormA{} - if screening.Value != nil { - err := json.Unmarshal([]byte(*screening.Value), &sData) - if err != nil { - event.ErrInfo = pl.ErrorInfo{ - Code: "data-unmarshal-fail", - Detail: err.Error(), - Raw: err, + switch screenings[0].Type { + case ercl.SFTCA: + // map template data + sData := es.FormA{} + if screenings[0].Value != nil { + err := json.Unmarshal([]byte(*screenings[0].Value), &sData) + if err != nil { + event.ErrInfo = pl.ErrorInfo{ + Code: "data-unmarshal-fail", + Detail: err.Error(), + Raw: err, + } + return nil, err } + } else { + return nil, errors.New("there is no data to be used") + } + + templateData := ScreeningPDF{} + templateData.IssuedDate = pu.GetTimeNow().Format("2006-01-02 15:04:05") + templateData.MedicalRecord = *encounter.Patient.Number + templateData.Name = encounter.Patient.Person.FullName() + templateData.BirthDate = encounter.Patient.Person.BirthDate.Format("2006-01-02 15:04:05") + templateData.Employee_Name = screenings[0].Employee.Person.FullName() + templateData.EarlyMedic = sData.Screening.SelectedScreeningLabels() + templateData.Assessment = sData.AssessmentDetail + templateData.ProblemIdentification = sData.ProblemIdentification.SelectedProblemLabels() + templateData.Planning = sData.PlanningDetail + templateData.Date = screenings[0].CreatedAt.Format("2006-01-02 15:04:05") + + return &templateData, nil + case ercl.SFTCB: + // map template data + templateData := ScreeningPDF{} + templateData.IssuedDate = pu.GetTimeNow().Format("2006-01-02 15:04:05") + templateData.MedicalRecord = *encounter.Patient.Number + templateData.Name = encounter.Patient.Person.FullName() + templateData.BirthDate = encounter.Patient.Person.BirthDate.Format("2006-01-02 15:04:05") + for k, v := range screenings { + templateData.FormB = append(templateData.FormB, ScreeningFormBPDF{ + Number: k + 1, + Date: v.CreatedAt.Format("2006-01-02 15:04:05"), + Employee_Name: v.Employee.Person.FullName(), + Value: *v.Value, + }) + } + + return &templateData, nil + } + return nil, errors.New("invalid screening type") +} + +func generateScreening(input GenerateDto, event pl.Event, tx *gorm.DB) (*ResponseDto, error) { + // get value from resume by ref_id + includes := "Employee.Person" + s, err := us.ReadDetailData(es.ReadDetailDto{Id: uint(*pc.StringToUint64(*input.Ref_Id)), Includes: includes}, &event) + if err != nil { + return nil, err + } + + var screenings []es.Screening + var templateData *ScreeningPDF + if s.IsFormA() { + if s.FileUrl != nil { + if err := removeFile(string(input.EntityType_Code), *s.FileUrl); err != nil { + return nil, err + } + } + screenings = append(screenings, *s) + input.FormatType = erc.DFTCPDF + input.TemplateName = TDNSA + input.Encounter_Id = s.Encounter_Id + templateData, err = generateScreeningTemplateData(screenings, event, tx) + if err != nil { return nil, err } } else { - return nil, errors.New("there is no data to be used") + includes := "Employee.Person" + sort := "CreatedAt:ASC" + ss, _, err := us.ReadListData(es.ReadListDto{FilterDto: es.FilterDto{Encounter_Id: s.Encounter_Id, Type: ercl.SFTCB}, Includes: includes, Sort: sort}, &event, tx) + if err != nil { + return nil, err + } + screenings = append(screenings, ss...) + input.FormatType = erc.DFTCPDF + input.TemplateName = TDNSB + input.Encounter_Id = s.Encounter_Id + templateData, err = generateScreeningTemplateData(screenings, event, tx) + if err != nil { + return nil, err + } } - templateData := ScreeningPDF{} - templateData.IssuedDate = pu.GetTimeNow().Format("2006-01-02 15:04:05") - templateData.MedicalRecord = *encounter.Patient.Number - templateData.Name = encounter.Patient.Person.FullName() - templateData.BirthDate = encounter.Patient.Person.BirthDate.Format("2006-01-02 15:04:05") - templateData.Employee_Name = screening.Employee.Person.FullName() - templateData.EarlyMedic = sData.Screening.SelectedScreeningLabels() - templateData.Assessment = sData.AssessmentDetail - templateData.ProblemIdentification = sData.ProblemIdentification.SelectedProblemLabels() - templateData.Planning = sData.PlanningDetail - templateData.Date = screening.CreatedAt.Format("2006-01-02 15:04:05") + // generate file + urlPub, err := generateFile(input, templateData) + if err != nil { + return nil, err + } - return &templateData, nil + if len(screenings) > 1 { + for i := range screenings { + screenings[i].FileUrl = &urlPub + } + if err := tx.Save(&screenings).Error; err != nil { + return nil, err + } + } else { + s.FileUrl = &urlPub + if err := tx.Save(&s).Error; err != nil { + return nil, err + } + } + + response := ResponseDto{ + FileUrl: urlPub, + } + + return &response, nil } diff --git a/internal/use-case/main-use-case/generate-file/tycovar.go b/internal/use-case/main-use-case/generate-file/tycovar.go index d5a7220e..a8fd5ef5 100644 --- a/internal/use-case/main-use-case/generate-file/tycovar.go +++ b/internal/use-case/main-use-case/generate-file/tycovar.go @@ -83,6 +83,14 @@ type ScreeningPDF struct { Assessment string ProblemIdentification []string Planning string + FormB []ScreeningFormBPDF +} + +type ScreeningFormBPDF struct { + Number int + Date string + Employee_Name string + Value string } type GenerateDto struct { diff --git a/internal/use-case/main-use-case/screening/lib.go b/internal/use-case/main-use-case/screening/lib.go index 413e84d2..31ed6ee1 100644 --- a/internal/use-case/main-use-case/screening/lib.go +++ b/internal/use-case/main-use-case/screening/lib.go @@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Sc 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 { @@ -81,7 +81,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e tx = dg.I } - if err := tx.First(&data, input.Id).Error; err != nil { + if err := tx.Scopes(gh.Preload(input.Includes)).First(&data, input.Id).Error; err != nil { if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil { return nil, processedErr } diff --git a/pkg/pdf-helper/pdf-helper.go b/pkg/pdf-helper/pdf-helper.go index 9878ecbd..9b1dc129 100644 --- a/pkg/pdf-helper/pdf-helper.go +++ b/pkg/pdf-helper/pdf-helper.go @@ -33,6 +33,9 @@ func (r *RequestPdf) ParseTemplate(templatePath string, data interface{}) error "nl2br": func(text string) template.HTML { return template.HTML(strings.Replace(template.HTMLEscapeString(text), "\n", "
", -1)) }, + "safeHTML": func(text string) template.HTML { + return template.HTML(text) + }, } t, err := template.New(fileName).Funcs(funcs).ParseFiles(templatePath) if err != nil { From 203b6f51d5a046246ab504d78aac94c792861bd0 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Wed, 3 Dec 2025 17:32:36 +0700 Subject: [PATCH 07/45] feat (encounter): add filter by range registered at, and patient name --- internal/domain/main-entities/encounter/dto.go | 7 +++++-- internal/use-case/main-use-case/encounter/lib.go | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/internal/domain/main-entities/encounter/dto.go b/internal/domain/main-entities/encounter/dto.go index 8dd9a0a1..c039fc0c 100644 --- a/internal/domain/main-entities/encounter/dto.go +++ b/internal/domain/main-entities/encounter/dto.go @@ -78,8 +78,11 @@ type TRujukan struct { type ReadListDto struct { FilterDto - Includes string `json:"includes"` - Pagination ecore.Pagination + Includes string `json:"includes"` + Pagination ecore.Pagination + Person_Name *string `json:"person-name"` + StartDate *string `json:"start-date"` + EndDate *string `json:"end-date"` pa.AuthInfo } diff --git a/internal/use-case/main-use-case/encounter/lib.go b/internal/use-case/main-use-case/encounter/lib.go index 0b14b925..0ea8988d 100644 --- a/internal/use-case/main-use-case/encounter/lib.go +++ b/internal/use-case/main-use-case/encounter/lib.go @@ -65,7 +65,20 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.En tx.Where("\"Responsible_Doctor_Code\" = ?", *input.AuthInfo.Doctor_Code) // } - tx.Scopes(gh.Preload(input.Includes)). + if input.StartDate != nil && input.EndDate != nil { + tx = tx.Where( + "DATE(\"RegisteredAt\") >= DATE(?) AND DATE(\"RegisteredAt\") <= DATE(?)", + input.StartDate, + input.EndDate, + ) + } + + if input.Person_Name != nil { + tx = tx.Joins("JOIN \"Patient\" ON \"Patient\".\"Id\" = \"Encounter\".\"Patient_Id\""). + Joins("JOIN \"Person\" ON \"Person\".\"Id\" = \"Patient\".\"Person_Id\"").Where("\"Person\".\"Name\" ILIKE ?", "%"+*input.Person_Name+"%") + } + + tx = tx.Debug().Scopes(gh.Preload(input.Includes)). Scopes(gh.Filter(input.FilterDto)). Count(&count). Scopes(gh.Paginate(input, &pagination)). From 8dba52cc176d0292ddeff5d5734efc7ba3f03778 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Thu, 4 Dec 2025 03:52:51 +0700 Subject: [PATCH 08/45] feat/order-things: adjust table structure --- cmd/main-migration/migrations/20251203205052.sql | 4 ++++ cmd/main-migration/migrations/atlas.sum | 3 ++- .../procedure-room-order-item/base/entity.go | 12 ++++++++++++ .../procedure-room-order-item/entity.go | 11 +++++------ .../main-entities/procedure-room-order/dto.go | 12 ++++++------ .../main-entities/procedure-room-order/entity.go | 15 ++++++++------- .../domain/main-entities/procedure-room/dto.go | 2 +- 7 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 cmd/main-migration/migrations/20251203205052.sql create mode 100644 internal/domain/main-entities/procedure-room-order-item/base/entity.go diff --git a/cmd/main-migration/migrations/20251203205052.sql b/cmd/main-migration/migrations/20251203205052.sql new file mode 100644 index 00000000..831497a2 --- /dev/null +++ b/cmd/main-migration/migrations/20251203205052.sql @@ -0,0 +1,4 @@ +-- Modify "ProcedureRoomOrder" table +ALTER TABLE "public"."ProcedureRoomOrder" DROP COLUMN "Infra_Code"; +-- Modify "ProcedureRoomOrderItem" table +ALTER TABLE "public"."ProcedureRoomOrderItem" ADD CONSTRAINT "fk_ProcedureRoomOrderItem_ProcedureRoomOrder" FOREIGN KEY ("ProcedureRoomOrder_Id") REFERENCES "public"."ProcedureRoomOrder" ("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 341a35d3..3ec1b876 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:DgMML95zGYI7JMvZaIb/gySCvncMu62CANOIXNX0A6w= +h1:qjr3k9/ymXjw1nopw49c6+fWtu0n+H8sQgsioqUC9Fo= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -144,3 +144,4 @@ h1:DgMML95zGYI7JMvZaIb/gySCvncMu62CANOIXNX0A6w= 20251202160848.sql h1:Kd2/TziKSMezrt4XgbjQcYvY/Lo9rX0qw7/Lz0/oyKk= 20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM= 20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= +20251203205052.sql h1:az/hGpk7u4YKT7gU+UuEw9guqB9AqdckPF1cYavQ3CA= diff --git a/internal/domain/main-entities/procedure-room-order-item/base/entity.go b/internal/domain/main-entities/procedure-room-order-item/base/entity.go new file mode 100644 index 00000000..cd54e456 --- /dev/null +++ b/internal/domain/main-entities/procedure-room-order-item/base/entity.go @@ -0,0 +1,12 @@ +package procedureroomorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" +) + +type ProcedureRoomOrderItem struct { + ecore.BigMain + ProcedureRoomOrder_Id uint64 `json:"procedureRoomOrder_id"` + ProcedureRoom_Code string `json:"procedureRoom_code" gorm:"size:20"` + Note string `json:"note" gorm:"size:255"` +} diff --git a/internal/domain/main-entities/procedure-room-order-item/entity.go b/internal/domain/main-entities/procedure-room-order-item/entity.go index 4a737048..13b4978b 100644 --- a/internal/domain/main-entities/procedure-room-order-item/entity.go +++ b/internal/domain/main-entities/procedure-room-order-item/entity.go @@ -1,14 +1,13 @@ package procedureroomorder import ( - ecore "simrs-vx/internal/domain/base-entities/core" epr "simrs-vx/internal/domain/main-entities/procedure-room" + epro "simrs-vx/internal/domain/main-entities/procedure-room-order" + eb "simrs-vx/internal/domain/main-entities/procedure-room-order-item/base" ) type ProcedureRoomOrderItem struct { - ecore.BigMain - ProcedureRoomOrder_Id uint64 `json:"procedureRoomOrder_id"` - ProcedureRoom_Code string `json:"procedureRoom_code" gorm:"size:20"` - ProcedureRoom *epr.ProcedureRoom `json:"procedureRoom,omitempty" gorm:"foreignKey:ProcedureRoom_Code;references:Code"` - Note string `json:"note" gorm:"size:255"` + eb.ProcedureRoomOrderItem + ProcedureRoomOrder *epro.ProcedureRoomOrder `json:"procedureRoomOrder,omitempty" gorm:"foreignKey:ProcedureRoomOrder_Id;references:Id"` + ProcedureRoom *epr.ProcedureRoom `json:"procedureRoom,omitempty" gorm:"foreignKey:ProcedureRoom_Code;references:Code"` } diff --git a/internal/domain/main-entities/procedure-room-order/dto.go b/internal/domain/main-entities/procedure-room-order/dto.go index 5810e756..4482081c 100644 --- a/internal/domain/main-entities/procedure-room-order/dto.go +++ b/internal/domain/main-entities/procedure-room-order/dto.go @@ -9,9 +9,9 @@ import ( ) type CreateDto struct { - Encounter_Id uint64 `json:"encounter_id" validate:"required"` - Infra_Code string `json:"infra_code" validate:"required"` - MaterialPackage_Code string `json:"materialPackage_code" validate:"required"` + Encounter_Id uint64 `json:"encounter_id" validate:"required"` + // Infra_Code string `json:"infra_code" validate:"required"` + MaterialPackage_Code *string `json:"materialPackage_code"` } type ReadListDto struct { @@ -48,7 +48,7 @@ type ResponseDto struct { Encounter_Id uint64 `json:"encounter_id"` Encounter *ec.Encounter `json:"encounter,omitempty"` Infra_Code string `json:"procedure"` - MaterialPackage_Code string `json:"materialPackage_code"` + MaterialPackage_Code *string `json:"materialPackage_code"` Status_Code erc.DataStatusCode `json:"status_code"` ProcedureRoom *epr.ProcedureRoom `json:"procedureRoom,omitempty"` MaterialPackage *emp.MaterialPackage `json:"materialPackage,omitempty"` @@ -56,8 +56,8 @@ type ResponseDto struct { func (d ProcedureRoomOrder) ToResponse() ResponseDto { resp := ResponseDto{ - Encounter_Id: d.Encounter_Id, - Infra_Code: d.Infra_Code, + Encounter_Id: d.Encounter_Id, + // Infra_Code: d.Infra_Code, MaterialPackage_Code: d.MaterialPackage_Code, Status_Code: d.Status_Code, } diff --git a/internal/domain/main-entities/procedure-room-order/entity.go b/internal/domain/main-entities/procedure-room-order/entity.go index 1ef7c178..5d2c8ba7 100644 --- a/internal/domain/main-entities/procedure-room-order/entity.go +++ b/internal/domain/main-entities/procedure-room-order/entity.go @@ -5,15 +5,16 @@ import ( ecore "simrs-vx/internal/domain/base-entities/core" emp "simrs-vx/internal/domain/main-entities/material-package" - epr "simrs-vx/internal/domain/main-entities/procedure-room" + eproi "simrs-vx/internal/domain/main-entities/procedure-room-order-item/base" ) type ProcedureRoomOrder struct { ecore.BigMain - Encounter_Id uint64 `json:"encounter_id"` - Infra_Code string `json:"infra_code" gorm:"size:20"` - ProcedureRoom *epr.ProcedureRoom `json:"procedureRoom,omitempty" gorm:"foreignKey:Infra_Code;references:Code"` - MaterialPackage_Code string `json:"materialPackage_code" gorm:"size:20"` - MaterialPackage *emp.MaterialPackage `json:"materialPackage,omitempty" gorm:"foreignKey:MaterialPackage_Code;references:Code"` - Status_Code erc.DataStatusCode `json:"status_code" gorm:"size:20"` + Encounter_Id uint64 `json:"encounter_id"` + // Infra_Code string `json:"infra_code" gorm:"size:20"` + // ProcedureRoom *epr.ProcedureRoom `json:"procedureRoom,omitempty" gorm:"foreignKey:Infra_Code;references:Code"` + MaterialPackage_Code *string `json:"materialPackage_code" gorm:"size:20"` + MaterialPackage *emp.MaterialPackage `json:"materialPackage,omitempty" gorm:"foreignKey:MaterialPackage_Code;references:Code"` + Status_Code erc.DataStatusCode `json:"status_code" gorm:"size:20"` + Items []eproi.ProcedureRoomOrderItem `json:"items,omitempty" gorm:"foreignKey:ProcedureRoomOrder_Id;references:Id"` } diff --git a/internal/domain/main-entities/procedure-room/dto.go b/internal/domain/main-entities/procedure-room/dto.go index 373e6cd9..b3812db2 100644 --- a/internal/domain/main-entities/procedure-room/dto.go +++ b/internal/domain/main-entities/procedure-room/dto.go @@ -25,7 +25,7 @@ type ReadListDto struct { type FilterDto struct { Infra_Code *string `json:"infra-code"` - Type_Code string `json:"type_code"` + Type_Code string `json:"type-code"` Unit_Code *string `json:"unit-code"` Specialist_Code *string `json:"specialist-code"` Subspecialist_Code *string `json:"subspecialist-code"` From 2fdb5fc9e08061f41a04a9db31a6b3d4cd049030 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Thu, 4 Dec 2025 03:54:19 +0700 Subject: [PATCH 09/45] feat/order-things: added procedure-room flow --- .../interface/main-handler/main-handler.go | 2 + .../main-handler/procedure-room/handler.go | 71 +++++++++++++++++++ .../procedure-room-order/helper.go | 1 - 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 internal/interface/main-handler/procedure-room/handler.go diff --git a/internal/interface/main-handler/main-handler.go b/internal/interface/main-handler/main-handler.go index d7c482e0..b5ef823b 100644 --- a/internal/interface/main-handler/main-handler.go +++ b/internal/interface/main-handler/main-handler.go @@ -34,6 +34,7 @@ import ( practiceschedule "simrs-vx/internal/interface/main-handler/practice-schedule" prescription "simrs-vx/internal/interface/main-handler/prescription" prescriptionitem "simrs-vx/internal/interface/main-handler/prescription-item" + procedureroom "simrs-vx/internal/interface/main-handler/procedure-room" procedureroomorder "simrs-vx/internal/interface/main-handler/procedure-room-order" procedureroomorderitem "simrs-vx/internal/interface/main-handler/procedure-room-order-item" responsibledoctorhist "simrs-vx/internal/interface/main-handler/responsible-doctor-hist" @@ -271,6 +272,7 @@ func SetRoutes() http.Handler { "DELETE /{id}": materialorder.O.Delete, "PATCH /{id}/complete": materialorder.O.Complete, }) + hc.RegCrud(r, "/v1/procedure-room", procedureroom.O) hc.RegCrud(r, "/v1/procedure-room-order", procedureroomorder.O) hc.RegCrud(r, "/v1/procedure-room-order-item", procedureroomorderitem.O) hk.GroupRoutes("/v1/consultation", r, auth.GuardMW, hk.MapHandlerFunc{ diff --git a/internal/interface/main-handler/procedure-room/handler.go b/internal/interface/main-handler/procedure-room/handler.go new file mode 100644 index 00000000..6d6aeb1c --- /dev/null +++ b/internal/interface/main-handler/procedure-room/handler.go @@ -0,0 +1,71 @@ +package procedureroom + +import ( + "net/http" + + rw "github.com/karincake/risoles" + sf "github.com/karincake/semprit" + + // ua "github.com/karincake/tumpeng/auth/svc" + + e "simrs-vx/internal/domain/main-entities/procedure-room" + u "simrs-vx/internal/use-case/main-use-case/procedure-room" +) + +type myBase struct{} + +var O myBase + +func (obj myBase) Create(w http.ResponseWriter, r *http.Request) { + dto := e.CreateDto{} + if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { + return + } + res, err := u.Create(dto) + rw.DataResponse(w, res, err) +} + +func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) { + dto := e.ReadListDto{} + sf.UrlQueryParam(&dto, *r.URL) + res, err := u.ReadList(dto) + rw.DataResponse(w, res, err) +} + +func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) { + id := rw.ValidateInt(w, "id", r.PathValue("id")) + if id == 0 { + return + } + dto := e.ReadDetailDto{} + dto.Id = uint16(id) + res, err := u.ReadDetail(dto) + rw.DataResponse(w, res, err) +} + +func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { + id := rw.ValidateInt(w, "id", r.PathValue("id")) + if id == 0 { + return + } + + dto := e.UpdateDto{} + if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { + return + } + dto.Id = uint16(id) + res, err := u.Update(dto) + rw.DataResponse(w, res, err) +} + +func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { + id := rw.ValidateInt(w, "id", r.PathValue("id")) + if id == 0 { + return + } + + dto := e.DeleteDto{} + dto.Id = uint16(id) + res, err := u.Delete(dto) + rw.DataResponse(w, res, err) +} diff --git a/internal/use-case/main-use-case/procedure-room-order/helper.go b/internal/use-case/main-use-case/procedure-room-order/helper.go index 6e91b7e3..9f47d54d 100644 --- a/internal/use-case/main-use-case/procedure-room-order/helper.go +++ b/internal/use-case/main-use-case/procedure-room-order/helper.go @@ -19,7 +19,6 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ProcedureRoomOrder) } data.Encounter_Id = inputSrc.Encounter_Id - data.Infra_Code = inputSrc.Infra_Code data.MaterialPackage_Code = inputSrc.MaterialPackage_Code data.Status_Code = erc.DSCNew } From b79c36ed0e3d613d6c484426a32a05152340cafe Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Thu, 4 Dec 2025 10:32:51 +0700 Subject: [PATCH 10/45] feat/order-things: adjust procedure-room-order --- .../procedure-room-order-item/dto.go | 3 +- .../procedure-room-order/entity.go | 4 ++ .../interface/main-handler/main-handler.go | 9 ++- .../procedure-room-order/handler.go | 12 ++++ .../procedure-room-order/case.go | 66 ++++++++++++++++++- 5 files changed, 90 insertions(+), 4 deletions(-) diff --git a/internal/domain/main-entities/procedure-room-order-item/dto.go b/internal/domain/main-entities/procedure-room-order-item/dto.go index 4b564ce6..83c4d094 100644 --- a/internal/domain/main-entities/procedure-room-order-item/dto.go +++ b/internal/domain/main-entities/procedure-room-order-item/dto.go @@ -18,7 +18,8 @@ type ReadListDto struct { } type FilterDto struct { - Encounter_Id uint64 `json:"encounter-id"` + Encounter_Id uint64 `json:"encounter-id"` + ProcedureRoomOrder_Id uint64 `json:"procedure-room-order-id"` } type ReadDetailDto struct { diff --git a/internal/domain/main-entities/procedure-room-order/entity.go b/internal/domain/main-entities/procedure-room-order/entity.go index 5d2c8ba7..5a4a8542 100644 --- a/internal/domain/main-entities/procedure-room-order/entity.go +++ b/internal/domain/main-entities/procedure-room-order/entity.go @@ -18,3 +18,7 @@ type ProcedureRoomOrder struct { Status_Code erc.DataStatusCode `json:"status_code" gorm:"size:20"` Items []eproi.ProcedureRoomOrderItem `json:"items,omitempty" gorm:"foreignKey:ProcedureRoomOrder_Id;references:Id"` } + +func (d ProcedureRoomOrder) IsNotNew() bool { + return d.Status_Code != erc.DSCNew +} diff --git a/internal/interface/main-handler/main-handler.go b/internal/interface/main-handler/main-handler.go index b5ef823b..0e637137 100644 --- a/internal/interface/main-handler/main-handler.go +++ b/internal/interface/main-handler/main-handler.go @@ -273,7 +273,14 @@ func SetRoutes() http.Handler { "PATCH /{id}/complete": materialorder.O.Complete, }) hc.RegCrud(r, "/v1/procedure-room", procedureroom.O) - hc.RegCrud(r, "/v1/procedure-room-order", procedureroomorder.O) + hk.GroupRoutes("/v1/procedure-room-order", r, auth.GuardMW, hk.MapHandlerFunc{ + "GET /": procedureroomorder.O.GetList, + "GET /{id}": procedureroomorder.O.GetDetail, + "POST /": procedureroomorder.O.Create, + "PATCH /{id}": procedureroomorder.O.Update, + "DELETE /{id}": procedureroomorder.O.Delete, + "PATCH /{id}/submit": procedureroomorder.O.Submit, + }) hc.RegCrud(r, "/v1/procedure-room-order-item", procedureroomorderitem.O) hk.GroupRoutes("/v1/consultation", r, auth.GuardMW, hk.MapHandlerFunc{ "GET /": consultation.O.GetList, diff --git a/internal/interface/main-handler/procedure-room-order/handler.go b/internal/interface/main-handler/procedure-room-order/handler.go index e50247a1..58c2c80b 100644 --- a/internal/interface/main-handler/procedure-room-order/handler.go +++ b/internal/interface/main-handler/procedure-room-order/handler.go @@ -69,3 +69,15 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) { res, err := u.Delete(dto) rw.DataResponse(w, res, err) } + +func (obj myBase) Submit(w http.ResponseWriter, r *http.Request) { + id := rw.ValidateInt(w, "id", r.PathValue("id")) + if id <= 0 { + return + } + + dto := e.ReadDetailDto{} + dto.Id = uint64(id) + res, err := u.Submit(dto) + rw.DataResponse(w, res, err) +} diff --git a/internal/use-case/main-use-case/procedure-room-order/case.go b/internal/use-case/main-use-case/procedure-room-order/case.go index 0724ce94..7e9e1952 100644 --- a/internal/use-case/main-use-case/procedure-room-order/case.go +++ b/internal/use-case/main-use-case/procedure-room-order/case.go @@ -1,16 +1,19 @@ package procedureroomorder import ( - e "simrs-vx/internal/domain/main-entities/procedure-room-order" + "errors" "strconv" + "gorm.io/gorm" + dg "github.com/karincake/apem/db-gorm-pg" d "github.com/karincake/dodol" pl "simrs-vx/pkg/logger" pu "simrs-vx/pkg/use-case-helper" - "gorm.io/gorm" + e "simrs-vx/internal/domain/main-entities/procedure-room-order" + erc "simrs-vx/internal/domain/references/common" ) const source = "procedure-room-order" @@ -274,3 +277,62 @@ func Delete(input e.DeleteDto) (*d.Data, error) { }, nil } + +func Submit(input e.ReadDetailDto) (*d.Data, error) { + var data *e.ProcedureRoomOrder + var err error + + event := pl.Event{ + Feature: "Process", + Source: source, + } + + // Start log + pl.SetLogInfo(&event, input, "started", "process") + + err = dg.I.Transaction(func(tx *gorm.DB) error { + data, err = ReadDetailData(input, &event, tx) + if err != nil { + return err + } + + if data.IsNotNew() { + event.Status = "failed" + event.ErrInfo = pl.ErrorInfo{ + Code: "data-state-mismatch", + Detail: source + " is not in new state", + Raw: errors.New(source + " is not in new state"), + } + return pl.SetLogError(&event, input) + } + + data.Status_Code = erc.DSCSubmited + if err := tx.Save(&data).Error; 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": "submited", + }, + Data: data.ToResponse(), + }, nil + +} From 521dbdd0a436f13e2d2be2e33a32bf730c6a5c2c Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Thu, 4 Dec 2025 11:13:08 +0700 Subject: [PATCH 11/45] fix (encounter): fix list --- internal/use-case/main-use-case/encounter/lib.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/use-case/main-use-case/encounter/lib.go b/internal/use-case/main-use-case/encounter/lib.go index 0ea8988d..a9a5a307 100644 --- a/internal/use-case/main-use-case/encounter/lib.go +++ b/internal/use-case/main-use-case/encounter/lib.go @@ -67,7 +67,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.En if input.StartDate != nil && input.EndDate != nil { tx = tx.Where( - "DATE(\"RegisteredAt\") >= DATE(?) AND DATE(\"RegisteredAt\") <= DATE(?)", + "DATE(\"Encounter\".\"RegisteredAt\") >= DATE(?) AND DATE(\"Encounter\".\"RegisteredAt\") <= DATE(?)", input.StartDate, input.EndDate, ) From 91e40cc2b747babde0af59f8156e2371542a3654 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Thu, 4 Dec 2025 13:11:54 +0700 Subject: [PATCH 12/45] fix (referral): typo json --- internal/domain/bpjs-entities/referral/entity.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/domain/bpjs-entities/referral/entity.go b/internal/domain/bpjs-entities/referral/entity.go index 8977ee31..680400b6 100644 --- a/internal/domain/bpjs-entities/referral/entity.go +++ b/internal/domain/bpjs-entities/referral/entity.go @@ -81,8 +81,8 @@ type Mr struct { } type Provider struct { - Kode string `json:"kdProvider" json:"kode"` // API sometimes uses different keys - NmProvider string `json:"nmProvider" json:"nama"` + Kode string `son:"kode"` + NmProvider string `json:"nama"` } type Poli struct { From 320ce99b0ee41a30c7818840d0681a2a9b12abf6 Mon Sep 17 00:00:00 2001 From: ari Date: Thu, 4 Dec 2025 13:52:24 +0700 Subject: [PATCH 13/45] update procedure report main api --- .../domain/main-entities/action-report/dto.go | 90 -------------- .../main-entities/action-report/entity.go | 51 -------- .../main-entities/procedure-report/dto.go | 110 ++++++++++++++++++ .../main-entities/procedure-report/entity.go | 68 +++++++++++ .../domain/references/clinical/clinical.go | 39 ++++--- .../interface/main-handler/main-handler.go | 4 +- .../handler.go | 4 +- internal/interface/migration/main-entities.go | 4 +- .../main-use-case/action-report/helper.go | 28 ----- .../case.go | 18 +-- .../main-use-case/procedure-report/helper.go | 39 +++++++ .../lib.go | 22 ++-- .../middleware-runner.go | 14 +-- .../middleware.go | 2 +- .../tycovar.go | 10 +- 15 files changed, 277 insertions(+), 226 deletions(-) delete mode 100644 internal/domain/main-entities/action-report/dto.go delete mode 100644 internal/domain/main-entities/action-report/entity.go create mode 100644 internal/domain/main-entities/procedure-report/dto.go create mode 100644 internal/domain/main-entities/procedure-report/entity.go rename internal/interface/main-handler/{action-report => procedure-report}/handler.go (93%) delete mode 100644 internal/use-case/main-use-case/action-report/helper.go rename internal/use-case/main-use-case/{action-report => procedure-report}/case.go (95%) create mode 100644 internal/use-case/main-use-case/procedure-report/helper.go rename internal/use-case/main-use-case/{action-report => procedure-report}/lib.go (83%) rename internal/use-case/main-use-case/{action-report => procedure-report}/middleware-runner.go (86%) rename internal/use-case/main-use-case/{action-report => procedure-report}/middleware.go (89%) rename internal/use-case/main-use-case/{action-report => procedure-report}/tycovar.go (74%) diff --git a/internal/domain/main-entities/action-report/dto.go b/internal/domain/main-entities/action-report/dto.go deleted file mode 100644 index 45c26d17..00000000 --- a/internal/domain/main-entities/action-report/dto.go +++ /dev/null @@ -1,90 +0,0 @@ -package actionreport - -import ( - ecore "simrs-vx/internal/domain/base-entities/core" - ee "simrs-vx/internal/domain/main-entities/encounter" - "time" - - pa "simrs-vx/internal/lib/auth" -) - -type CreateDto struct { - Encounter_Id uint64 `json:"encounter_id" validate:"required"` - Date *time.Time `json:"date" validate:"required"` - Doctor_Code string `json:"doctor_code" validate:"required"` - Operator_Employe_Id uint `json:"operator_employe_id" validate:"required"` - Assistant_Employe_Id uint `json:"assistant_employe_id" validate:"required"` - Instrumentor_Employe_Id uint `json:"instrumentor_employe_id" validate:"required"` - Diagnose *string `json:"diagnose"` - Nurse_Code string `json:"nurse_code" validate:"required"` - Value string `json:"value" validate:"required"` - - pa.AuthInfo -} - -type ReadListDto struct { - FilterDto - Includes string `json:"includes"` - Pagination ecore.Pagination -} - -type FilterDto struct { - Encounter_Id *uint `json:"encounter-id"` -} - -type ReadDetailDto struct { - Id uint16 `json:"id"` -} - -type UpdateDto struct { - Id uint16 `json:"id"` - CreateDto -} - -type DeleteDto struct { - Id uint16 `json:"id"` -} - -type MetaDto struct { - PageNumber int `json:"page_number"` - PageSize int `json:"page_size"` - Count int `json:"count"` -} - -type ResponseDto struct { - ecore.Main - Encounter_Id uint64 `json:"encounter_id"` - Encounter *ee.Encounter `json:"encounter,omitempty"` - Date *time.Time `json:"date"` - Doctor_Code string `json:"doctor_code"` - Operator_Employe_Id uint `json:"operator_employe_id"` - Assistant_Employe_Id uint `json:"assistant_employe_id"` - Instrumentor_Employe_Id uint `json:"instrumentor_employe_id"` - Diagnose *string `json:"diagnose"` - Nurse_Code string `json:"nurse_code"` - Value *string `json:"value"` -} - -func (d ActionReport) ToResponse() ResponseDto { - resp := ResponseDto{ - Encounter_Id: d.Encounter_Id, - Encounter: d.Encounter, - Date: d.Date, - Doctor_Code: d.Doctor_Code, - Operator_Employe_Id: d.Operator_Employe_Id, - Assistant_Employe_Id: d.Assistant_Employe_Id, - Instrumentor_Employe_Id: d.Instrumentor_Employe_Id, - Nurse_Code: d.Nurse_Code, - Value: &d.Value, - } - resp.Main = d.Main - return resp -} - -func ToResponseList(data []ActionReport) []ResponseDto { - resp := make([]ResponseDto, len(data)) - for i, u := range data { - resp[i] = u.ToResponse() - } - return resp -} diff --git a/internal/domain/main-entities/action-report/entity.go b/internal/domain/main-entities/action-report/entity.go deleted file mode 100644 index 8447a2e5..00000000 --- a/internal/domain/main-entities/action-report/entity.go +++ /dev/null @@ -1,51 +0,0 @@ -package actionreport - -import ( - ecore "simrs-vx/internal/domain/base-entities/core" - ed "simrs-vx/internal/domain/main-entities/doctor" - eem "simrs-vx/internal/domain/main-entities/employee" - ee "simrs-vx/internal/domain/main-entities/encounter" - en "simrs-vx/internal/domain/main-entities/nurse" - "time" -) - -type ActionReport struct { - ecore.Main // adjust this according to the needs - Encounter_Id uint64 `json:"encounter_id" gorm:"foreignKey"` - Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` - Date *time.Time `json:"date" gorm:"not null;size:20"` - Doctor_Code string `json:"doctor_code" gorm:"size:10"` - Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` - Operator_Employe_Id uint `json:"operator_employe_id"` - Operator_Employe *eem.Employee `json:"operator_employe,omitempty" gorm:"foreignKey:Operator_Employe_Id;references:Id"` - Assistant_Employe_Id uint `json:"assistant_employe_id"` - Instrumentor_Employe_Id uint `json:"instrumentor_employe_id"` - Instrumentor_Employe *eem.Employee `json:"instrumentor_employe,omitempty" gorm:"foreignKey:Instrumentor_Employe_Id;references:Id"` - Diagnose *string `json:"diagnose" gorm:"size:1024"` - Nurse_Code string `json:"nurse_code" gorm:"size:10"` - Nurse *en.Nurse `json:"nurse,omitempty" gorm:"foreignKey:Nurse_Code;references:Code"` - Value string `json:"value"` - // SurgerySize_Code *string `json:"surgerySize_code" gorm:"size:10"` - // Billing_Code *string `json:"billing_code" gorm:"size:10"` - // SurgerySystem_Code *string `json:"surgerySystem_code" gorm:"size:10"` - // StartAt *string `json:"startAt" gorm:"size:20"` - // EndAt *string `json:"endAt" gorm:"size:20"` - // AnesthesiaStartAt *string `json:"anesthesiaStartAt" gorm:"size:20"` - // AnesthesiaEndAt *string `json:"anesthesiaEndAt" gorm:"size:20"` - // SurgeryType_Code *string `json:"surgeryType_code" gorm:"size:10"` - // SurgeryStage_Code *string `json:"surgeryStage_code" gorm:"size:10"` - // BornMortality_Code *string `json:"bornMortality_code" gorm:"size:10"` - // BornLocation_Code *string `json:"bornLocation_code" gorm:"size:10"` - // Weight *string `json:"weight" gorm:"size:10"` - // BornNotes *string `json:"bornNotes" gorm:"size:1024"` - // Description *string `json:"notes" gorm:"size:1024"` - // BleedingAmount *uint16 `json:"bleedingAmount" gorm:"size:10"` - // BloodInType_Code *string `json:"bloodInType_code" gorm:"size:10"` - // BloodInAmount *uint16 `json:"bloodInAmount" gorm:"size:10"` - // Brand *string `json:"brand" gorm:"size:100"` - // ImplantName *string `json:"implantName" gorm:"size:100"` - // ImplantRegisterNumber *string `json:"implantRegisterNumber" gorm:"size:100"` - // ImplantCompanionName *string `json:"implantCompanionName" gorm:"size:100"` - // SpecimentDest_Code *string `json:"specimentDest" gorm:"size:100"` - // TissueInfo *string `json:"tissueInfo" gorm:"size:100"` -} diff --git a/internal/domain/main-entities/procedure-report/dto.go b/internal/domain/main-entities/procedure-report/dto.go new file mode 100644 index 00000000..9cd400be --- /dev/null +++ b/internal/domain/main-entities/procedure-report/dto.go @@ -0,0 +1,110 @@ +package procedurereport + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/encounter" + "time" + + pa "simrs-vx/internal/lib/auth" +) + +type CreateDto struct { + Encounter_Id uint64 `json:"encounter_id" validate:"required"` + Date *time.Time `json:"date" validate:"required"` + Doctor_Code string `json:"doctor_code" validate:"required"` + Operator_Name string `json:"operator_name" validate:"required"` + Assistant_Name string `json:"assistant_name" validate:"required"` + Instrumentor_Name string `json:"instrumentor_name" validate:"required"` + Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" validate:"required"` + Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name" validate:"required"` + Diagnose *string `json:"diagnose"` + Nurse_Name string `json:"nurse_name" validate:"required"` + ProcedureValue string `json:"procedure_value" validate:"required"` + ExecutionValue string `json:"execution_value" validate:"required"` + Type string `json:"type" validate:"required"` + + pa.AuthInfo + + // PROPER + // Operator_Employe_Id uint `json:"operator_employe_id" validate:"required"` + // Assistant_Employe_Id uint `json:"assistant_employe_id" validate:"required"` + // Instrumentor_Employe_Id uint `json:"instrumentor_employe_id" validate:"required"` + // Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" validate:"required"` + // Anesthesia_Nurse_Employe_Id uint `json:"anesthesia_nurse_employe_id" validate:"required"` + // Nurse_Code string `json:"nurse_code" validate:"required"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Encounter_Id *uint `json:"encounter-id"` +} + +type ReadDetailDto struct { + Id uint16 `json:"id"` +} + +type UpdateDto struct { + Id uint16 `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint16 `json:"id"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.Main + Encounter_Id uint64 `json:"encounter_id"` + Encounter *ee.Encounter `json:"encounter,omitempty"` + Date *time.Time `json:"date"` + Doctor_Code string `json:"doctor_code"` + Operator_Name string `json:"operator_name"` + Assistant_Name string `json:"assistant_name"` + Instrumentor_Name string `json:"instrumentor_name"` + Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code"` + Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name"` + Diagnose *string `json:"diagnose"` + Nurse_Name string `json:"nurse_name"` + ProcedureValue *string `json:"procedure_value"` + ExecutionValue *string `json:"execution_value"` + Type string `json:"type"` +} + +func (d ProcedureReport) ToResponse() ResponseDto { + resp := ResponseDto{ + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Date: d.Date, + Doctor_Code: d.Doctor_Code, + Operator_Name: d.Operator_Name, + Assistant_Name: d.Assistant_Name, + Instrumentor_Name: d.Instrumentor_Name, + Anesthesia_Doctor_Code: d.Anesthesia_Doctor_Code, + Anesthesia_Nurse_Name: d.Anesthesia_Nurse_Name, + Nurse_Name: d.Nurse_Name, + ProcedureValue: &d.ProcedureValue, + ExecutionValue: &d.ExecutionValue, + Type: d.Type, + } + resp.Main = d.Main + return resp +} + +func ToResponseList(data []ProcedureReport) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/procedure-report/entity.go b/internal/domain/main-entities/procedure-report/entity.go new file mode 100644 index 00000000..f25bf604 --- /dev/null +++ b/internal/domain/main-entities/procedure-report/entity.go @@ -0,0 +1,68 @@ +package procedurereport + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ed "simrs-vx/internal/domain/main-entities/doctor" + eem "simrs-vx/internal/domain/main-entities/employee" + ee "simrs-vx/internal/domain/main-entities/encounter" + "time" +) + +type ProcedureReport struct { + ecore.Main // adjust this according to the needs + Encounter_Id uint64 `json:"encounter_id" gorm:"foreignKey"` + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Date *time.Time `json:"date" gorm:"not null;size:20"` + Doctor_Code string `json:"doctor_code" gorm:"size:10"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` + Operator_Name string `json:"operator_name"` + Assistant_Name string `json:"assistant_name"` + Instrumentor_Name string `json:"instrumentor_name"` + Diagnose *string `json:"diagnose" gorm:"size:1024"` + Nurse_Name string `json:"nurse_code" gorm:"size:10"` + Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" gorm:"size:10"` + Anesthesia *eem.Employee `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` + Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name"` + ProcedureValue string `json:"procedure_value"` + ExecutionValue string `json:"execution_value"` + Type string `json:"type"` + + // SurgerySize_Code *string `json:"surgerySize_code" gorm:"size:10"` + // Billing_Code *string `json:"billing_code" gorm:"size:10"` + // SurgerySystem_Code *string `json:"surgerySystem_code" gorm:"size:10"` + // StartAt *string `json:"startAt" gorm:"size:20"` + // EndAt *string `json:"endAt" gorm:"size:20"` + // AnesthesiaStartAt *string `json:"anesthesiaStartAt" gorm:"size:20"` + // AnesthesiaEndAt *string `json:"anesthesiaEndAt" gorm:"size:20"` + // SurgeryType_Code *string `json:"surgeryType_code" gorm:"size:10"` + // SurgeryStage_Code *string `json:"surgeryStage_code" gorm:"size:10"` + // BornMortality_Code *string `json:"bornMortality_code" gorm:"size:10"` + // BornLocation_Code *string `json:"bornLocation_code" gorm:"size:10"` + // Weight *string `json:"weight" gorm:"size:10"` + // BornNotes *string `json:"bornNotes" gorm:"size:1024"` + // Description *string `json:"notes" gorm:"size:1024"` + // BleedingAmount *uint16 `json:"bleedingAmount" gorm:"size:10"` + // BloodInType_Code *string `json:"bloodInType_code" gorm:"size:10"` + // BloodInAmount *uint16 `json:"bloodInAmount" gorm:"size:10"` + // Brand *string `json:"brand" gorm:"size:100"` + // ImplantName *string `json:"implantName" gorm:"size:100"` + // ImplantRegisterNumber *string `json:"implantRegisterNumber" gorm:"size:100"` + // ImplantCompanionName *string `json:"implantCompanionName" gorm:"size:100"` + // SpecimentDest_Code *string `json:"specimentDest" gorm:"size:100"` + // TissueInfo *string `json:"tissueInfo" gorm:"size:100"` + + //PROPER + // Doctor_Code string `json:"doctor_code" gorm:"size:10"` + // Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` + // Operator_Employe_Id uint `json:"operator_employe_id"` + // Operator_Employe *eem.Employee `json:"operator_employe,omitempty" gorm:"foreignKey:Operator_Employe_Id;references:Id"` + // Assistant_Employe_Id uint `json:"assistant_employe_id"` + // Instrumentor_Employe_Id uint `json:"instrumentor_employe_id"` + // Instrumentor_Employe *eem.Employee `json:"instrumentor_employe,omitempty" gorm:"foreignKey:Instrumentor_Employe_Id;references:Id"` + // Nurse_Code string `json:"nurse_code" gorm:"size:10"` + // Nurse *en.Nurse `json:"nurse,omitempty" gorm:"foreignKey:Nurse_Code;references:Code"` + // Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" gorm:"size:10"` + // Anesthesia *eem.Employee `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` + // Anesthesia_Nurse_Employe_Id uint `json:"anesthesia_nurse_employe_id"` + // Anesthesia_Nurse *eem.Employee `json:"anesthesia_nurse,omitempty" gorm:"foreignKey:Anesthesia_Nurse_Employe_Id;references:Id"` +} diff --git a/internal/domain/references/clinical/clinical.go b/internal/domain/references/clinical/clinical.go index a9d3fc2b..3054c130 100644 --- a/internal/domain/references/clinical/clinical.go +++ b/internal/domain/references/clinical/clinical.go @@ -204,26 +204,26 @@ const ( MSCMicroLab McuScopeCode = "micro-lab" MSCApLab McuScopeCode = "ap-lab" - SSCSmall SurgerySizeCode = "" - SSCMedium SurgerySizeCode = "" - SSCLarge SurgerySizeCode = "" - SSCSpecial SurgerySizeCode = "" + SSCSmall SurgerySizeCode = "small" + SSCMedium SurgerySizeCode = "medium" + SSCLarge SurgerySizeCode = "large" + SSCSpecial SurgerySizeCode = "special" - SSyCCito SurgerySystemCode = "" - SSyCUrgent SurgerySystemCode = "" - SSyCEfective SurgerySystemCode = "" - SSyCSpecial SurgerySystemCode = "" + SSyCCito SurgerySystemCode = "cito" + SSyCUrgent SurgerySystemCode = "urgent" + SSyCEfective SurgerySystemCode = "efective" + SSyCSpecial SurgerySystemCode = "special" - STCClean SurgeryTypeCode = "" - STCCleanCtm SurgeryTypeCode = "" - STCUncleanCtm SurgeryTypeCode = "" - STCUnclean SurgeryTypeCode = "" + STCClean SurgeryTypeCode = "clean" + STCCleanCtm SurgeryTypeCode = "clean-ctm" + STCUncleanCtm SurgeryTypeCode = "unclean-ctm" + STCUnclean SurgeryTypeCode = "unclean" - SStCFirst SurgeryStageCode = "" - SStCRepeat SurgeryStageCode = "" + SStCFirst SurgeryStageCode = "first" + SStCRepeat SurgeryStageCode = "repeat" - BMCAlive BornMortalityCode = "" - BMCDead BornMortalityCode = "" + BMCAlive BornMortalityCode = "alive" + BMCDead BornMortalityCode = "dead" BLCExtMiw BornLocationCode = "" BLCExtDoc BornLocationCode = "" @@ -360,8 +360,11 @@ type HeadToToe struct { BodyOthers string `json:"body-others,omitempty"` } -type RecordAction struct { - Procedures []string `json:"procedures"` +type ProcedureRecord struct { + Procedures []CodeWithName `json:"procedures"` +} + +type ProcedureExecution struct { SurgerySize_Code *string `json:"surgerySize_code"` Billing_Code *string `json:"billing_code"` SurgerySystem_Code *string `json:"surgerySystem_code"` diff --git a/internal/interface/main-handler/main-handler.go b/internal/interface/main-handler/main-handler.go index d7c482e0..86b0c2aa 100644 --- a/internal/interface/main-handler/main-handler.go +++ b/internal/interface/main-handler/main-handler.go @@ -4,7 +4,6 @@ import ( "net/http" /******************** main / transaction ********************/ - actionreport "simrs-vx/internal/interface/main-handler/action-report" adime "simrs-vx/internal/interface/main-handler/adime" admemployeehist "simrs-vx/internal/interface/main-handler/adm-employee-hist" ambulancetransportrequest "simrs-vx/internal/interface/main-handler/ambulance-transport-req" @@ -34,6 +33,7 @@ import ( practiceschedule "simrs-vx/internal/interface/main-handler/practice-schedule" prescription "simrs-vx/internal/interface/main-handler/prescription" prescriptionitem "simrs-vx/internal/interface/main-handler/prescription-item" + procedurereport "simrs-vx/internal/interface/main-handler/procedure-report" procedureroomorder "simrs-vx/internal/interface/main-handler/procedure-room-order" procedureroomorderitem "simrs-vx/internal/interface/main-handler/procedure-room-order-item" responsibledoctorhist "simrs-vx/internal/interface/main-handler/responsible-doctor-hist" @@ -176,7 +176,7 @@ func SetRoutes() http.Handler { hc.RegCrud(r, "/v1/sbar", auth.GuardMW, sbar.O) hc.RegCrud(r, "/v1/prescription-item", prescriptionitem.O) hc.RegCrud(r, "/v1/device-order-item", deviceorderitem.O) - hc.RegCrud(r, "/v1/action-report", auth.GuardMW, actionreport.O) + hc.RegCrud(r, "/v1/procedure-report", auth.GuardMW, procedurereport.O) hc.RegCrud(r, "/v1/material-order-item", materialorderitem.O) hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{ diff --git a/internal/interface/main-handler/action-report/handler.go b/internal/interface/main-handler/procedure-report/handler.go similarity index 93% rename from internal/interface/main-handler/action-report/handler.go rename to internal/interface/main-handler/procedure-report/handler.go index 0fdd1851..a648463b 100644 --- a/internal/interface/main-handler/action-report/handler.go +++ b/internal/interface/main-handler/procedure-report/handler.go @@ -8,8 +8,8 @@ import ( // ua "github.com/karincake/tumpeng/auth/svc" - e "simrs-vx/internal/domain/main-entities/action-report" - u "simrs-vx/internal/use-case/main-use-case/action-report" + e "simrs-vx/internal/domain/main-entities/procedure-report" + u "simrs-vx/internal/use-case/main-use-case/procedure-report" pa "simrs-vx/internal/lib/auth" diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 34530d78..8b43f165 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -1,7 +1,6 @@ package migration import ( - actionreport "simrs-vx/internal/domain/main-entities/action-report" adime "simrs-vx/internal/domain/main-entities/adime" admemployeehist "simrs-vx/internal/domain/main-entities/adm-employee-hist" ambulancetransportreq "simrs-vx/internal/domain/main-entities/ambulance-transport-req" @@ -82,6 +81,7 @@ import ( practiceschedule "simrs-vx/internal/domain/main-entities/practice-schedule" prescription "simrs-vx/internal/domain/main-entities/prescription" prescriptionitem "simrs-vx/internal/domain/main-entities/prescription-item" + procedurereport "simrs-vx/internal/domain/main-entities/procedure-report" procedureroom "simrs-vx/internal/domain/main-entities/procedure-room" procedureroomorder "simrs-vx/internal/domain/main-entities/procedure-room-order" procedureroomorderitem "simrs-vx/internal/domain/main-entities/procedure-room-order-item" @@ -234,6 +234,6 @@ func getMainEntities() []any { &resume.Resume{}, &vclaimreference.VclaimReference{}, &screening.Screening{}, - &actionreport.ActionReport{}, + &procedurereport.ProcedureReport{}, } } diff --git a/internal/use-case/main-use-case/action-report/helper.go b/internal/use-case/main-use-case/action-report/helper.go deleted file mode 100644 index efe4532e..00000000 --- a/internal/use-case/main-use-case/action-report/helper.go +++ /dev/null @@ -1,28 +0,0 @@ -/* -DESCRIPTION: -Any functions that are used internally by the use-case -*/ -package actionreport - -import ( - e "simrs-vx/internal/domain/main-entities/action-report" -) - -func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ActionReport) { - var inputSrc *e.CreateDto - if inputT, ok := any(input).(*e.CreateDto); ok { - inputSrc = inputT - } else { - inputTemp := any(input).(*e.UpdateDto) - inputSrc = &inputTemp.CreateDto - } - - data.Encounter_Id = inputSrc.Encounter_Id - data.Date = inputSrc.Date - data.Doctor_Code = inputSrc.Doctor_Code - data.Operator_Employe_Id = inputSrc.Operator_Employe_Id - data.Assistant_Employe_Id = inputSrc.Assistant_Employe_Id - data.Instrumentor_Employe_Id = inputSrc.Instrumentor_Employe_Id - data.Nurse_Code = inputSrc.Nurse_Code - data.Value = inputSrc.Value -} diff --git a/internal/use-case/main-use-case/action-report/case.go b/internal/use-case/main-use-case/procedure-report/case.go similarity index 95% rename from internal/use-case/main-use-case/action-report/case.go rename to internal/use-case/main-use-case/procedure-report/case.go index 2ae0f268..e44cfaee 100644 --- a/internal/use-case/main-use-case/action-report/case.go +++ b/internal/use-case/main-use-case/procedure-report/case.go @@ -1,10 +1,10 @@ -package actionreport +package procedurereport import ( "errors" "strconv" - e "simrs-vx/internal/domain/main-entities/action-report" + e "simrs-vx/internal/domain/main-entities/procedure-report" dg "github.com/karincake/apem/db-gorm-pg" d "github.com/karincake/dodol" @@ -15,10 +15,10 @@ import ( "gorm.io/gorm" ) -const source = "action-report" +const source = "procedure-report" func Create(input e.CreateDto) (*d.Data, error) { - data := e.ActionReport{} + data := e.ProcedureReport{} event := pl.Event{ Feature: "Create", @@ -85,8 +85,8 @@ func Create(input e.CreateDto) (*d.Data, error) { } func ReadList(input e.ReadListDto) (*d.Data, error) { - var data *e.ActionReport - var dataList []e.ActionReport + var data *e.ProcedureReport + var dataList []e.ProcedureReport var metaList *e.MetaDto var err error @@ -138,7 +138,7 @@ func ReadList(input e.ReadListDto) (*d.Data, error) { } func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { - var data *e.ActionReport + var data *e.ProcedureReport var err error event := pl.Event{ @@ -186,7 +186,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { func Update(input e.UpdateDto) (*d.Data, error) { rdDto := e.ReadDetailDto{Id: input.Id} - var data *e.ActionReport + var data *e.ProcedureReport var err error event := pl.Event{ @@ -242,7 +242,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { func Delete(input e.DeleteDto) (*d.Data, error) { rdDto := e.ReadDetailDto{Id: input.Id} - var data *e.ActionReport + var data *e.ProcedureReport var err error event := pl.Event{ diff --git a/internal/use-case/main-use-case/procedure-report/helper.go b/internal/use-case/main-use-case/procedure-report/helper.go new file mode 100644 index 00000000..9fb87778 --- /dev/null +++ b/internal/use-case/main-use-case/procedure-report/helper.go @@ -0,0 +1,39 @@ +/* +DESCRIPTION: +Any functions that are used internally by the use-case +*/ +package procedurereport + +import ( + e "simrs-vx/internal/domain/main-entities/procedure-report" +) + +func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ProcedureReport) { + var inputSrc *e.CreateDto + if inputT, ok := any(input).(*e.CreateDto); ok { + inputSrc = inputT + } else { + inputTemp := any(input).(*e.UpdateDto) + inputSrc = &inputTemp.CreateDto + } + + data.Encounter_Id = inputSrc.Encounter_Id + data.Date = inputSrc.Date + data.Doctor_Code = inputSrc.Doctor_Code + data.Operator_Name = inputSrc.Operator_Name + data.Assistant_Name = inputSrc.Assistant_Name + data.Instrumentor_Name = inputSrc.Instrumentor_Name + data.Anesthesia_Doctor_Code = inputSrc.Anesthesia_Doctor_Code + data.Anesthesia_Nurse_Name = inputSrc.Anesthesia_Nurse_Name + data.Diagnose = inputSrc.Diagnose + data.Nurse_Name = inputSrc.Nurse_Name + data.ProcedureValue = inputSrc.ProcedureValue + data.ExecutionValue = inputSrc.ExecutionValue + data.Type = inputSrc.Type + + //PROPER + // data.Operator_Employe_Id = inputSrc.Operator_Employe_Id + // data.Assistant_Employe_Id = inputSrc.Assistant_Employe_Id + // data.Instrumentor_Employe_Id = inputSrc.Instrumentor_Employe_Id + // data.Nurse_Code = inputSrc.Nurse_Code +} diff --git a/internal/use-case/main-use-case/action-report/lib.go b/internal/use-case/main-use-case/procedure-report/lib.go similarity index 83% rename from internal/use-case/main-use-case/action-report/lib.go rename to internal/use-case/main-use-case/procedure-report/lib.go index 5a272cce..0588a944 100644 --- a/internal/use-case/main-use-case/action-report/lib.go +++ b/internal/use-case/main-use-case/procedure-report/lib.go @@ -1,7 +1,7 @@ -package actionreport +package procedurereport import ( - e "simrs-vx/internal/domain/main-entities/action-report" + e "simrs-vx/internal/domain/main-entities/procedure-report" plh "simrs-vx/pkg/lib-helper" pl "simrs-vx/pkg/logger" @@ -12,10 +12,10 @@ import ( "gorm.io/gorm" ) -func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.ActionReport, error) { +func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.ProcedureReport, error) { pl.SetLogInfo(event, nil, "started", "DBCreate") - data := e.ActionReport{} + data := e.ProcedureReport{} setData(&input, &data) var tx *gorm.DB @@ -33,9 +33,9 @@ func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.ActionR return &data, nil } -func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.ActionReport, *e.MetaDto, error) { +func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.ProcedureReport, *e.MetaDto, error) { pl.SetLogInfo(event, input, "started", "DBReadList") - data := []e.ActionReport{} + data := []e.ProcedureReport{} pagination := gh.Pagination{} count := int64(0) meta := e.MetaDto{} @@ -48,7 +48,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Ac } tx = tx. - Model(&e.ActionReport{}). + Model(&e.ProcedureReport{}). Scopes(gh.Preload(input.Includes)). Scopes(gh.Filter(input.FilterDto)). Count(&count). @@ -70,9 +70,9 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Ac return data, &meta, nil } -func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e.ActionReport, error) { +func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e.ProcedureReport, error) { pl.SetLogInfo(event, input, "started", "DBReadDetail") - data := e.ActionReport{} + data := e.ProcedureReport{} var tx *gorm.DB if len(dbx) > 0 { @@ -91,7 +91,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e return &data, nil } -func UpdateData(input e.UpdateDto, data *e.ActionReport, event *pl.Event, dbx ...*gorm.DB) error { +func UpdateData(input e.UpdateDto, data *e.ProcedureReport, event *pl.Event, dbx ...*gorm.DB) error { pl.SetLogInfo(event, data, "started", "DBUpdate") setData(&input, data) @@ -116,7 +116,7 @@ func UpdateData(input e.UpdateDto, data *e.ActionReport, event *pl.Event, dbx .. return nil } -func DeleteData(data *e.ActionReport, event *pl.Event, dbx ...*gorm.DB) error { +func DeleteData(data *e.ProcedureReport, event *pl.Event, dbx ...*gorm.DB) error { pl.SetLogInfo(event, data, "started", "DBDelete") var tx *gorm.DB if len(dbx) > 0 { diff --git a/internal/use-case/main-use-case/action-report/middleware-runner.go b/internal/use-case/main-use-case/procedure-report/middleware-runner.go similarity index 86% rename from internal/use-case/main-use-case/action-report/middleware-runner.go rename to internal/use-case/main-use-case/procedure-report/middleware-runner.go index e2544169..c849ef28 100644 --- a/internal/use-case/main-use-case/action-report/middleware-runner.go +++ b/internal/use-case/main-use-case/procedure-report/middleware-runner.go @@ -1,7 +1,7 @@ -package actionreport +package procedurereport import ( - e "simrs-vx/internal/domain/main-entities/action-report" + e "simrs-vx/internal/domain/main-entities/procedure-report" pl "simrs-vx/pkg/logger" pu "simrs-vx/pkg/use-case-helper" @@ -23,7 +23,7 @@ func newMiddlewareRunner(event *pl.Event, tx *gorm.DB) *middlewareRunner { } // ExecuteCreateMiddleware executes create middleware -func (me *middlewareRunner) RunCreateMiddleware(middlewares []createMw, input *e.CreateDto, data *e.ActionReport) error { +func (me *middlewareRunner) RunCreateMiddleware(middlewares []createMw, input *e.CreateDto, data *e.ProcedureReport) error { for _, middleware := range middlewares { logData := pu.GetLogData(input, data) @@ -38,7 +38,7 @@ func (me *middlewareRunner) RunCreateMiddleware(middlewares []createMw, input *e return nil } -func (me *middlewareRunner) RunReadListMiddleware(middlewares []readListMw, input *e.ReadListDto, data *e.ActionReport) error { +func (me *middlewareRunner) RunReadListMiddleware(middlewares []readListMw, input *e.ReadListDto, data *e.ProcedureReport) error { for _, middleware := range middlewares { logData := pu.GetLogData(input, data) @@ -53,7 +53,7 @@ func (me *middlewareRunner) RunReadListMiddleware(middlewares []readListMw, inpu return nil } -func (me *middlewareRunner) RunReadDetailMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ActionReport) error { +func (me *middlewareRunner) RunReadDetailMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ProcedureReport) error { for _, middleware := range middlewares { logData := pu.GetLogData(input, data) @@ -68,7 +68,7 @@ func (me *middlewareRunner) RunReadDetailMiddleware(middlewares []readDetailMw, return nil } -func (me *middlewareRunner) RunUpdateMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ActionReport) error { +func (me *middlewareRunner) RunUpdateMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ProcedureReport) error { for _, middleware := range middlewares { logData := pu.GetLogData(input, data) @@ -83,7 +83,7 @@ func (me *middlewareRunner) RunUpdateMiddleware(middlewares []readDetailMw, inpu return nil } -func (me *middlewareRunner) RunDeleteMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ActionReport) error { +func (me *middlewareRunner) RunDeleteMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ProcedureReport) error { for _, middleware := range middlewares { logData := pu.GetLogData(input, data) diff --git a/internal/use-case/main-use-case/action-report/middleware.go b/internal/use-case/main-use-case/procedure-report/middleware.go similarity index 89% rename from internal/use-case/main-use-case/action-report/middleware.go rename to internal/use-case/main-use-case/procedure-report/middleware.go index 50254de2..157d4e2e 100644 --- a/internal/use-case/main-use-case/action-report/middleware.go +++ b/internal/use-case/main-use-case/procedure-report/middleware.go @@ -1,4 +1,4 @@ -package actionreport +package procedurereport // example of middleware // func init() { diff --git a/internal/use-case/main-use-case/action-report/tycovar.go b/internal/use-case/main-use-case/procedure-report/tycovar.go similarity index 74% rename from internal/use-case/main-use-case/action-report/tycovar.go rename to internal/use-case/main-use-case/procedure-report/tycovar.go index 9eebfabd..3fb449c3 100644 --- a/internal/use-case/main-use-case/action-report/tycovar.go +++ b/internal/use-case/main-use-case/procedure-report/tycovar.go @@ -6,27 +6,27 @@ In this sample it also provides type and variable regarding the needs of the middleware to separate from main use-case which has the basic CRUD functionality. The purpose of this is to make the code more maintainable. */ -package actionreport +package procedurereport import ( "gorm.io/gorm" - e "simrs-vx/internal/domain/main-entities/action-report" + e "simrs-vx/internal/domain/main-entities/procedure-report" ) type createMw struct { Name string - Func func(input *e.CreateDto, data *e.ActionReport, tx *gorm.DB) error + Func func(input *e.CreateDto, data *e.ProcedureReport, tx *gorm.DB) error } type readListMw struct { Name string - Func func(input *e.ReadListDto, data *e.ActionReport, tx *gorm.DB) error + Func func(input *e.ReadListDto, data *e.ProcedureReport, tx *gorm.DB) error } type readDetailMw struct { Name string - Func func(input *e.ReadDetailDto, data *e.ActionReport, tx *gorm.DB) error + Func func(input *e.ReadDetailDto, data *e.ProcedureReport, tx *gorm.DB) error } type UpdateMw = readDetailMw From 9d3a872eba9ccd8b9cd34fabc0d4fab8f0a8078b Mon Sep 17 00:00:00 2001 From: ari Date: Thu, 4 Dec 2025 14:01:57 +0700 Subject: [PATCH 14/45] update migration --- .../migrations/20251201104439.sql | 28 +++++++++++++------ .../migrations/20251201113804.sql | 4 +-- .../migrations/20251201113858.sql | 4 +-- .../migrations/20251201114751.sql | 4 +-- .../migrations/20251201114913.sql | 4 +-- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/cmd/main-migration/migrations/20251201104439.sql b/cmd/main-migration/migrations/20251201104439.sql index 50f60b6b..832d10e2 100644 --- a/cmd/main-migration/migrations/20251201104439.sql +++ b/cmd/main-migration/migrations/20251201104439.sql @@ -1,5 +1,5 @@ --- Create "ActionReport" table -CREATE TABLE "public"."ActionReport" ( +-- Create "ProcedureReport" table +CREATE TABLE "public"."ProcedureReport" ( "Id" bigserial NOT NULL, "CreatedAt" timestamptz NULL, "UpdatedAt" timestamptz NULL, @@ -7,13 +7,23 @@ CREATE TABLE "public"."ActionReport" ( "Encounter_Id" bigint NULL, "Date" character varying(20) NOT NULL, "Doctor_Code" character varying(10) NULL, - "Operator_Employe_Id" bigint NULL, - "Assistant_Employe_Id" bigint NULL, - "Instrumentor_Employe_Id" bigint NULL, + "Operator_Name" character varying(120) NULL, + "Assistant_Name" character varying(120) NULL, + "Instrumentor_Name" character varying(120) NULL, "Diagnose" character varying(1024) NULL, - "Procedures" character varying(10240) NULL, - "Nurse_Code" character varying(10) NULL, - "Value" text NULL, + "Nurse_Name" character varying(120) NULL, + "ProcedureValue" text NULL, + "ExecutionValue" text NULL, + "Type" character varying(10) NULL, PRIMARY KEY ("Id"), - CONSTRAINT "fk_ActionReport_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION + CONSTRAINT "fk_ProcedureReport_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION ); + +-- PROPER + -- "Operator_Employe_Id" bigint NULL, + -- "Assistant_Employe_Id" bigint NULL, + -- "Instrumentor_Employe_Id" bigint NULL, + -- "Diagnose" character varying(1024) NULL, + -- "Procedures" character varying(10240) NULL, + -- "Nurse_Code" character varying(10) NULL, + diff --git a/cmd/main-migration/migrations/20251201113804.sql b/cmd/main-migration/migrations/20251201113804.sql index 0f5c5123..8cecb5fe 100644 --- a/cmd/main-migration/migrations/20251201113804.sql +++ b/cmd/main-migration/migrations/20251201113804.sql @@ -1,2 +1,2 @@ --- Modify "ActionReport" table -ALTER TABLE "public"."ActionReport" DROP COLUMN "Date", DROP COLUMN "Procedures"; +-- Modify "ProcedureReport" table +ALTER TABLE "public"."ProcedureReport" DROP COLUMN "Date", DROP COLUMN "Procedures"; diff --git a/cmd/main-migration/migrations/20251201113858.sql b/cmd/main-migration/migrations/20251201113858.sql index fd6fddc9..bc77d02c 100644 --- a/cmd/main-migration/migrations/20251201113858.sql +++ b/cmd/main-migration/migrations/20251201113858.sql @@ -1,2 +1,2 @@ --- Modify "ActionReport" table -ALTER TABLE "public"."ActionReport" ADD COLUMN "Date" timestamptz NOT NULL; +-- Modify "ProcedureReport" table +ALTER TABLE "public"."ProcedureReport" ADD COLUMN "Date" timestamptz NOT NULL; diff --git a/cmd/main-migration/migrations/20251201114751.sql b/cmd/main-migration/migrations/20251201114751.sql index 6611b811..339ee39c 100644 --- a/cmd/main-migration/migrations/20251201114751.sql +++ b/cmd/main-migration/migrations/20251201114751.sql @@ -1,2 +1,2 @@ --- Modify "ActionReport" table -ALTER TABLE "public"."ActionReport" ADD CONSTRAINT "fk_ActionReport_Instrumentor_Employe" FOREIGN KEY ("Instrumentor_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ActionReport_Nurse" FOREIGN KEY ("Nurse_Code") REFERENCES "public"."Nurse" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ActionReport_Operator_Employe" FOREIGN KEY ("Operator_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Modify "ProcedureReport" table +ALTER TABLE "public"."ProcedureReport" ADD CONSTRAINT "fk_ProcedureReport_Instrumentor_Employe" FOREIGN KEY ("Instrumentor_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ProcedureReport_Nurse" FOREIGN KEY ("Nurse_Code") REFERENCES "public"."Nurse" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ProcedureReport_Operator_Employe" FOREIGN KEY ("Operator_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/cmd/main-migration/migrations/20251201114913.sql b/cmd/main-migration/migrations/20251201114913.sql index 5155ed37..85c0281c 100644 --- a/cmd/main-migration/migrations/20251201114913.sql +++ b/cmd/main-migration/migrations/20251201114913.sql @@ -1,2 +1,2 @@ --- Modify "ActionReport" table -ALTER TABLE "public"."ActionReport" ADD CONSTRAINT "fk_ActionReport_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Modify "ProcedureReport" table +ALTER TABLE "public"."ProcedureReport" ADD CONSTRAINT "fk_ProcedureReport_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; From 1a92e4539c161ee7287d326c8e96ff88d8a46455 Mon Sep 17 00:00:00 2001 From: ari Date: Thu, 4 Dec 2025 14:03:41 +0700 Subject: [PATCH 15/45] update query --- cmd/main-migration/migrations/20251201104439.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/main-migration/migrations/20251201104439.sql b/cmd/main-migration/migrations/20251201104439.sql index 832d10e2..6862ccde 100644 --- a/cmd/main-migration/migrations/20251201104439.sql +++ b/cmd/main-migration/migrations/20251201104439.sql @@ -10,6 +10,8 @@ CREATE TABLE "public"."ProcedureReport" ( "Operator_Name" character varying(120) NULL, "Assistant_Name" character varying(120) NULL, "Instrumentor_Name" character varying(120) NULL, + "Anesthesia_Doctor_Code" character varying(10) NULL, + "Anesthesia_Nurse_Name" character varying(120) NULL, "Diagnose" character varying(1024) NULL, "Nurse_Name" character varying(120) NULL, "ProcedureValue" text NULL, From dc75980e307a8639df1c549e43282fe2350f7ca2 Mon Sep 17 00:00:00 2001 From: ari Date: Fri, 5 Dec 2025 09:31:13 +0700 Subject: [PATCH 16/45] update const --- .../domain/references/clinical/clinical.go | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/internal/domain/references/clinical/clinical.go b/internal/domain/references/clinical/clinical.go index 3054c130..44de34b6 100644 --- a/internal/domain/references/clinical/clinical.go +++ b/internal/domain/references/clinical/clinical.go @@ -30,6 +30,7 @@ type ( BornMortalityCode string BornLocationCode string SpecimentDestCode string + ProcedureReportType string ) const ( @@ -225,16 +226,19 @@ const ( BMCAlive BornMortalityCode = "alive" BMCDead BornMortalityCode = "dead" - BLCExtMiw BornLocationCode = "" - BLCExtDoc BornLocationCode = "" - BLCTradMiw BornLocationCode = "" - BLCLocalMed BornLocationCode = "" - BLCExtParamedic BornLocationCode = "" + BLCExtMiw BornLocationCode = "ext-miw" + BLCExtDoc BornLocationCode = "ext-doc" + BLCTradMiw BornLocationCode = "trad-miw" + BLCLocalMed BornLocationCode = "local-med" + BLCExtParamedic BornLocationCode = "ext-paramedic" - SDCAp SpecimentDestCode = "" - SDCMicro SpecimentDestCode = "" - SDCLab SpecimentDestCode = "" - SDCNone SpecimentDestCode = "" + SDCAp SpecimentDestCode = "ap" + SDCMicro SpecimentDestCode = "micro" + SDCLab SpecimentDestCode = "lab" + SDCNone SpecimentDestCode = "none" + + PRTProcedure ProcedureReportType = "procedure" + PRTSurgery ProcedureReportType = "surgery" ) type Soapi struct { From ff0b7f1fab3617cf0f0fc0252222acd236651222 Mon Sep 17 00:00:00 2001 From: ari Date: Fri, 5 Dec 2025 09:39:30 +0700 Subject: [PATCH 17/45] update non required val --- internal/domain/main-entities/procedure-report/dto.go | 8 ++++---- internal/domain/main-entities/procedure-report/entity.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/domain/main-entities/procedure-report/dto.go b/internal/domain/main-entities/procedure-report/dto.go index 9cd400be..b27191a4 100644 --- a/internal/domain/main-entities/procedure-report/dto.go +++ b/internal/domain/main-entities/procedure-report/dto.go @@ -15,8 +15,8 @@ type CreateDto struct { Operator_Name string `json:"operator_name" validate:"required"` Assistant_Name string `json:"assistant_name" validate:"required"` Instrumentor_Name string `json:"instrumentor_name" validate:"required"` - Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" validate:"required"` - Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name" validate:"required"` + Anesthesia_Doctor_Code *string `json:"anesthesia_doctor_code"` + Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"` Diagnose *string `json:"diagnose"` Nurse_Name string `json:"nurse_name" validate:"required"` ProcedureValue string `json:"procedure_value" validate:"required"` @@ -72,8 +72,8 @@ type ResponseDto struct { Operator_Name string `json:"operator_name"` Assistant_Name string `json:"assistant_name"` Instrumentor_Name string `json:"instrumentor_name"` - Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code"` - Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name"` + Anesthesia_Doctor_Code *string `json:"anesthesia_doctor_code"` + Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"` Diagnose *string `json:"diagnose"` Nurse_Name string `json:"nurse_name"` ProcedureValue *string `json:"procedure_value"` diff --git a/internal/domain/main-entities/procedure-report/entity.go b/internal/domain/main-entities/procedure-report/entity.go index f25bf604..82d178f2 100644 --- a/internal/domain/main-entities/procedure-report/entity.go +++ b/internal/domain/main-entities/procedure-report/entity.go @@ -20,9 +20,9 @@ type ProcedureReport struct { Instrumentor_Name string `json:"instrumentor_name"` Diagnose *string `json:"diagnose" gorm:"size:1024"` Nurse_Name string `json:"nurse_code" gorm:"size:10"` - Anesthesia_Doctor_Code string `json:"anesthesia_doctor_code" gorm:"size:10"` + Anesthesia_Doctor_Code *string `json:"anesthesia_doctor_code" gorm:"size:10"` Anesthesia *eem.Employee `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` - Anesthesia_Nurse_Name string `json:"anesthesia_nurse_name"` + Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"` ProcedureValue string `json:"procedure_value"` ExecutionValue string `json:"execution_value"` Type string `json:"type"` From 935cc8aef5a3cde6f107be73d70a84fa685338da Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Fri, 5 Dec 2025 14:04:56 +0700 Subject: [PATCH 18/45] feat (encounter): add more filter for list --- .../domain/main-entities/encounter/dto.go | 14 +++++----- .../use-case/main-use-case/encounter/lib.go | 26 ++++++++++++++++--- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/internal/domain/main-entities/encounter/dto.go b/internal/domain/main-entities/encounter/dto.go index c039fc0c..9b007097 100644 --- a/internal/domain/main-entities/encounter/dto.go +++ b/internal/domain/main-entities/encounter/dto.go @@ -78,11 +78,14 @@ type TRujukan struct { type ReadListDto struct { FilterDto - Includes string `json:"includes"` - Pagination ecore.Pagination - Person_Name *string `json:"person-name"` - StartDate *string `json:"start-date"` - EndDate *string `json:"end-date"` + Includes string `json:"includes"` + Pagination ecore.Pagination + Patient_Identifier *string `json:"patient-identifier"` + StartDate *string `json:"start-date"` + EndDate *string `json:"end-date"` + PaymentMethod_Code *string `json:"paymentMethod-code"` + Status_Code *string `json:"status-code"` + Unit_Code *string `json:"unit-code"` pa.AuthInfo } @@ -92,7 +95,6 @@ type FilterDto struct { Patient *ep.Patient `json:"patient,omitempty"` RegisteredAt *time.Time `json:"registeredAt"` Class_Code ere.EncounterClassCode `json:"class-code" validate:"maxLength=10"` - Unit_Code *string `json:"unit-code"` Specialist_Code *string `json:"specialist-code"` Subspecialist_Code *string `json:"subspecialist-code"` VisitDate time.Time `json:"visitDate"` diff --git a/internal/use-case/main-use-case/encounter/lib.go b/internal/use-case/main-use-case/encounter/lib.go index a9a5a307..3baec23a 100644 --- a/internal/use-case/main-use-case/encounter/lib.go +++ b/internal/use-case/main-use-case/encounter/lib.go @@ -73,17 +73,35 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.En ) } - if input.Person_Name != nil { + if input.Patient_Identifier != nil { tx = tx.Joins("JOIN \"Patient\" ON \"Patient\".\"Id\" = \"Encounter\".\"Patient_Id\""). - Joins("JOIN \"Person\" ON \"Person\".\"Id\" = \"Patient\".\"Person_Id\"").Where("\"Person\".\"Name\" ILIKE ?", "%"+*input.Person_Name+"%") + Joins("JOIN \"Person\" ON \"Person\".\"Id\" = \"Patient\".\"Person_Id\"").Where("\"Person\".\"Name\" ILIKE ? OR \"Patient\".\"Number\" = ?", "%"+*input.Patient_Identifier+"%", *input.Patient_Identifier) } - tx = tx.Debug().Scopes(gh.Preload(input.Includes)). - Scopes(gh.Filter(input.FilterDto)). + // TODO: getuk lib need to be updated to support this + if input.Status_Code != nil { + tx = tx.Where("\"Encounter\".\"Status_Code\" = ?", *input.Status_Code) + } + + if input.Unit_Code != nil { + tx = tx.Where("\"Encounter\".\"Unit_Code\" = ?", *input.Unit_Code) + } + + if input.PaymentMethod_Code != nil { + tx = tx.Where("\"Encounter\".\"PaymentMethod_Code\" = ?", *input.PaymentMethod_Code) + } + + tx = tx.Scopes(gh.Preload(input.Includes)). Count(&count). Scopes(gh.Paginate(input, &pagination)). Order("\"CreatedAt\" DESC") + // tx.Debug().Scopes(gh.Preload(input.Includes)). + // Scopes(gh.Filter(input.FilterDto)). + // Count(&count). + // Scopes(gh.Paginate(input, &pagination)). + // Order("\"CreatedAt\" DESC") + if err := tx.Find(&data).Error; err != nil { if err == gorm.ErrRecordNotFound { return nil, &meta, nil From 6c13b1ad517447c95bc1cf8cf9381749c224b8a2 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Fri, 5 Dec 2025 14:18:39 +0700 Subject: [PATCH 19/45] feat (item): fix get-detail by code --- internal/domain/main-entities/item/dto.go | 2 +- internal/use-case/main-use-case/item/lib.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/domain/main-entities/item/dto.go b/internal/domain/main-entities/item/dto.go index 686a5c17..53e3c763 100644 --- a/internal/domain/main-entities/item/dto.go +++ b/internal/domain/main-entities/item/dto.go @@ -33,7 +33,7 @@ type FilterDto struct { } type ReadDetailDto struct { - Id *uint16 `json:"id"` + Id *uint `json:"id"` Code *string `json:"code"` } diff --git a/internal/use-case/main-use-case/item/lib.go b/internal/use-case/main-use-case/item/lib.go index 56c4c915..a58a956b 100644 --- a/internal/use-case/main-use-case/item/lib.go +++ b/internal/use-case/main-use-case/item/lib.go @@ -81,7 +81,15 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e tx = dg.I } - if err := tx.First(&data, input.Id).Error; err != nil { + if input.Code != nil { + tx = tx.Where("\"Code\" = ?", *input.Code) + } + + if input.Id != nil { + tx = tx.Where("\"Id\" = ?", input.Id) + } + + if err := tx.First(&data).Error; err != nil { if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil { return nil, processedErr } From 5bc3c8783ee012e5999ba0cd7a2ba01104a758b9 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Fri, 5 Dec 2025 16:08:22 +0700 Subject: [PATCH 20/45] feat (item): update handle buying price and selling price --- internal/domain/main-entities/item/dto.go | 2 ++ internal/use-case/main-use-case/item/helper.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/internal/domain/main-entities/item/dto.go b/internal/domain/main-entities/item/dto.go index 53e3c763..a25c5a7a 100644 --- a/internal/domain/main-entities/item/dto.go +++ b/internal/domain/main-entities/item/dto.go @@ -13,6 +13,8 @@ type CreateDto struct { Uom_Code *string `json:"uom_code" validate:"maxLength=10"` Infra_Code *string `json:"infra_code"` Stock *int `json:"stock"` + BuyingPrice *float64 `json:"buyingPrice"` + SellingPrice *float64 `json:"sellingPrice"` } type ReadListDto struct { diff --git a/internal/use-case/main-use-case/item/helper.go b/internal/use-case/main-use-case/item/helper.go index 6f7e0c57..2de4c1bd 100644 --- a/internal/use-case/main-use-case/item/helper.go +++ b/internal/use-case/main-use-case/item/helper.go @@ -23,4 +23,6 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Item) { data.Uom_Code = inputSrc.Uom_Code data.Infra_Code = inputSrc.Infra_Code data.Stock = inputSrc.Stock + data.BuyingPrice = inputSrc.BuyingPrice + data.SellingPrice = inputSrc.SellingPrice } From d82e67ae5c579f36dd5dad044cdf26aab8397fa4 Mon Sep 17 00:00:00 2001 From: vanilia Date: Sat, 6 Dec 2025 04:20:40 +0700 Subject: [PATCH 21/45] add chemoplans entity in chemo protocol --- cmd/main-migration/migrations/20251205211957.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 5 +++-- internal/domain/main-entities/chemo-plan/dto.go | 8 ++------ internal/domain/main-entities/chemo-plan/entity.go | 3 --- internal/domain/main-entities/chemo-protocol/entity.go | 2 ++ 5 files changed, 9 insertions(+), 11 deletions(-) create mode 100644 cmd/main-migration/migrations/20251205211957.sql diff --git a/cmd/main-migration/migrations/20251205211957.sql b/cmd/main-migration/migrations/20251205211957.sql new file mode 100644 index 00000000..99677edd --- /dev/null +++ b/cmd/main-migration/migrations/20251205211957.sql @@ -0,0 +1,2 @@ +-- Modify "ChemoPlan" table +ALTER TABLE "public"."ChemoPlan" DROP CONSTRAINT "fk_ChemoPlan_Protocol", ADD CONSTRAINT "fk_ChemoProtocol_ChemoPlans" FOREIGN KEY ("Protocol_Id") REFERENCES "public"."ChemoProtocol" ("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 9b12364f..9e1a235c 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:2pGamYMy0LEZE7Du/0SEb8z5LrkmpNk199Yw0CJri+M= +h1:JgjOL5Bl+2zIlc2E1Lz/LhEJo/IGWouNe79ccswAcq8= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -144,4 +144,5 @@ h1:2pGamYMy0LEZE7Du/0SEb8z5LrkmpNk199Yw0CJri+M= 20251202160848.sql h1:Kd2/TziKSMezrt4XgbjQcYvY/Lo9rX0qw7/Lz0/oyKk= 20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM= 20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= -20251205073858.sql h1:GD692c2jC2mFr6esv3eQmxEpWOeIA860TGctwHAldfM= +20251205073858.sql h1:Ep03jQ9hJAJILDJfKVcmi3Z6fqmTHSq9gKQtwf070PE= +20251205211957.sql h1:RGkuUdSgt8BtypqGpji9VBBi1r85e2ez1aJILTB7zi0= diff --git a/internal/domain/main-entities/chemo-plan/dto.go b/internal/domain/main-entities/chemo-plan/dto.go index b3e89d80..ffd9803f 100644 --- a/internal/domain/main-entities/chemo-plan/dto.go +++ b/internal/domain/main-entities/chemo-plan/dto.go @@ -1,18 +1,17 @@ package chemo_plan import ( - ecp "simrs-vx/internal/domain/main-entities/chemo-protocol" - ere "simrs-vx/internal/domain/references/encounter" // std "time" + ere "simrs-vx/internal/domain/references/encounter" + // internal - domain - main-entities ecore "simrs-vx/internal/domain/base-entities/core" ) type CreateDto struct { Parent_Id *uint `json:"parent_id"` - Protocol_Id *uint `json:"protocol_id"` SeriesNumber *uint16 `json:"seriesNumber"` CycleNumber *uint `json:"cycleNumber"` PlanDate *time.Time `json:"planDate"` @@ -56,7 +55,6 @@ type ResponseDto struct { ecore.Main Parent_Id *uint `json:"parent_id"` // chemo.Id Protocol_Id *uint `json:"protocol_id"` - Protocol ecp.ChemoProtocol `json:"protocol,omitempty"` SeriesNumber *uint16 `json:"seriesNumber"` // series ke - CycleNumber *uint `json:"cycleNumber"` // cycle ke - PlanDate *time.Time `json:"planDate"` @@ -68,8 +66,6 @@ type ResponseDto struct { func (d ChemoPlan) ToResponse() ResponseDto { resp := ResponseDto{ Parent_Id: d.Parent_Id, - Protocol_Id: d.Protocol_Id, - Protocol: d.Protocol, SeriesNumber: d.SeriesNumber, CycleNumber: d.CycleNumber, PlanDate: d.PlanDate, diff --git a/internal/domain/main-entities/chemo-plan/entity.go b/internal/domain/main-entities/chemo-plan/entity.go index 08ac905d..1f3f3ca5 100644 --- a/internal/domain/main-entities/chemo-plan/entity.go +++ b/internal/domain/main-entities/chemo-plan/entity.go @@ -6,15 +6,12 @@ import ( ecore "simrs-vx/internal/domain/base-entities/core" ere "simrs-vx/internal/domain/references/encounter" - - ecp "simrs-vx/internal/domain/main-entities/chemo-protocol" ) type ChemoPlan struct { ecore.Main Parent_Id *uint `json:"parent_id"` // chemo.Id Protocol_Id *uint `json:"protocol_id"` - Protocol ecp.ChemoProtocol `json:"protocol,omitempty" gorm:"foreignKey:Protocol_Id;references:Id"` SeriesNumber *uint16 `json:"seriesNumber"` // series ke - CycleNumber *uint `json:"cycleNumber"` // cycle ke - PlanDate *time.Time `json:"planDate"` diff --git a/internal/domain/main-entities/chemo-protocol/entity.go b/internal/domain/main-entities/chemo-protocol/entity.go index e20f3592..63639f46 100644 --- a/internal/domain/main-entities/chemo-protocol/entity.go +++ b/internal/domain/main-entities/chemo-protocol/entity.go @@ -7,6 +7,7 @@ import ( erc "simrs-vx/internal/domain/references/common" ec "simrs-vx/internal/domain/main-entities/chemo" + ecp "simrs-vx/internal/domain/main-entities/chemo-plan" ) type ChemoProtocol struct { @@ -24,4 +25,5 @@ type ChemoProtocol struct { StartDate *time.Time `json:"startDate"` EndDate *time.Time `json:"endDate"` Status_Code erc.DataVerifiedCode `json:"status_code"` + ChemoPlans *[]ecp.ChemoPlan `json:"chemoPlans,omitempty" gorm:"foreignKey:Protocol_Id;references:Id"` } From c4103539c9cf5171996a1d0914918a8512d3c174 Mon Sep 17 00:00:00 2001 From: vanilia Date: Sat, 6 Dec 2025 04:45:05 +0700 Subject: [PATCH 22/45] adj chemoprotoc --- cmd/main-migration/migrations/20251205214433.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 5 +++-- internal/domain/main-entities/chemo-protocol/entity.go | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 cmd/main-migration/migrations/20251205214433.sql diff --git a/cmd/main-migration/migrations/20251205214433.sql b/cmd/main-migration/migrations/20251205214433.sql new file mode 100644 index 00000000..34343308 --- /dev/null +++ b/cmd/main-migration/migrations/20251205214433.sql @@ -0,0 +1,2 @@ +-- Modify "ChemoProtocol" table +ALTER TABLE "public"."ChemoProtocol" ADD COLUMN "Patient_Id" bigint NULL; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 9e1a235c..176afc27 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:JgjOL5Bl+2zIlc2E1Lz/LhEJo/IGWouNe79ccswAcq8= +h1:8SotxMlqYq7PNXcyAsIzO4075hP1c39CA2efE7Jp1kk= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -145,4 +145,5 @@ h1:JgjOL5Bl+2zIlc2E1Lz/LhEJo/IGWouNe79ccswAcq8= 20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM= 20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= 20251205073858.sql h1:Ep03jQ9hJAJILDJfKVcmi3Z6fqmTHSq9gKQtwf070PE= -20251205211957.sql h1:RGkuUdSgt8BtypqGpji9VBBi1r85e2ez1aJILTB7zi0= +20251205211957.sql h1:zRHcvLY+nfLdUyMcfpgI8vYQcPzJUWbfjkc4cK0QGHU= +20251205214433.sql h1:cPyzSgAn5VHElC5yHtK2TCKSnBoTI65S0kcoc2GbIxQ= diff --git a/internal/domain/main-entities/chemo-protocol/entity.go b/internal/domain/main-entities/chemo-protocol/entity.go index 63639f46..7ffc8afd 100644 --- a/internal/domain/main-entities/chemo-protocol/entity.go +++ b/internal/domain/main-entities/chemo-protocol/entity.go @@ -26,4 +26,5 @@ type ChemoProtocol struct { EndDate *time.Time `json:"endDate"` Status_Code erc.DataVerifiedCode `json:"status_code"` ChemoPlans *[]ecp.ChemoPlan `json:"chemoPlans,omitempty" gorm:"foreignKey:Protocol_Id;references:Id"` + Patient_Id *uint `json:"patient_id"` } From c5c4a10e2e8d45a3b22a53049b304605c01704e5 Mon Sep 17 00:00:00 2001 From: vanilia Date: Sat, 6 Dec 2025 05:11:58 +0700 Subject: [PATCH 23/45] adjust protoc --- .../migrations/20251205221124.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 5 +-- .../main-entities/chemo-protocol/entity.go | 34 +++++++++++-------- 3 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 cmd/main-migration/migrations/20251205221124.sql diff --git a/cmd/main-migration/migrations/20251205221124.sql b/cmd/main-migration/migrations/20251205221124.sql new file mode 100644 index 00000000..3eab115a --- /dev/null +++ b/cmd/main-migration/migrations/20251205221124.sql @@ -0,0 +1,2 @@ +-- Modify "ChemoProtocol" table +ALTER TABLE "public"."ChemoProtocol" ADD COLUMN "VerifiedAt" timestamptz NULL, ADD COLUMN "VerifiedBy_User_Id" bigint NULL, ADD CONSTRAINT "fk_ChemoProtocol_VerifiedBy" FOREIGN KEY ("VerifiedBy_User_Id") REFERENCES "public"."User" ("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 176afc27..09459c64 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:8SotxMlqYq7PNXcyAsIzO4075hP1c39CA2efE7Jp1kk= +h1:BsDkwn1AzNdKnOPVb6PkonyiXM7nTdVcjRdw62i/NlQ= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -146,4 +146,5 @@ h1:8SotxMlqYq7PNXcyAsIzO4075hP1c39CA2efE7Jp1kk= 20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= 20251205073858.sql h1:Ep03jQ9hJAJILDJfKVcmi3Z6fqmTHSq9gKQtwf070PE= 20251205211957.sql h1:zRHcvLY+nfLdUyMcfpgI8vYQcPzJUWbfjkc4cK0QGHU= -20251205214433.sql h1:cPyzSgAn5VHElC5yHtK2TCKSnBoTI65S0kcoc2GbIxQ= +20251205214433.sql h1:tgHB/fNy9XwAOWIqNI6GCqGXeJgSuZs2aHiCEj3BHZA= +20251205221124.sql h1:VthPlq3XcQOYz5VsFivb4Wof8jCAG36fAaerKmM4/OA= diff --git a/internal/domain/main-entities/chemo-protocol/entity.go b/internal/domain/main-entities/chemo-protocol/entity.go index 7ffc8afd..6377c136 100644 --- a/internal/domain/main-entities/chemo-protocol/entity.go +++ b/internal/domain/main-entities/chemo-protocol/entity.go @@ -8,23 +8,27 @@ import ( ec "simrs-vx/internal/domain/main-entities/chemo" ecp "simrs-vx/internal/domain/main-entities/chemo-plan" + eus "simrs-vx/internal/domain/main-entities/user" ) type ChemoProtocol struct { ecore.Main - Chemo_Id *uint `json:"chemo_id"` - Chemo *ec.Chemo `json:"chemo,omitempty" gorm:"foreignKey:Chemo_Id;references:Id"` - Patient_Weight *float32 `json:"patient_weight"` - Patient_Height *float32 `json:"patient_height"` - Diagnoses *string `json:"diagnoses"` - Duration *uint `json:"duration"` // not used - DurationUnit_Code *erc.TimeUnitCode `json:"durationUnit_code"` // not used - Interval *uint `json:"interval"` - Cycle *uint `json:"cycle"` // total cycle - Series *uint16 `json:"series"` // total series - StartDate *time.Time `json:"startDate"` - EndDate *time.Time `json:"endDate"` - Status_Code erc.DataVerifiedCode `json:"status_code"` - ChemoPlans *[]ecp.ChemoPlan `json:"chemoPlans,omitempty" gorm:"foreignKey:Protocol_Id;references:Id"` - Patient_Id *uint `json:"patient_id"` + Chemo_Id *uint `json:"chemo_id"` + Chemo *ec.Chemo `json:"chemo,omitempty" gorm:"foreignKey:Chemo_Id;references:Id"` + Patient_Weight *float32 `json:"patient_weight"` + Patient_Height *float32 `json:"patient_height"` + Diagnoses *string `json:"diagnoses"` + Duration *uint `json:"duration"` // not used + DurationUnit_Code *erc.TimeUnitCode `json:"durationUnit_code"` // not used + Interval *uint `json:"interval"` + Cycle *uint `json:"cycle"` // total cycle + Series *uint16 `json:"series"` // total series + StartDate *time.Time `json:"startDate"` + EndDate *time.Time `json:"endDate"` + Status_Code erc.DataVerifiedCode `json:"status_code"` + VerifiedAt *time.Time `json:"verifiedAt"` + VerifiedBy_User_Id *uint `json:"verifiedBy_user_id"` + VerifiedBy *eus.User `json:"verifiedBy,omitempty" gorm:"foreignKey:VerifiedBy_User_Id;references:Id"` + ChemoPlans *[]ecp.ChemoPlan `json:"chemoPlans,omitempty" gorm:"foreignKey:Protocol_Id;references:Id"` + Patient_Id *uint `json:"patient_id"` } From 019a413e9b56b77703e160283103335b775ea95a Mon Sep 17 00:00:00 2001 From: ari Date: Sat, 6 Dec 2025 08:36:05 +0700 Subject: [PATCH 24/45] update --- internal/domain/main-entities/procedure-report/entity.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/domain/main-entities/procedure-report/entity.go b/internal/domain/main-entities/procedure-report/entity.go index 82d178f2..81a888b6 100644 --- a/internal/domain/main-entities/procedure-report/entity.go +++ b/internal/domain/main-entities/procedure-report/entity.go @@ -3,7 +3,6 @@ package procedurereport import ( ecore "simrs-vx/internal/domain/base-entities/core" ed "simrs-vx/internal/domain/main-entities/doctor" - eem "simrs-vx/internal/domain/main-entities/employee" ee "simrs-vx/internal/domain/main-entities/encounter" "time" ) @@ -19,9 +18,9 @@ type ProcedureReport struct { Assistant_Name string `json:"assistant_name"` Instrumentor_Name string `json:"instrumentor_name"` Diagnose *string `json:"diagnose" gorm:"size:1024"` - Nurse_Name string `json:"nurse_code" gorm:"size:10"` + Nurse_Name string `json:"nurse_name" gorm:"size:10"` Anesthesia_Doctor_Code *string `json:"anesthesia_doctor_code" gorm:"size:10"` - Anesthesia *eem.Employee `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` + Anesthesia_Doctor *ed.Doctor `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"` ProcedureValue string `json:"procedure_value"` ExecutionValue string `json:"execution_value"` From 17403278149789644c6c86b79bda7a33c63d0b3e Mon Sep 17 00:00:00 2001 From: ari Date: Sat, 6 Dec 2025 09:54:05 +0700 Subject: [PATCH 25/45] update migration issue --- .../migrations/20251201104439.sql | 30 ++++++------------- .../migrations/20251201113804.sql | 4 +-- .../migrations/20251201113858.sql | 4 +-- .../migrations/20251201114751.sql | 4 +-- .../migrations/20251201114913.sql | 4 +-- .../migrations/20251206021053.sql | 26 ++++++++++++++++ .../main-entities/procedure-report/dto.go | 9 +++--- .../main-entities/procedure-report/entity.go | 2 +- .../main-use-case/procedure-report/helper.go | 2 +- 9 files changed, 50 insertions(+), 35 deletions(-) create mode 100644 cmd/main-migration/migrations/20251206021053.sql diff --git a/cmd/main-migration/migrations/20251201104439.sql b/cmd/main-migration/migrations/20251201104439.sql index 6862ccde..50f60b6b 100644 --- a/cmd/main-migration/migrations/20251201104439.sql +++ b/cmd/main-migration/migrations/20251201104439.sql @@ -1,5 +1,5 @@ --- Create "ProcedureReport" table -CREATE TABLE "public"."ProcedureReport" ( +-- Create "ActionReport" table +CREATE TABLE "public"."ActionReport" ( "Id" bigserial NOT NULL, "CreatedAt" timestamptz NULL, "UpdatedAt" timestamptz NULL, @@ -7,25 +7,13 @@ CREATE TABLE "public"."ProcedureReport" ( "Encounter_Id" bigint NULL, "Date" character varying(20) NOT NULL, "Doctor_Code" character varying(10) NULL, - "Operator_Name" character varying(120) NULL, - "Assistant_Name" character varying(120) NULL, - "Instrumentor_Name" character varying(120) NULL, - "Anesthesia_Doctor_Code" character varying(10) NULL, - "Anesthesia_Nurse_Name" character varying(120) NULL, + "Operator_Employe_Id" bigint NULL, + "Assistant_Employe_Id" bigint NULL, + "Instrumentor_Employe_Id" bigint NULL, "Diagnose" character varying(1024) NULL, - "Nurse_Name" character varying(120) NULL, - "ProcedureValue" text NULL, - "ExecutionValue" text NULL, - "Type" character varying(10) NULL, + "Procedures" character varying(10240) NULL, + "Nurse_Code" character varying(10) NULL, + "Value" text NULL, PRIMARY KEY ("Id"), - CONSTRAINT "fk_ProcedureReport_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION + CONSTRAINT "fk_ActionReport_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION ); - --- PROPER - -- "Operator_Employe_Id" bigint NULL, - -- "Assistant_Employe_Id" bigint NULL, - -- "Instrumentor_Employe_Id" bigint NULL, - -- "Diagnose" character varying(1024) NULL, - -- "Procedures" character varying(10240) NULL, - -- "Nurse_Code" character varying(10) NULL, - diff --git a/cmd/main-migration/migrations/20251201113804.sql b/cmd/main-migration/migrations/20251201113804.sql index 8cecb5fe..0f5c5123 100644 --- a/cmd/main-migration/migrations/20251201113804.sql +++ b/cmd/main-migration/migrations/20251201113804.sql @@ -1,2 +1,2 @@ --- Modify "ProcedureReport" table -ALTER TABLE "public"."ProcedureReport" DROP COLUMN "Date", DROP COLUMN "Procedures"; +-- Modify "ActionReport" table +ALTER TABLE "public"."ActionReport" DROP COLUMN "Date", DROP COLUMN "Procedures"; diff --git a/cmd/main-migration/migrations/20251201113858.sql b/cmd/main-migration/migrations/20251201113858.sql index bc77d02c..fd6fddc9 100644 --- a/cmd/main-migration/migrations/20251201113858.sql +++ b/cmd/main-migration/migrations/20251201113858.sql @@ -1,2 +1,2 @@ --- Modify "ProcedureReport" table -ALTER TABLE "public"."ProcedureReport" ADD COLUMN "Date" timestamptz NOT NULL; +-- Modify "ActionReport" table +ALTER TABLE "public"."ActionReport" ADD COLUMN "Date" timestamptz NOT NULL; diff --git a/cmd/main-migration/migrations/20251201114751.sql b/cmd/main-migration/migrations/20251201114751.sql index 339ee39c..6611b811 100644 --- a/cmd/main-migration/migrations/20251201114751.sql +++ b/cmd/main-migration/migrations/20251201114751.sql @@ -1,2 +1,2 @@ --- Modify "ProcedureReport" table -ALTER TABLE "public"."ProcedureReport" ADD CONSTRAINT "fk_ProcedureReport_Instrumentor_Employe" FOREIGN KEY ("Instrumentor_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ProcedureReport_Nurse" FOREIGN KEY ("Nurse_Code") REFERENCES "public"."Nurse" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ProcedureReport_Operator_Employe" FOREIGN KEY ("Operator_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Modify "ActionReport" table +ALTER TABLE "public"."ActionReport" ADD CONSTRAINT "fk_ActionReport_Instrumentor_Employe" FOREIGN KEY ("Instrumentor_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ActionReport_Nurse" FOREIGN KEY ("Nurse_Code") REFERENCES "public"."Nurse" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ActionReport_Operator_Employe" FOREIGN KEY ("Operator_Employe_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/cmd/main-migration/migrations/20251201114913.sql b/cmd/main-migration/migrations/20251201114913.sql index 85c0281c..5155ed37 100644 --- a/cmd/main-migration/migrations/20251201114913.sql +++ b/cmd/main-migration/migrations/20251201114913.sql @@ -1,2 +1,2 @@ --- Modify "ProcedureReport" table -ALTER TABLE "public"."ProcedureReport" ADD CONSTRAINT "fk_ProcedureReport_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Modify "ActionReport" table +ALTER TABLE "public"."ActionReport" ADD CONSTRAINT "fk_ActionReport_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/cmd/main-migration/migrations/20251206021053.sql b/cmd/main-migration/migrations/20251206021053.sql new file mode 100644 index 00000000..03ab3bfb --- /dev/null +++ b/cmd/main-migration/migrations/20251206021053.sql @@ -0,0 +1,26 @@ +-- Create "ProcedureReport" table +CREATE TABLE "public"."ProcedureReport" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Encounter_Id" bigint NULL, + "Date" timestamptz NOT NULL, + "Doctor_Code" character varying(10) NULL, + "Operator_Name" text NULL, + "Assistant_Name" text NULL, + "Instrumentor_Name" text NULL, + "Diagnose" character varying(1024) NULL, + "Nurse_Name" character varying(10) NULL, + "Anesthesia_Doctor_Code" character varying(10) NULL, + "Anesthesia_Nurse_Name" text NULL, + "ProcedureValue" text NULL, + "ExecutionValue" text NULL, + "Type_Code" text NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_ProcedureReport_Anesthesia_Doctor" FOREIGN KEY ("Anesthesia_Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_ProcedureReport_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_ProcedureReport_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Drop "ActionReport" table +DROP TABLE "public"."ActionReport"; diff --git a/internal/domain/main-entities/procedure-report/dto.go b/internal/domain/main-entities/procedure-report/dto.go index b27191a4..ec815b43 100644 --- a/internal/domain/main-entities/procedure-report/dto.go +++ b/internal/domain/main-entities/procedure-report/dto.go @@ -21,7 +21,7 @@ type CreateDto struct { Nurse_Name string `json:"nurse_name" validate:"required"` ProcedureValue string `json:"procedure_value" validate:"required"` ExecutionValue string `json:"execution_value" validate:"required"` - Type string `json:"type" validate:"required"` + Type_Code string `json:"type_code" validate:"required"` pa.AuthInfo @@ -41,7 +41,8 @@ type ReadListDto struct { } type FilterDto struct { - Encounter_Id *uint `json:"encounter-id"` + Encounter_Id *uint `json:"encounter-id"` + Type_Code string `json:"type-code"` } type ReadDetailDto struct { @@ -78,7 +79,7 @@ type ResponseDto struct { Nurse_Name string `json:"nurse_name"` ProcedureValue *string `json:"procedure_value"` ExecutionValue *string `json:"execution_value"` - Type string `json:"type"` + Type_Code string `json:"type_code"` } func (d ProcedureReport) ToResponse() ResponseDto { @@ -95,7 +96,7 @@ func (d ProcedureReport) ToResponse() ResponseDto { Nurse_Name: d.Nurse_Name, ProcedureValue: &d.ProcedureValue, ExecutionValue: &d.ExecutionValue, - Type: d.Type, + Type_Code: d.Type_Code, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/procedure-report/entity.go b/internal/domain/main-entities/procedure-report/entity.go index 81a888b6..4a8a7032 100644 --- a/internal/domain/main-entities/procedure-report/entity.go +++ b/internal/domain/main-entities/procedure-report/entity.go @@ -24,7 +24,7 @@ type ProcedureReport struct { Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"` ProcedureValue string `json:"procedure_value"` ExecutionValue string `json:"execution_value"` - Type string `json:"type"` + Type_Code string `json:"type_code"` // SurgerySize_Code *string `json:"surgerySize_code" gorm:"size:10"` // Billing_Code *string `json:"billing_code" gorm:"size:10"` diff --git a/internal/use-case/main-use-case/procedure-report/helper.go b/internal/use-case/main-use-case/procedure-report/helper.go index 9fb87778..e16711e5 100644 --- a/internal/use-case/main-use-case/procedure-report/helper.go +++ b/internal/use-case/main-use-case/procedure-report/helper.go @@ -29,7 +29,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ProcedureReport) { data.Nurse_Name = inputSrc.Nurse_Name data.ProcedureValue = inputSrc.ProcedureValue data.ExecutionValue = inputSrc.ExecutionValue - data.Type = inputSrc.Type + data.Type_Code = inputSrc.Type_Code //PROPER // data.Operator_Employe_Id = inputSrc.Operator_Employe_Id From faca8dfa14d8a525510b0400c4a32aaa16842721 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Sun, 7 Dec 2025 09:07:01 +0700 Subject: [PATCH 26/45] feat/order-things: added ap-mcu-order --- .../migrations/20251207020537.sql | 22 ++ cmd/main-migration/migrations/atlas.sum | 5 +- .../domain/main-entities/ap-mcu-order/dto.go | 94 ++++++ .../main-entities/ap-mcu-order/entity.go | 23 ++ internal/interface/migration/main-entities.go | 2 + .../main-use-case/ap-mcu-order/case.go | 276 ++++++++++++++++++ .../main-use-case/ap-mcu-order/helper.go | 30 ++ .../main-use-case/ap-mcu-order/lib.go | 140 +++++++++ .../ap-mcu-order/middleware-runner.go | 103 +++++++ .../main-use-case/ap-mcu-order/middleware.go | 9 + .../main-use-case/ap-mcu-order/tycovar.go | 44 +++ 11 files changed, 746 insertions(+), 2 deletions(-) create mode 100644 cmd/main-migration/migrations/20251207020537.sql create mode 100644 internal/domain/main-entities/ap-mcu-order/dto.go create mode 100644 internal/domain/main-entities/ap-mcu-order/entity.go create mode 100644 internal/use-case/main-use-case/ap-mcu-order/case.go create mode 100644 internal/use-case/main-use-case/ap-mcu-order/helper.go create mode 100644 internal/use-case/main-use-case/ap-mcu-order/lib.go create mode 100644 internal/use-case/main-use-case/ap-mcu-order/middleware-runner.go create mode 100644 internal/use-case/main-use-case/ap-mcu-order/middleware.go create mode 100644 internal/use-case/main-use-case/ap-mcu-order/tycovar.go diff --git a/cmd/main-migration/migrations/20251207020537.sql b/cmd/main-migration/migrations/20251207020537.sql new file mode 100644 index 00000000..14142cb0 --- /dev/null +++ b/cmd/main-migration/migrations/20251207020537.sql @@ -0,0 +1,22 @@ +-- Create "ApMcuOrder" table +CREATE TABLE "public"."ApMcuOrder" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "McuOrder_Id" smallint NULL, + "Substances" text NULL, + "Fictations" text NULL, + "Localization" text NULL, + "ClinicalDiagnoses" text NULL, + "Stadium" text NULL, + "ClinicalNotes" text NULL, + "PastHistory" text NULL, + "CurrentHistory" text NULL, + "PrevApMcu" text NULL, + "PrevApMcuNotes" text NULL, + "SupportingExams" text NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_ApMcuOrder_McuOrder_Id" UNIQUE ("McuOrder_Id"), + CONSTRAINT "fk_ApMcuOrder_McuOrder" FOREIGN KEY ("McuOrder_Id") REFERENCES "public"."McuOrder" ("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 3ec1b876..632e0ddb 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:qjr3k9/ymXjw1nopw49c6+fWtu0n+H8sQgsioqUC9Fo= +h1:1BOh7w/6hkhDj1PptjXT4tLOgmRtIIofGm3ERJ+EfyM= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -144,4 +144,5 @@ h1:qjr3k9/ymXjw1nopw49c6+fWtu0n+H8sQgsioqUC9Fo= 20251202160848.sql h1:Kd2/TziKSMezrt4XgbjQcYvY/Lo9rX0qw7/Lz0/oyKk= 20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM= 20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= -20251203205052.sql h1:az/hGpk7u4YKT7gU+UuEw9guqB9AqdckPF1cYavQ3CA= +20251203205052.sql h1:nk0VK2Uv4bHE3SBfHo/aevVZxtHzr7zAzvmMU8TCCtk= +20251207020537.sql h1:UmtHxX1vZi/BiKxHPOOP7fALRZ3RoRGSGmUma7ttp8w= diff --git a/internal/domain/main-entities/ap-mcu-order/dto.go b/internal/domain/main-entities/ap-mcu-order/dto.go new file mode 100644 index 00000000..7fcaa1d3 --- /dev/null +++ b/internal/domain/main-entities/ap-mcu-order/dto.go @@ -0,0 +1,94 @@ +package apmcuorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + emo "simrs-vx/internal/domain/main-entities/mcu-order" +) + +type CreateDto struct { + McuOrder_Id string `json:"mcuOrder_id"` + Substances string `json:"substances"` + Fictations string `json:"fictations"` + Localization string `json:"localization"` + ClinicalDiagnoses string `json:"clinicalDiagnoses"` + Stadium string `json:"stadium"` + ClinicalNotes string `json:"clinicalNotes"` + PastHistory string `json:"pastHistory"` + CurrentHistory string `json:"currentHistory"` + PrevApMcu string `json:"prevApMcu"` + PrevApMcuNotes string `json:"prevApMcuNotes"` + SupportingExams string `json:"supportingExams"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Sort string `json:"sort"` + Pagination ecore.Pagination +} + +type FilterDto struct { + McuOrder_Id string `json:"mcu-order-id"` +} + +type ReadDetailDto struct { + Id uint64 `json:"id"` +} + +type UpdateDto struct { + Id uint64 `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint64 `json:"id"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.Main + McuOrder_Id string `json:"mcuOrder_id"` + McuOrder *emo.McuOrder + Substances string `json:"substances"` + Fictations string `json:"fictations"` + Localization string `json:"localization"` + ClinicalDiagnoses string `json:"clinicalDiagnoses"` + Stadium string `json:"stadium"` + ClinicalNotes string `json:"clinicalNotes"` + PastHistory string `json:"pastHistory"` + CurrentHistory string `json:"currentHistory"` + PrevApMcu string `json:"prevApMcu"` + PrevApMcuNotes string `json:"prevApMcuNotes"` + SupportingExams string `json:"supportingExams"` +} + +func (d ApMcuOrder) ToResponse() ResponseDto { + resp := ResponseDto{ + McuOrder_Id: d.McuOrder_Id, + Substances: d.Substances, + Fictations: d.Fictations, + Localization: d.Localization, + ClinicalDiagnoses: d.ClinicalDiagnoses, + Stadium: d.Stadium, + ClinicalNotes: d.ClinicalNotes, + PastHistory: d.PastHistory, + CurrentHistory: d.CurrentHistory, + PrevApMcu: d.PrevApMcu, + PrevApMcuNotes: d.PrevApMcuNotes, + } + resp.McuOrder = d.McuOrder + return resp +} + +func ToResponseList(data []ApMcuOrder) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/ap-mcu-order/entity.go b/internal/domain/main-entities/ap-mcu-order/entity.go new file mode 100644 index 00000000..f57e7497 --- /dev/null +++ b/internal/domain/main-entities/ap-mcu-order/entity.go @@ -0,0 +1,23 @@ +package apmcuorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + emo "simrs-vx/internal/domain/main-entities/mcu-order" +) + +type ApMcuOrder struct { + ecore.BigMain + McuOrder_Id string `json:"mcuOrder_id" gorm:"unique;size:10"` + McuOrder *emo.McuOrder `json:"mcuOrder,omitempty" gorm:"foreignKey:McuOrder_Id;references:Id"` + Substances string `json:"substances"` + Fictations string `json:"fictations"` + Localization string `json:"localization"` + ClinicalDiagnoses string `json:"clinicalDiagnoses"` + Stadium string `json:"stadium"` + ClinicalNotes string `json:"clinicalNotes"` + PastHistory string `json:"pastHistory"` + CurrentHistory string `json:"currentHistory"` + PrevApMcu string `json:"prevApMcu"` + PrevApMcuNotes string `json:"prevApMcuNotes"` + SupportingExams string `json:"supportingExams"` +} diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 34530d78..9767b21b 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -8,6 +8,7 @@ import ( ambulatory "simrs-vx/internal/domain/main-entities/ambulatory" antibioticinuse "simrs-vx/internal/domain/main-entities/antibiotic-in-use" antibioticsrccategory "simrs-vx/internal/domain/main-entities/antibiotic-src-category" + apmcuorder "simrs-vx/internal/domain/main-entities/ap-mcu-order" appointment "simrs-vx/internal/domain/main-entities/appointment" authpartner "simrs-vx/internal/domain/main-entities/auth-partner" chemo "simrs-vx/internal/domain/main-entities/chemo" @@ -121,6 +122,7 @@ import ( func getMainEntities() []any { return []any{ &authpartner.AuthPartner{}, + &apmcuorder.ApMcuOrder{}, &user.User{}, &userfes.UserFes{}, &division.Division{}, diff --git a/internal/use-case/main-use-case/ap-mcu-order/case.go b/internal/use-case/main-use-case/ap-mcu-order/case.go new file mode 100644 index 00000000..845b8eeb --- /dev/null +++ b/internal/use-case/main-use-case/ap-mcu-order/case.go @@ -0,0 +1,276 @@ +package apmcuorder + +import ( + e "simrs-vx/internal/domain/main-entities/ap-mcu-order" + "strconv" + + dg "github.com/karincake/apem/db-gorm-pg" + d "github.com/karincake/dodol" + + pl "simrs-vx/pkg/logger" + pu "simrs-vx/pkg/use-case-helper" + + "gorm.io/gorm" +) + +const source = "device" + +func Create(input e.CreateDto) (*d.Data, error) { + data := e.ApMcuOrder{} + + event := pl.Event{ + Feature: "Create", + Source: source, + } + + // Start log + pl.SetLogInfo(&event, input, "started", "create") + + err := dg.I.Transaction(func(tx *gorm.DB) error { + mwRunner := newMiddlewareRunner(&event, tx) + mwRunner.setMwType(pu.MWTPre) + // Run pre-middleware + if err := mwRunner.RunCreateMiddleware(createPreMw, &input, &data); err != nil { + return err + } + + if resData, err := CreateData(input, &event, tx); err != nil { + return err + } else { + data = *resData + } + + mwRunner.setMwType(pu.MWTPost) + // Run post-middleware + if err := mwRunner.RunCreateMiddleware(createPostMw, &input, &data); err != nil { + return err + } + + pl.SetLogInfo(&event, nil, "complete") + + return nil + }) + + if err != nil { + return nil, err + } + + return &d.Data{ + Meta: d.II{ + "source": source, + "structure": "single-data", + "status": "created", + }, + Data: data.ToResponse(), + }, nil +} + +func ReadList(input e.ReadListDto) (*d.Data, error) { + var data *e.ApMcuOrder + var dataList []e.ApMcuOrder + var metaList *e.MetaDto + var err error + + event := pl.Event{ + Feature: "ReadList", + Source: source, + } + + // Start log + pl.SetLogInfo(&event, input, "started", "readList") + + err = dg.I.Transaction(func(tx *gorm.DB) error { + mwRunner := newMiddlewareRunner(&event, tx) + mwRunner.setMwType(pu.MWTPre) + // Run pre-middleware + if err := mwRunner.RunReadListMiddleware(readListPreMw, &input, data); err != nil { + return err + } + + if dataList, metaList, err = ReadListData(input, &event, tx); err != nil { + return err + } + + mwRunner.setMwType(pu.MWTPost) + // Run post-middleware + if err := mwRunner.RunReadListMiddleware(readListPostMw, &input, data); err != nil { + return err + } + + return nil + }) + + if err != nil { + return nil, err + } + + return &d.Data{ + Meta: d.IS{ + "source": source, + "structure": "list-data", + "status": "fetched", + "page_number": strconv.Itoa(metaList.PageNumber), + "page_size": strconv.Itoa(metaList.PageSize), + "record_totalCount": strconv.Itoa(metaList.Count), + "record_currentCount": strconv.Itoa(len(dataList)), + }, + Data: e.ToResponseList(dataList), + }, nil +} + +func ReadDetail(input e.ReadDetailDto) (*d.Data, error) { + var data *e.ApMcuOrder + var err error + + event := pl.Event{ + Feature: "ReadDetail", + Source: source, + } + + // Start log + pl.SetLogInfo(&event, input, "started", "readDetail") + + err = dg.I.Transaction(func(tx *gorm.DB) error { + mwRunner := newMiddlewareRunner(&event, tx) + mwRunner.setMwType(pu.MWTPre) + // Run pre-middleware + if err := mwRunner.RunReadDetailMiddleware(readDetailPreMw, &input, data); err != nil { + return err + } + + if data, err = ReadDetailData(input, &event, tx); err != nil { + return err + } + + mwRunner.setMwType(pu.MWTPost) + // Run post-middleware + if err := mwRunner.RunReadDetailMiddleware(readDetailPostMw, &input, data); err != nil { + return err + } + + return nil + }) + + if err != nil { + return nil, err + } + + return &d.Data{ + Meta: d.IS{ + "source": source, + "structure": "single-data", + "status": "fetched", + }, + Data: data.ToResponse(), + }, nil +} + +func Update(input e.UpdateDto) (*d.Data, error) { + rdDto := e.ReadDetailDto{Id: input.Id} + var data *e.ApMcuOrder + var err error + + event := pl.Event{ + Feature: "Update", + Source: source, + } + + // Start log + pl.SetLogInfo(&event, input, "started", "update") + + 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 + } + + mwRunner := newMiddlewareRunner(&event, tx) + mwRunner.setMwType(pu.MWTPre) + // Run pre-middleware + if err := mwRunner.RunUpdateMiddleware(readDetailPreMw, &rdDto, data); err != nil { + return err + } + + if err := UpdateData(input, data, &event, tx); err != nil { + return err + } + + pl.SetLogInfo(&event, nil, "complete") + + mwRunner.setMwType(pu.MWTPost) + // Run post-middleware + if err := mwRunner.RunUpdateMiddleware(readDetailPostMw, &rdDto, data); err != nil { + return err + } + + return nil + }) + + if err != nil { + return nil, err + } + + return &d.Data{ + Meta: d.IS{ + "source": source, + "structure": "single-data", + "status": "updated", + }, + Data: data.ToResponse(), + }, nil + +} + +func Delete(input e.DeleteDto) (*d.Data, error) { + rdDto := e.ReadDetailDto{Id: input.Id} + var data *e.ApMcuOrder + var err error + + event := pl.Event{ + Feature: "Delete", + Source: source, + } + + // Start log + pl.SetLogInfo(&event, input, "started", "delete") + + 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 + } + + mwRunner := newMiddlewareRunner(&event, tx) + mwRunner.setMwType(pu.MWTPre) + // Run pre-middleware + if err := mwRunner.RunDeleteMiddleware(readDetailPreMw, &rdDto, data); err != nil { + return err + } + + if err := DeleteData(data, &event, tx); err != nil { + return err + } + + mwRunner.setMwType(pu.MWTPost) + // Run post-middleware + if err := mwRunner.RunDeleteMiddleware(readDetailPostMw, &rdDto, data); err != nil { + return err + } + + return nil + }) + + if err != nil { + return nil, err + } + + return &d.Data{ + Meta: d.IS{ + "source": source, + "structure": "single-data", + "status": "deleted", + }, + Data: data.ToResponse(), + }, nil + +} diff --git a/internal/use-case/main-use-case/ap-mcu-order/helper.go b/internal/use-case/main-use-case/ap-mcu-order/helper.go new file mode 100644 index 00000000..717e6ce6 --- /dev/null +++ b/internal/use-case/main-use-case/ap-mcu-order/helper.go @@ -0,0 +1,30 @@ +/* +DESCRIPTION: +Any functions that are used internally by the use-case +*/ +package apmcuorder + +import ( + e "simrs-vx/internal/domain/main-entities/ap-mcu-order" +) + +func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ApMcuOrder) { + var inputSrc *e.CreateDto + if inputT, ok := any(input).(*e.CreateDto); ok { + inputSrc = inputT + } else { + inputTemp := any(input).(*e.UpdateDto) + inputSrc = &inputTemp.CreateDto + } + + data.McuOrder_Id = inputSrc.McuOrder_Id + data.Substances = inputSrc.Substances + data.Fictations = inputSrc.Fictations + data.Localization = inputSrc.Localization + data.ClinicalDiagnoses = inputSrc.ClinicalDiagnoses + data.Stadium = inputSrc.Stadium + data.ClinicalNotes = inputSrc.ClinicalNotes + data.PastHistory = inputSrc.PastHistory + data.CurrentHistory = inputSrc.CurrentHistory + data.PrevApMcu = inputSrc.PrevApMcu +} diff --git a/internal/use-case/main-use-case/ap-mcu-order/lib.go b/internal/use-case/main-use-case/ap-mcu-order/lib.go new file mode 100644 index 00000000..8b6d8a74 --- /dev/null +++ b/internal/use-case/main-use-case/ap-mcu-order/lib.go @@ -0,0 +1,140 @@ +package apmcuorder + +import ( + e "simrs-vx/internal/domain/main-entities/ap-mcu-order" + + plh "simrs-vx/pkg/lib-helper" + pl "simrs-vx/pkg/logger" + pu "simrs-vx/pkg/use-case-helper" + + dg "github.com/karincake/apem/db-gorm-pg" + gh "github.com/karincake/getuk" + "gorm.io/gorm" +) + +func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.ApMcuOrder, error) { + pl.SetLogInfo(event, nil, "started", "DBCreate") + + data := e.ApMcuOrder{} + setData(&input, &data) + + var tx *gorm.DB + if len(dbx) > 0 { + tx = dbx[0] + } else { + tx = dg.I + } + + if err := tx.Create(&data).Error; err != nil { + return nil, plh.HandleCreateError(input, event, err) + } + + pl.SetLogInfo(event, nil, "complete") + return &data, nil +} + +func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.ApMcuOrder, *e.MetaDto, error) { + pl.SetLogInfo(event, input, "started", "DBReadList") + data := []e.ApMcuOrder{} + pagination := gh.Pagination{} + count := int64(0) + meta := e.MetaDto{} + + var tx *gorm.DB + if len(dbx) > 0 { + tx = dbx[0] + } else { + tx = dg.I + } + + tx = tx. + Model(&e.ApMcuOrder{}). + Scopes(gh.Preload(input.Includes)). + Scopes(gh.Filter(input.FilterDto)). + Count(&count). + Scopes(gh.Paginate(input, &pagination)). + Scopes(gh.Sort(input.Sort)) + + if err := tx.Find(&data).Error; err != nil { + if err == gorm.ErrRecordNotFound { + return nil, &meta, nil + } + return nil, nil, plh.HandleListError(input, event, err) + } + + meta.Count = int(count) + meta.PageNumber = pagination.PageNumber + meta.PageSize = pagination.PageSize + + pl.SetLogInfo(event, nil, "complete") + return data, &meta, nil +} + +func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e.ApMcuOrder, error) { + pl.SetLogInfo(event, input, "started", "DBReadDetail") + data := e.ApMcuOrder{} + + var tx *gorm.DB + if len(dbx) > 0 { + tx = dbx[0] + } else { + tx = dg.I + } + + if err := tx.First(&data, input.Id).Error; err != nil { + if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil { + return nil, processedErr + } + } + + pl.SetLogInfo(event, nil, "complete") + return &data, nil +} + +func UpdateData(input e.UpdateDto, data *e.ApMcuOrder, event *pl.Event, dbx ...*gorm.DB) error { + pl.SetLogInfo(event, data, "started", "DBUpdate") + setData(&input, data) + + var tx *gorm.DB + if len(dbx) > 0 { + tx = dbx[0] + } else { + tx = dg.I + } + + if err := tx.Save(&data).Error; 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 +} + +func DeleteData(data *e.ApMcuOrder, event *pl.Event, dbx ...*gorm.DB) error { + pl.SetLogInfo(event, data, "started", "DBDelete") + var tx *gorm.DB + if len(dbx) > 0 { + tx = dbx[0] + } else { + tx = dg.I + } + + if err := tx.Delete(&data).Error; err != nil { + event.Status = "failed" + event.ErrInfo = pl.ErrorInfo{ + Code: "data-delete-fail", + Detail: "Database delete failed", + Raw: err, + } + return pl.SetLogError(event, data) + } + + pl.SetLogInfo(event, nil, "complete") + return nil +} diff --git a/internal/use-case/main-use-case/ap-mcu-order/middleware-runner.go b/internal/use-case/main-use-case/ap-mcu-order/middleware-runner.go new file mode 100644 index 00000000..dc7f2495 --- /dev/null +++ b/internal/use-case/main-use-case/ap-mcu-order/middleware-runner.go @@ -0,0 +1,103 @@ +package apmcuorder + +import ( + e "simrs-vx/internal/domain/main-entities/ap-mcu-order" + pl "simrs-vx/pkg/logger" + pu "simrs-vx/pkg/use-case-helper" + + "gorm.io/gorm" +) + +type middlewareRunner struct { + Event *pl.Event + Tx *gorm.DB + MwType pu.MWType +} + +// NewMiddlewareExecutor creates a new middleware executor +func newMiddlewareRunner(event *pl.Event, tx *gorm.DB) *middlewareRunner { + return &middlewareRunner{ + Event: event, + Tx: tx, + } +} + +// ExecuteCreateMiddleware executes create middleware +func (me *middlewareRunner) RunCreateMiddleware(middlewares []createMw, input *e.CreateDto, data *e.ApMcuOrder) error { + for _, middleware := range middlewares { + logData := pu.GetLogData(input, data) + + pl.SetLogInfo(me.Event, logData, "started", middleware.Name) + + if err := middleware.Func(input, data, me.Tx); err != nil { + return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err) + } + + pl.SetLogInfo(me.Event, nil, "complete") + } + return nil +} + +func (me *middlewareRunner) RunReadListMiddleware(middlewares []readListMw, input *e.ReadListDto, data *e.ApMcuOrder) error { + for _, middleware := range middlewares { + logData := pu.GetLogData(input, data) + + pl.SetLogInfo(me.Event, logData, "started", middleware.Name) + + if err := middleware.Func(input, data, me.Tx); err != nil { + return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err) + } + + pl.SetLogInfo(me.Event, nil, "complete") + } + return nil +} + +func (me *middlewareRunner) RunReadDetailMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ApMcuOrder) error { + for _, middleware := range middlewares { + logData := pu.GetLogData(input, data) + + pl.SetLogInfo(me.Event, logData, "started", middleware.Name) + + if err := middleware.Func(input, data, me.Tx); err != nil { + return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err) + } + + pl.SetLogInfo(me.Event, nil, "complete") + } + return nil +} + +func (me *middlewareRunner) RunUpdateMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ApMcuOrder) error { + for _, middleware := range middlewares { + logData := pu.GetLogData(input, data) + + pl.SetLogInfo(me.Event, logData, "started", middleware.Name) + + if err := middleware.Func(input, data, me.Tx); err != nil { + return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err) + } + + pl.SetLogInfo(me.Event, nil, "complete") + } + return nil +} + +func (me *middlewareRunner) RunDeleteMiddleware(middlewares []readDetailMw, input *e.ReadDetailDto, data *e.ApMcuOrder) error { + for _, middleware := range middlewares { + logData := pu.GetLogData(input, data) + + pl.SetLogInfo(me.Event, logData, "started", middleware.Name) + + if err := middleware.Func(input, data, me.Tx); err != nil { + return pu.HandleMiddlewareError(me.Event, string(me.MwType), middleware.Name, logData, err) + } + + pl.SetLogInfo(me.Event, nil, "complete") + } + return nil +} + +func (me *middlewareRunner) setMwType(mwType pu.MWType) { + me.MwType = mwType +} diff --git a/internal/use-case/main-use-case/ap-mcu-order/middleware.go b/internal/use-case/main-use-case/ap-mcu-order/middleware.go new file mode 100644 index 00000000..38161afe --- /dev/null +++ b/internal/use-case/main-use-case/ap-mcu-order/middleware.go @@ -0,0 +1,9 @@ +package apmcuorder + +// example of middleware +// func init() { +// createPreMw = append(createPreMw, +// CreateMw{Name: "modif-input", Func: pm.ModifInput}, +// CreateMw{Name: "check-data", Func: pm.CheckData}, +// ) +// } diff --git a/internal/use-case/main-use-case/ap-mcu-order/tycovar.go b/internal/use-case/main-use-case/ap-mcu-order/tycovar.go new file mode 100644 index 00000000..7f301ff1 --- /dev/null +++ b/internal/use-case/main-use-case/ap-mcu-order/tycovar.go @@ -0,0 +1,44 @@ +/* +DESCRIPTION: +A sample, part of the package that contains type, constants, and/or variables. + +In this sample it also provides type and variable regarding the needs of the +middleware to separate from main use-case which has the basic CRUD +functionality. The purpose of this is to make the code more maintainable. +*/ +package apmcuorder + +import ( + "gorm.io/gorm" + + e "simrs-vx/internal/domain/main-entities/ap-mcu-order" +) + +type createMw struct { + Name string + Func func(input *e.CreateDto, data *e.ApMcuOrder, tx *gorm.DB) error +} + +type readListMw struct { + Name string + Func func(input *e.ReadListDto, data *e.ApMcuOrder, tx *gorm.DB) error +} + +type readDetailMw struct { + Name string + Func func(input *e.ReadDetailDto, data *e.ApMcuOrder, tx *gorm.DB) error +} + +type UpdateMw = readDetailMw +type DeleteMw = readDetailMw + +var createPreMw []createMw // preprocess middleware +var createPostMw []createMw // postprocess middleware +var readListPreMw []readListMw // .. +var readListPostMw []readListMw // .. +var readDetailPreMw []readDetailMw +var readDetailPostMw []readDetailMw +var updatePreMw []readDetailMw +var updatePostMw []readDetailMw +var deletePreMw []readDetailMw +var deletePostMw []readDetailMw From b9e0d2beb052fd79064055ea48729f965b49c206 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Sun, 7 Dec 2025 18:35:29 +0700 Subject: [PATCH 27/45] feat/order-things: seperate mcu-order by scope --- .../main-entities/ap-mcu-order/base/dto.go | 23 +++++ .../main-entities/ap-mcu-order/base/entity.go | 23 +++++ .../domain/main-entities/ap-mcu-order/dto.go | 57 +++++++------ .../main-entities/ap-mcu-order/entity.go | 22 ++--- .../main-entities/cp-mcu-order/base/entity.go | 19 +++++ .../domain/main-entities/cp-mcu-order/dto.go | 80 ++++++++++++++++++ .../main-entities/cp-mcu-order/entity.go | 13 +++ .../micro-mcu-order/base/entity.go | 16 ++++ .../main-entities/micro-mcu-order/dto.go | 82 ++++++++++++++++++ .../main-entities/micro-mcu-order/entity.go | 13 +++ .../radiology-mcu-order/base/entity.go | 15 ++++ .../main-entities/radiology-mcu-order/dto.go | 84 +++++++++++++++++++ .../radiology-mcu-order/entity.go | 15 ++++ .../main-use-case/ap-mcu-order/helper.go | 3 - 14 files changed, 417 insertions(+), 48 deletions(-) create mode 100644 internal/domain/main-entities/ap-mcu-order/base/dto.go create mode 100644 internal/domain/main-entities/ap-mcu-order/base/entity.go create mode 100644 internal/domain/main-entities/cp-mcu-order/base/entity.go create mode 100644 internal/domain/main-entities/cp-mcu-order/dto.go create mode 100644 internal/domain/main-entities/cp-mcu-order/entity.go create mode 100644 internal/domain/main-entities/micro-mcu-order/base/entity.go create mode 100644 internal/domain/main-entities/micro-mcu-order/dto.go create mode 100644 internal/domain/main-entities/micro-mcu-order/entity.go create mode 100644 internal/domain/main-entities/radiology-mcu-order/base/entity.go create mode 100644 internal/domain/main-entities/radiology-mcu-order/dto.go create mode 100644 internal/domain/main-entities/radiology-mcu-order/entity.go diff --git a/internal/domain/main-entities/ap-mcu-order/base/dto.go b/internal/domain/main-entities/ap-mcu-order/base/dto.go new file mode 100644 index 00000000..447bc771 --- /dev/null +++ b/internal/domain/main-entities/ap-mcu-order/base/dto.go @@ -0,0 +1,23 @@ +package apmcuorder + +type CreateDto struct { + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"-"` + Substances string `json:"substances"` + Fictations string `json:"fictations"` + Localization string `json:"localization"` + ClinicalDiagnoses string `json:"clinicalDiagnoses"` + Stadium string `json:"stadium"` + ClinicalNotes string `json:"clinicalNotes"` + CurrentHistory string `json:"currentHistory"` + PastHistory string `json:"pastHistory"` + PrevApMcu string `json:"prevApMcu"` + PrevApMcuNotes string `json:"prevApMcuNotes"` + SupportingExams string `json:"supportingExams"` +} + +type UpdateDto struct { + Id uint64 `json:"id"` + CreateDto +} diff --git a/internal/domain/main-entities/ap-mcu-order/base/entity.go b/internal/domain/main-entities/ap-mcu-order/base/entity.go new file mode 100644 index 00000000..5aa99c20 --- /dev/null +++ b/internal/domain/main-entities/ap-mcu-order/base/entity.go @@ -0,0 +1,23 @@ +package apmcuorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" +) + +type ApMcuOrder struct { + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` + Substances string `json:"substances"` + Fictations string `json:"fictations"` + Localization string `json:"localization"` + ClinicalDiagnoses string `json:"clinicalDiagnoses"` + Stadium string `json:"stadium"` + ClinicalNotes *string `json:"clinicalNotes"` + CurrentHistory string `json:"currentHistory"` + PastHistory string `json:"pastHistory"` + PrevApMcu *string `json:"prevApMcu"` + PrevApMcuNotes *string `json:"prevApMcuNotes"` + SupportingExams *string `json:"supportingExams"` +} diff --git a/internal/domain/main-entities/ap-mcu-order/dto.go b/internal/domain/main-entities/ap-mcu-order/dto.go index 7fcaa1d3..954efad2 100644 --- a/internal/domain/main-entities/ap-mcu-order/dto.go +++ b/internal/domain/main-entities/ap-mcu-order/dto.go @@ -2,22 +2,13 @@ package apmcuorder import ( ecore "simrs-vx/internal/domain/base-entities/core" - emo "simrs-vx/internal/domain/main-entities/mcu-order" + eamob "simrs-vx/internal/domain/main-entities/ap-mcu-order/base" + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" ) type CreateDto struct { - McuOrder_Id string `json:"mcuOrder_id"` - Substances string `json:"substances"` - Fictations string `json:"fictations"` - Localization string `json:"localization"` - ClinicalDiagnoses string `json:"clinicalDiagnoses"` - Stadium string `json:"stadium"` - ClinicalNotes string `json:"clinicalNotes"` - PastHistory string `json:"pastHistory"` - CurrentHistory string `json:"currentHistory"` - PrevApMcu string `json:"prevApMcu"` - PrevApMcuNotes string `json:"prevApMcuNotes"` - SupportingExams string `json:"supportingExams"` + eamob.CreateDto } type ReadListDto struct { @@ -51,25 +42,32 @@ type MetaDto struct { } type ResponseDto struct { - ecore.Main - McuOrder_Id string `json:"mcuOrder_id"` - McuOrder *emo.McuOrder - Substances string `json:"substances"` - Fictations string `json:"fictations"` - Localization string `json:"localization"` - ClinicalDiagnoses string `json:"clinicalDiagnoses"` - Stadium string `json:"stadium"` - ClinicalNotes string `json:"clinicalNotes"` - PastHistory string `json:"pastHistory"` - CurrentHistory string `json:"currentHistory"` - PrevApMcu string `json:"prevApMcu"` - PrevApMcuNotes string `json:"prevApMcuNotes"` - SupportingExams string `json:"supportingExams"` + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Encounter *ee.Encounter + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code"` + Doctor *ed.Doctor + Substances string `json:"substances"` + Fictations string `json:"fictations"` + Localization string `json:"localization"` + ClinicalDiagnoses string `json:"clinicalDiagnoses"` + Stadium string `json:"stadium"` + ClinicalNotes *string `json:"clinicalNotes"` + PastHistory string `json:"pastHistory"` + CurrentHistory string `json:"currentHistory"` + PrevApMcu *string `json:"prevApMcu"` + PrevApMcuNotes *string `json:"prevApMcuNotes"` + SupportingExams *string `json:"supportingExams"` } func (d ApMcuOrder) ToResponse() ResponseDto { resp := ResponseDto{ - McuOrder_Id: d.McuOrder_Id, + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Number: d.Number, + Doctor_Code: d.Doctor_Code, + Doctor: d.Doctor, Substances: d.Substances, Fictations: d.Fictations, Localization: d.Localization, @@ -80,8 +78,9 @@ func (d ApMcuOrder) ToResponse() ResponseDto { CurrentHistory: d.CurrentHistory, PrevApMcu: d.PrevApMcu, PrevApMcuNotes: d.PrevApMcuNotes, + SupportingExams: d.SupportingExams, } - resp.McuOrder = d.McuOrder + resp.BigMain = d.BigMain return resp } diff --git a/internal/domain/main-entities/ap-mcu-order/entity.go b/internal/domain/main-entities/ap-mcu-order/entity.go index f57e7497..703e9ebb 100644 --- a/internal/domain/main-entities/ap-mcu-order/entity.go +++ b/internal/domain/main-entities/ap-mcu-order/entity.go @@ -1,23 +1,13 @@ package apmcuorder import ( - ecore "simrs-vx/internal/domain/base-entities/core" - emo "simrs-vx/internal/domain/main-entities/mcu-order" + eamob "simrs-vx/internal/domain/main-entities/ap-mcu-order/base" + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" ) type ApMcuOrder struct { - ecore.BigMain - McuOrder_Id string `json:"mcuOrder_id" gorm:"unique;size:10"` - McuOrder *emo.McuOrder `json:"mcuOrder,omitempty" gorm:"foreignKey:McuOrder_Id;references:Id"` - Substances string `json:"substances"` - Fictations string `json:"fictations"` - Localization string `json:"localization"` - ClinicalDiagnoses string `json:"clinicalDiagnoses"` - Stadium string `json:"stadium"` - ClinicalNotes string `json:"clinicalNotes"` - PastHistory string `json:"pastHistory"` - CurrentHistory string `json:"currentHistory"` - PrevApMcu string `json:"prevApMcu"` - PrevApMcuNotes string `json:"prevApMcuNotes"` - SupportingExams string `json:"supportingExams"` + eamob.ApMcuOrder + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` } diff --git a/internal/domain/main-entities/cp-mcu-order/base/entity.go b/internal/domain/main-entities/cp-mcu-order/base/entity.go new file mode 100644 index 00000000..883ba0b6 --- /dev/null +++ b/internal/domain/main-entities/cp-mcu-order/base/entity.go @@ -0,0 +1,19 @@ +package cpmcuorder + +import ( + "time" + + ecore "simrs-vx/internal/domain/base-entities/core" + ercl "simrs-vx/internal/domain/references/clinical" +) + +type CpMcuOrder struct { + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` + UrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"urgencyLevel_code" gorm:"not null;size:15"` + OtherNotes *string `json:"otherNotes"` + ExamScheduleDate *time.Time `json:"examinationDate"` + Resume *string `json:"resume"` +} diff --git a/internal/domain/main-entities/cp-mcu-order/dto.go b/internal/domain/main-entities/cp-mcu-order/dto.go new file mode 100644 index 00000000..5cc2e753 --- /dev/null +++ b/internal/domain/main-entities/cp-mcu-order/dto.go @@ -0,0 +1,80 @@ +package cpmcuorder + +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" +) + +type CreateDto struct { + Encounter_Id uint `json:"encounter_id" validate:"required"` + Number uint64 `json:"number"` // SHOULD BE AUTOMATIC WITHOUT SYNC + UrgencyLevel_Code string `json:"urgencyLevel_code" validate:"required"` + OtherNotes string `json:"otherNotes"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Sort string `json:"sort"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Encounter_Id uint `json:"encounter-id"` + Doctor_Code string `json:"doctor-code"` +} + +type ReadDetailDto struct { + Id uint64 `json:"id"` +} + +type UpdateDto struct { + Id uint64 `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint64 `json:"id"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.BigMain + Encounter_Id uint + Encounter *ee.Encounter + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code"` + Doctor *ed.Doctor + UrgencyLevel_Code string `json:"urgencyLevel_code" gorm:"not null;size:15"` + OtherNotes *string `json:"otherNotes"` + Resume *string `json:"resume"` +} + +func (d CpMcuOrder) ToResponse() ResponseDto { + resp := ResponseDto{ + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Number: d.Number, + Doctor_Code: d.Doctor_Code, + Doctor: d.Doctor, + UrgencyLevel_Code: string(d.UrgencyLevel_Code), + OtherNotes: d.OtherNotes, + Resume: d.Resume, + } + resp.BigMain = d.BigMain + return resp +} + +func ToResponseList(data []CpMcuOrder) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/cp-mcu-order/entity.go b/internal/domain/main-entities/cp-mcu-order/entity.go new file mode 100644 index 00000000..92e20ef5 --- /dev/null +++ b/internal/domain/main-entities/cp-mcu-order/entity.go @@ -0,0 +1,13 @@ +package cpmcuorder + +import ( + eamob "simrs-vx/internal/domain/main-entities/cp-mcu-order/base" + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" +) + +type CpMcuOrder struct { + eamob.CpMcuOrder + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` +} diff --git a/internal/domain/main-entities/micro-mcu-order/base/entity.go b/internal/domain/main-entities/micro-mcu-order/base/entity.go new file mode 100644 index 00000000..2250ca20 --- /dev/null +++ b/internal/domain/main-entities/micro-mcu-order/base/entity.go @@ -0,0 +1,16 @@ +package micromcuorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ercl "simrs-vx/internal/domain/references/clinical" +) + +type MicroMcuOrder struct { + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` + Stage_Code ercl.McuOrderStageCode `json:"stage_code" gorm:"not null;size:10"` + AxillaryTemp float64 `json:"axillaryTemp"` + OtherNotes *string `json:"otherNotes"` +} diff --git a/internal/domain/main-entities/micro-mcu-order/dto.go b/internal/domain/main-entities/micro-mcu-order/dto.go new file mode 100644 index 00000000..82f926db --- /dev/null +++ b/internal/domain/main-entities/micro-mcu-order/dto.go @@ -0,0 +1,82 @@ +package micromcuorder + +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" + ercl "simrs-vx/internal/domain/references/clinical" +) + +type CreateDto struct { + Encounter_Id uint `json:"encounter_id" validate:"required"` + Number uint64 `json:"number"` // SHOULD BE AUTOMATIC WITHOUT SYNC + OrderStage_Code string `json:"orderStage_code" gorm:"not null;size:10"` + AxillaryTemp float64 `json:"axillaryTemp"` + OtherNotes string `json:"otherNotes"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Sort string `json:"sort"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Encounter_Id uint `json:"encounter-id"` + Doctor_Code string `json:"doctor-code"` +} + +type ReadDetailDto struct { + Id uint64 `json:"id"` +} + +type UpdateDto struct { + Id uint64 `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint64 `json:"id"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.BigMain + Encounter_Id uint + Encounter *ee.Encounter + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code"` + Doctor *ed.Doctor + Stage_Code ercl.McuOrderStageCode `json:"stage_code" gorm:"not null;size:10"` + AxillaryTemp float64 `json:"axillaryTemp"` + OtherNotes *string `json:"otherNotes"` +} + +func (d MicroMcuOrder) ToResponse() ResponseDto { + resp := ResponseDto{ + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Number: d.Number, + Doctor_Code: d.Doctor_Code, + Doctor: d.Doctor, + Stage_Code: d.Stage_Code, + AxillaryTemp: d.AxillaryTemp, + OtherNotes: d.OtherNotes, + } + resp.BigMain = d.BigMain + return resp +} + +func ToResponseList(data []MicroMcuOrder) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/micro-mcu-order/entity.go b/internal/domain/main-entities/micro-mcu-order/entity.go new file mode 100644 index 00000000..1c645040 --- /dev/null +++ b/internal/domain/main-entities/micro-mcu-order/entity.go @@ -0,0 +1,13 @@ +package micromcuorder + +import ( + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" + eamob "simrs-vx/internal/domain/main-entities/micro-mcu-order/base" +) + +type MicroMcuOrder struct { + eamob.MicroMcuOrder + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` +} diff --git a/internal/domain/main-entities/radiology-mcu-order/base/entity.go b/internal/domain/main-entities/radiology-mcu-order/base/entity.go new file mode 100644 index 00000000..a771e0a7 --- /dev/null +++ b/internal/domain/main-entities/radiology-mcu-order/base/entity.go @@ -0,0 +1,15 @@ +package radiologymcuorder + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" +) + +type RadiologyMcuOrder struct { + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` + ClinicalNotes *string `json:"clinicalNotes"` + OtherNotes *string `json:"otherNotes"` + Resume *string `json:"resume"` +} diff --git a/internal/domain/main-entities/radiology-mcu-order/dto.go b/internal/domain/main-entities/radiology-mcu-order/dto.go new file mode 100644 index 00000000..f24b5668 --- /dev/null +++ b/internal/domain/main-entities/radiology-mcu-order/dto.go @@ -0,0 +1,84 @@ +package radiologymcuorder + +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" + ermoi "simrs-vx/internal/domain/main-entities/radiology-mcu-order-item/base" +) + +type CreateDto struct { + Encounter_Id uint `json:"encounter_id"` + Number *uint64 `json:"number"` // SHOULD BE AUTOMATIC WITHOUT SYNC + Doctor_Code string `json:"-" validate:"required"` + ClinicalNotes string `json:"clinicalNotes"` + OtherNotes string `json:"otherNotes"` + Items []ermoi.SubCreateDto `json:"items" validate:"required"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Sort string `json:"sort"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Encounter_Id uint `json:"encounter-id"` + Doctor_Code string `json:"doctor-code"` +} + +type ReadDetailDto struct { + Id uint64 `json:"id"` +} + +type UpdateDto struct { + Id uint64 `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint64 `json:"id"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.BigMain + Encounter_Id uint `json:"encounter_id"` + Encounter *ee.Encounter + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code"` + Doctor *ed.Doctor + ClinicalNotes *string `json:"clinicalNotes"` + OtherNotes *string `json:"otherNotes"` + Resume *string `json:"resume"` + Items []*ermoi.RadiologyMcuOrderItem +} + +func (d RadiologyMcuOrder) ToResponse() ResponseDto { + resp := ResponseDto{ + Encounter_Id: d.Encounter_Id, + Encounter: d.Encounter, + Number: d.Number, + Doctor_Code: d.Doctor_Code, + Doctor: d.Doctor, + ClinicalNotes: d.ClinicalNotes, + OtherNotes: d.OtherNotes, + Resume: d.Resume, + } + resp.BigMain = d.BigMain + return resp +} + +func ToResponseList(data []RadiologyMcuOrder) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/radiology-mcu-order/entity.go b/internal/domain/main-entities/radiology-mcu-order/entity.go new file mode 100644 index 00000000..2ff3ec20 --- /dev/null +++ b/internal/domain/main-entities/radiology-mcu-order/entity.go @@ -0,0 +1,15 @@ +package radiologymcuorder + +import ( + ed "simrs-vx/internal/domain/main-entities/doctor" + ee "simrs-vx/internal/domain/main-entities/encounter" + ermoi "simrs-vx/internal/domain/main-entities/radiology-mcu-order-item/base" + eamob "simrs-vx/internal/domain/main-entities/radiology-mcu-order/base" +) + +type RadiologyMcuOrder struct { + eamob.RadiologyMcuOrder + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` + Items []*ermoi.RadiologyMcuOrderItem `json:"items" gorm:"foreignKey:RadiologyMcuOrder_Id;references:Id"` +} diff --git a/internal/use-case/main-use-case/ap-mcu-order/helper.go b/internal/use-case/main-use-case/ap-mcu-order/helper.go index 717e6ce6..4b91b7aa 100644 --- a/internal/use-case/main-use-case/ap-mcu-order/helper.go +++ b/internal/use-case/main-use-case/ap-mcu-order/helper.go @@ -17,14 +17,11 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ApMcuOrder) { inputSrc = &inputTemp.CreateDto } - data.McuOrder_Id = inputSrc.McuOrder_Id data.Substances = inputSrc.Substances data.Fictations = inputSrc.Fictations data.Localization = inputSrc.Localization data.ClinicalDiagnoses = inputSrc.ClinicalDiagnoses data.Stadium = inputSrc.Stadium - data.ClinicalNotes = inputSrc.ClinicalNotes data.PastHistory = inputSrc.PastHistory data.CurrentHistory = inputSrc.CurrentHistory - data.PrevApMcu = inputSrc.PrevApMcu } From 24d216ec5653ca00f2b24c502f73bd2707b67484 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Mon, 8 Dec 2025 04:08:01 +0700 Subject: [PATCH 28/45] feat/order-things: separated mcu-order-items --- .../cp-mcu-order-item/base/dto.go | 6 ++ .../cp-mcu-order-item/base/entity.go | 16 ++++ .../main-entities/cp-mcu-order-item/dto.go | 80 +++++++++++++++++++ .../main-entities/cp-mcu-order-item/entity.go | 21 +++++ .../micro-mcu-order-item/base/dto.go | 6 ++ .../micro-mcu-order-item/base/entity.go | 17 ++++ .../main-entities/micro-mcu-order-item/dto.go | 80 +++++++++++++++++++ .../micro-mcu-order-item/entity.go | 17 ++++ .../radiology-mcu-order-item/base/dto.go | 6 ++ .../radiology-mcu-order-item/base/entity.go | 17 ++++ .../radiology-mcu-order-item/dto.go | 80 +++++++++++++++++++ .../radiology-mcu-order-item/entity.go | 17 ++++ .../domain/references/clinical/clinical.go | 4 + 13 files changed, 367 insertions(+) create mode 100644 internal/domain/main-entities/cp-mcu-order-item/base/dto.go create mode 100644 internal/domain/main-entities/cp-mcu-order-item/base/entity.go create mode 100644 internal/domain/main-entities/cp-mcu-order-item/dto.go create mode 100644 internal/domain/main-entities/cp-mcu-order-item/entity.go create mode 100644 internal/domain/main-entities/micro-mcu-order-item/base/dto.go create mode 100644 internal/domain/main-entities/micro-mcu-order-item/base/entity.go create mode 100644 internal/domain/main-entities/micro-mcu-order-item/dto.go create mode 100644 internal/domain/main-entities/micro-mcu-order-item/entity.go create mode 100644 internal/domain/main-entities/radiology-mcu-order-item/base/dto.go create mode 100644 internal/domain/main-entities/radiology-mcu-order-item/base/entity.go create mode 100644 internal/domain/main-entities/radiology-mcu-order-item/dto.go create mode 100644 internal/domain/main-entities/radiology-mcu-order-item/entity.go diff --git a/internal/domain/main-entities/cp-mcu-order-item/base/dto.go b/internal/domain/main-entities/cp-mcu-order-item/base/dto.go new file mode 100644 index 00000000..2510f9a0 --- /dev/null +++ b/internal/domain/main-entities/cp-mcu-order-item/base/dto.go @@ -0,0 +1,6 @@ +package cpmcuorderitem + +type SubCreateDto struct { + McuSrc_Code string `json:"mcuSrc_code" validate:"required"` + Note string `json:"note"` +} diff --git a/internal/domain/main-entities/cp-mcu-order-item/base/entity.go b/internal/domain/main-entities/cp-mcu-order-item/base/entity.go new file mode 100644 index 00000000..49cea380 --- /dev/null +++ b/internal/domain/main-entities/cp-mcu-order-item/base/entity.go @@ -0,0 +1,16 @@ +package cpmcuorderitem + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + + erc "simrs-vx/internal/domain/references/common" +) + +type CpMcuOrderItem struct { + ecore.BigMain // adjust this according to the needs + CpMcuOrder_Id uint64 `json:"cpMcuOrder_id" gorm:"uniqueIndex:idx_order_src"` + McuSrc_Code string `json:"mcuSrc_code" gorm:"uniqueIndex:idx_order_src"` + Note *string `json:"note" gorm:"size:1024"` + Result *string `json:"result"` + Status_Code erc.DataStatusCode `json:"status_code"` +} diff --git a/internal/domain/main-entities/cp-mcu-order-item/dto.go b/internal/domain/main-entities/cp-mcu-order-item/dto.go new file mode 100644 index 00000000..a0979186 --- /dev/null +++ b/internal/domain/main-entities/cp-mcu-order-item/dto.go @@ -0,0 +1,80 @@ +package cpmcuorderitem + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + emro "simrs-vx/internal/domain/main-entities/cp-mcu-order" + ems "simrs-vx/internal/domain/main-entities/mcu-src" + erc "simrs-vx/internal/domain/references/common" + "time" +) + +type CreateDto struct { + CpMcuOrder_Id uint64 `json:"cpMcuOrder_id"` + McuSrc_Code string `json:"mcuSrc_code"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Pagination ecore.Pagination +} + +type FilterDto struct { + CpMcuOrder_Id *uint64 `json:"cp-mcu-order-id"` + McuSrc_Code *string `json:"mcu-src-code"` + Status_Code erc.DataStatusCode `json:"status-code"` +} +type ReadDetailDto struct { + Id uint `json:"id"` +} + +type UpdateDto struct { + Id uint `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint `json:"id"` +} + +type SetScheduleDto struct { + Id uint `json:"id"` + ExaminationDate *time.Time `json:"examinationDate"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.BigMain + CpMcuOrder_Id uint64 `json:"cpMcuOrder_id"` + CpMcuOrder *emro.CpMcuOrder `json:"cpMcuOrder,omitempty"` + McuSrc_Code string `json:"mcuSrc_code"` + McuSrc *ems.McuSrc `json:"mcuSrc,omitempty"` + Result *string `json:"result"` + Status_Code erc.DataStatusCode `json:"status_code"` +} + +func (d CpMcuOrderItem) ToResponse() ResponseDto { + resp := ResponseDto{ + CpMcuOrder_Id: d.CpMcuOrder_Id, + CpMcuOrder: d.CpMcuOrder, + McuSrc_Code: d.McuSrc_Code, + McuSrc: d.McuSrc, + Result: d.Result, + Status_Code: d.Status_Code, + } + resp.BigMain = d.BigMain + return resp +} + +func ToResponseList(data []CpMcuOrderItem) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/cp-mcu-order-item/entity.go b/internal/domain/main-entities/cp-mcu-order-item/entity.go new file mode 100644 index 00000000..65ec70cd --- /dev/null +++ b/internal/domain/main-entities/cp-mcu-order-item/entity.go @@ -0,0 +1,21 @@ +package cpmcuorderitem + +import ( + emo "simrs-vx/internal/domain/main-entities/cp-mcu-order" + emoib "simrs-vx/internal/domain/main-entities/cp-mcu-order-item/base" + + emosi "simrs-vx/internal/domain/main-entities/mcu-order-sub-item/base" + ems "simrs-vx/internal/domain/main-entities/mcu-src" + erc "simrs-vx/internal/domain/references/common" +) + +type CpMcuOrderItem struct { + emoib.CpMcuOrderItem + CpMcuOrder *emo.CpMcuOrder `json:"cpMcuOrder,omitempty" gorm:"foreignKey:McuOrder_Id;references:Id"` + McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Code;references:Code"` + Items []*emosi.McuOrderSubItem `json:"items" gorm:"foreignKey:McuOrderItem_Id;references:Id"` +} + +func (d CpMcuOrderItem) IsCompleted() bool { + return d.Status_Code == erc.DSCDone +} diff --git a/internal/domain/main-entities/micro-mcu-order-item/base/dto.go b/internal/domain/main-entities/micro-mcu-order-item/base/dto.go new file mode 100644 index 00000000..56827131 --- /dev/null +++ b/internal/domain/main-entities/micro-mcu-order-item/base/dto.go @@ -0,0 +1,6 @@ +package micromcuorderitem + +type SubCreateDto struct { + McuSrc_Code string `json:"mcuSrc_code" validate:"required"` + Note string `json:"note"` +} diff --git a/internal/domain/main-entities/micro-mcu-order-item/base/entity.go b/internal/domain/main-entities/micro-mcu-order-item/base/entity.go new file mode 100644 index 00000000..c9d91561 --- /dev/null +++ b/internal/domain/main-entities/micro-mcu-order-item/base/entity.go @@ -0,0 +1,17 @@ +package micromcuorderitem + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ems "simrs-vx/internal/domain/main-entities/mcu-src" + erc "simrs-vx/internal/domain/references/common" +) + +type MicroMcuOrderItem struct { + ecore.BigMain // adjust this according to the needs + MicroMcuOrder_Id uint64 `json:"microMcuOrder_id" gorm:"uniqueIndex:idx_order_src"` + McuSrc_Code string `json:"mcuSrc_code" gorm:"uniqueIndex:idx_order_src"` + McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Code;references:Code"` + Note *string `json:"note" gorm:"size:1024"` + Result *string `json:"result"` + Status_Code erc.DataStatusCode `json:"status_code"` +} diff --git a/internal/domain/main-entities/micro-mcu-order-item/dto.go b/internal/domain/main-entities/micro-mcu-order-item/dto.go new file mode 100644 index 00000000..1d2ceaeb --- /dev/null +++ b/internal/domain/main-entities/micro-mcu-order-item/dto.go @@ -0,0 +1,80 @@ +package micromcuorderitem + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ems "simrs-vx/internal/domain/main-entities/mcu-src" + emro "simrs-vx/internal/domain/main-entities/micro-mcu-order" + erc "simrs-vx/internal/domain/references/common" + "time" +) + +type CreateDto struct { + MicroMcuOrder_Id uint64 `json:"microMcuOrder_id"` + McuSrc_Code string `json:"mcuSrc_code"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Pagination ecore.Pagination +} + +type FilterDto struct { + MicroMcuOrder_Id *uint64 `json:"micro-mcu-order-id"` + McuSrc_Code *string `json:"mcu-src-code"` + Status_Code erc.DataStatusCode `json:"status-code"` +} +type ReadDetailDto struct { + Id uint `json:"id"` +} + +type UpdateDto struct { + Id uint `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint `json:"id"` +} + +type SetScheduleDto struct { + Id uint `json:"id"` + ExaminationDate *time.Time `json:"examinationDate"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.BigMain + MicroMcuOrder_Id uint64 `json:"microMcuOrder_id"` + MicroMcuOrder *emro.MicroMcuOrder `json:"microMcuOrder,omitempty"` + McuSrc_Code string `json:"mcuSrc_code"` + McuSrc *ems.McuSrc `json:"mcuSrc,omitempty"` + Result *string `json:"result"` + Status_Code erc.DataStatusCode `json:"status_code"` +} + +func (d MicroMcuOrderItem) ToResponse() ResponseDto { + resp := ResponseDto{ + MicroMcuOrder_Id: d.MicroMcuOrder_Id, + MicroMcuOrder: d.MicroMcuOrder, + McuSrc_Code: d.McuSrc_Code, + McuSrc: d.McuSrc, + Result: d.Result, + Status_Code: d.Status_Code, + } + resp.BigMain = d.BigMain + return resp +} + +func ToResponseList(data []MicroMcuOrderItem) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/micro-mcu-order-item/entity.go b/internal/domain/main-entities/micro-mcu-order-item/entity.go new file mode 100644 index 00000000..8d818e27 --- /dev/null +++ b/internal/domain/main-entities/micro-mcu-order-item/entity.go @@ -0,0 +1,17 @@ +package micromcuorderitem + +import ( + emo "simrs-vx/internal/domain/main-entities/micro-mcu-order" + emoib "simrs-vx/internal/domain/main-entities/micro-mcu-order-item/base" + + erc "simrs-vx/internal/domain/references/common" +) + +type MicroMcuOrderItem struct { + emoib.MicroMcuOrderItem + MicroMcuOrder *emo.MicroMcuOrder `json:"microMcuOrder,omitempty" gorm:"foreignKey:McuOrder_Id;references:Id"` +} + +func (d MicroMcuOrderItem) IsCompleted() bool { + return d.Status_Code == erc.DSCDone +} diff --git a/internal/domain/main-entities/radiology-mcu-order-item/base/dto.go b/internal/domain/main-entities/radiology-mcu-order-item/base/dto.go new file mode 100644 index 00000000..8ca6d02f --- /dev/null +++ b/internal/domain/main-entities/radiology-mcu-order-item/base/dto.go @@ -0,0 +1,6 @@ +package radiologymcuorderitem + +type SubCreateDto struct { + McuSrc_Code string `json:"mcuSrc_code" validate:"required"` + Note string `json:"note"` +} diff --git a/internal/domain/main-entities/radiology-mcu-order-item/base/entity.go b/internal/domain/main-entities/radiology-mcu-order-item/base/entity.go new file mode 100644 index 00000000..1f3ff5a5 --- /dev/null +++ b/internal/domain/main-entities/radiology-mcu-order-item/base/entity.go @@ -0,0 +1,17 @@ +package radiologymcuorderitem + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ems "simrs-vx/internal/domain/main-entities/mcu-src" + erc "simrs-vx/internal/domain/references/common" +) + +type RadiologyMcuOrderItem struct { + ecore.BigMain // adjust this according to the needs + RadiologyMcuOrder_Id uint64 `json:"radiologyMcuOrder_id" gorm:"uniqueIndex:idx_order_src"` + McuSrc_Code string `json:"mcuSrc_code" gorm:"uniqueIndex:idx_order_src"` + McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Code;references:Code"` + Note *string `json:"note" gorm:"size:1024"` + Result *string `json:"result"` + Status_Code erc.DataStatusCode `json:"status_code"` +} diff --git a/internal/domain/main-entities/radiology-mcu-order-item/dto.go b/internal/domain/main-entities/radiology-mcu-order-item/dto.go new file mode 100644 index 00000000..99c65df3 --- /dev/null +++ b/internal/domain/main-entities/radiology-mcu-order-item/dto.go @@ -0,0 +1,80 @@ +package radiologymcuorderitem + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ems "simrs-vx/internal/domain/main-entities/mcu-src" + emro "simrs-vx/internal/domain/main-entities/radiology-mcu-order" + erc "simrs-vx/internal/domain/references/common" + "time" +) + +type CreateDto struct { + RadiologyMcuOrder_Id uint64 `json:"radiologyMcuOrder_id"` + McuSrc_Code string `json:"mcuSrc_code"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Pagination ecore.Pagination +} + +type FilterDto struct { + RadiologyMcuOrder_Id *uint64 `json:"radiology-mcu-order-id"` + McuSrc_Code *string `json:"mcu-src-code"` + Status_Code erc.DataStatusCode `json:"status-code"` +} +type ReadDetailDto struct { + Id uint `json:"id"` +} + +type UpdateDto struct { + Id uint `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint `json:"id"` +} + +type SetScheduleDto struct { + Id uint `json:"id"` + ExaminationDate *time.Time `json:"examinationDate"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.BigMain + RadiologyMcuOrder_Id uint64 `json:"radiologyMcuOrder_id"` + RadiologyMcuOrder *emro.RadiologyMcuOrder `json:"radiologyMcuOrder,omitempty"` + McuSrc_Code string `json:"mcuSrc_code"` + McuSrc *ems.McuSrc `json:"mcuSrc,omitempty"` + Result *string `json:"result"` + Status_Code erc.DataStatusCode `json:"status_code"` +} + +func (d RadiologyMcuOrderItem) ToResponse() ResponseDto { + resp := ResponseDto{ + RadiologyMcuOrder_Id: d.RadiologyMcuOrder_Id, + RadiologyMcuOrder: d.RadiologyMcuOrder, + McuSrc_Code: d.McuSrc_Code, + McuSrc: d.McuSrc, + Result: d.Result, + Status_Code: d.Status_Code, + } + resp.BigMain = d.BigMain + return resp +} + +func ToResponseList(data []RadiologyMcuOrderItem) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/radiology-mcu-order-item/entity.go b/internal/domain/main-entities/radiology-mcu-order-item/entity.go new file mode 100644 index 00000000..2e1734a3 --- /dev/null +++ b/internal/domain/main-entities/radiology-mcu-order-item/entity.go @@ -0,0 +1,17 @@ +package radiologymcuorderitem + +import ( + emo "simrs-vx/internal/domain/main-entities/radiology-mcu-order" + emoib "simrs-vx/internal/domain/main-entities/radiology-mcu-order-item/base" + + erc "simrs-vx/internal/domain/references/common" +) + +type RadiologyMcuOrderItem struct { + emoib.RadiologyMcuOrderItem + RadiologyMcuOrder *emo.RadiologyMcuOrder `json:"radiologyMcuOrder,omitempty" gorm:"foreignKey:McuOrder_Id;references:Id"` +} + +func (d RadiologyMcuOrderItem) IsCompleted() bool { + return d.Status_Code == erc.DSCDone +} diff --git a/internal/domain/references/clinical/clinical.go b/internal/domain/references/clinical/clinical.go index a9d3fc2b..80c451c7 100644 --- a/internal/domain/references/clinical/clinical.go +++ b/internal/domain/references/clinical/clinical.go @@ -9,6 +9,7 @@ type ( InstructionCode string HeadToToeCode string McuUrgencyLevelCode string + McuOrderStageCode string McuScopeCode string SoapiTypeCode string MedicalActionTypeCode string @@ -125,6 +126,9 @@ const ( MULCPF McuUrgencyLevelCode = "priority-form" // Form Prioritas MULCRT McuUrgencyLevelCode = "routine" // Pemeriksaan Rutin + MOSFirst McuOrderStageCode = "first" // Stage 1 + MOSSecond McuOrderStageCode = "repeat" // Stage 2 + STCEarlyNurse SoapiTypeCode = "early-nursery" // Kajian Awal Keperawatan STCEEarlyMedic SoapiTypeCode = "early-medic" // Kajian Awal Rehab Medis STCEarlyRehab SoapiTypeCode = "early-rehab" // Kajian Awal Rehab Medik From 1036cab53ccd8ea8dcd844e6a4411156b80c36d3 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Mon, 8 Dec 2025 05:13:04 +0700 Subject: [PATCH 29/45] feat/order-things: entity separation finalization --- .../migrations/20251207212015.sql | 99 +++++++++++++++++++ .../migrations/20251207221222.sql | 8 ++ cmd/main-migration/migrations/atlas.sum | 6 +- .../main-entities/ap-mcu-order/base/entity.go | 30 +++--- .../domain/main-entities/ap-mcu-order/dto.go | 3 + .../main-entities/ap-mcu-order/entity.go | 13 +++ .../cp-mcu-order-item/base/entity.go | 3 +- .../main-entities/cp-mcu-order-item/entity.go | 6 +- .../main-entities/cp-mcu-order/base/entity.go | 2 + .../domain/main-entities/cp-mcu-order/dto.go | 6 +- .../main-entities/cp-mcu-order/entity.go | 19 +++- .../micro-mcu-order-item/entity.go | 5 +- .../micro-mcu-order/base/entity.go | 2 + .../main-entities/micro-mcu-order/dto.go | 6 +- .../main-entities/micro-mcu-order/entity.go | 19 +++- .../radiology-mcu-order-item/entity.go | 2 +- .../radiology-mcu-order/base/entity.go | 14 +-- .../main-entities/radiology-mcu-order/dto.go | 10 +- .../radiology-mcu-order/entity.go | 13 +++ internal/interface/migration/main-entities.go | 14 ++- 20 files changed, 239 insertions(+), 41 deletions(-) create mode 100644 cmd/main-migration/migrations/20251207212015.sql create mode 100644 cmd/main-migration/migrations/20251207221222.sql diff --git a/cmd/main-migration/migrations/20251207212015.sql b/cmd/main-migration/migrations/20251207212015.sql new file mode 100644 index 00000000..c551aa8c --- /dev/null +++ b/cmd/main-migration/migrations/20251207212015.sql @@ -0,0 +1,99 @@ +-- Modify "ApMcuOrder" table +ALTER TABLE "public"."ApMcuOrder" DROP COLUMN "McuOrder_Id", ADD COLUMN "Encounter_Id" bigint NULL, ADD COLUMN "Number" bigint NULL, ADD COLUMN "Doctor_Code" character varying(20) NULL, ADD CONSTRAINT "uni_ApMcuOrder_Doctor_Code" UNIQUE ("Doctor_Code"), ADD CONSTRAINT "fk_ApMcuOrder_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_ApMcuOrder_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION; +-- Create "CpMcuOrder" table +CREATE TABLE "public"."CpMcuOrder" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Encounter_Id" bigint NULL, + "Number" bigint NULL, + "Doctor_Code" character varying(20) NULL, + "UrgencyLevel_Code" character varying(15) NOT NULL, + "OtherNotes" text NULL, + "ExamScheduleDate" timestamptz NULL, + "Resume" text NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_CpMcuOrder_Doctor_Code" UNIQUE ("Doctor_Code"), + CONSTRAINT "fk_CpMcuOrder_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_CpMcuOrder_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "CpMcuOrderItem" table +CREATE TABLE "public"."CpMcuOrderItem" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "CpMcuOrder_Id" bigint NULL, + "McuSrc_Code" character varying(20) NULL, + "Note" character varying(1024) NULL, + "Result" text NULL, + "Status_Code" text NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_CpMcuOrderItem_CpMcuOrder" FOREIGN KEY ("CpMcuOrder_Id") REFERENCES "public"."CpMcuOrder" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_CpMcuOrderItem_McuSrc" FOREIGN KEY ("McuSrc_Code") REFERENCES "public"."McuSrc" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "MicroMcuOrder" table +CREATE TABLE "public"."MicroMcuOrder" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Encounter_Id" bigint NULL, + "Number" bigint NULL, + "Doctor_Code" character varying(20) NULL, + "Stage_Code" character varying(10) NOT NULL, + "AxillaryTemp" numeric NULL, + "OtherNotes" text NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_MicroMcuOrder_Doctor_Code" UNIQUE ("Doctor_Code"), + CONSTRAINT "fk_MicroMcuOrder_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_MicroMcuOrder_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "MicroMcuOrderItem" table +CREATE TABLE "public"."MicroMcuOrderItem" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "MicroMcuOrder_Id" bigint NULL, + "McuSrc_Code" character varying(20) NULL, + "Note" character varying(1024) NULL, + "Result" text NULL, + "Status_Code" text NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_MicroMcuOrderItem_McuSrc" FOREIGN KEY ("McuSrc_Code") REFERENCES "public"."McuSrc" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_MicroMcuOrderItem_MicroMcuOrder" FOREIGN KEY ("MicroMcuOrder_Id") REFERENCES "public"."MicroMcuOrder" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "RadiologyMcuOrder" table +CREATE TABLE "public"."RadiologyMcuOrder" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Encounter_Id" bigint NULL, + "Number" bigint NULL, + "Doctor_Code" character varying(20) NULL, + "ClinicalNotes" text NULL, + "OtherNotes" text NULL, + "Resume" text NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "uni_RadiologyMcuOrder_Doctor_Code" UNIQUE ("Doctor_Code"), + CONSTRAINT "fk_RadiologyMcuOrder_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_RadiologyMcuOrder_Encounter" FOREIGN KEY ("Encounter_Id") REFERENCES "public"."Encounter" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); +-- Create "RadiologyMcuOrderItem" table +CREATE TABLE "public"."RadiologyMcuOrderItem" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "RadiologyMcuOrder_Id" bigint NULL, + "McuSrc_Code" character varying(20) NULL, + "Note" character varying(1024) NULL, + "Result" text NULL, + "Status_Code" text NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_RadiologyMcuOrderItem_McuSrc" FOREIGN KEY ("McuSrc_Code") REFERENCES "public"."McuSrc" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_RadiologyMcuOrderItem_RadiologyMcuOrder" FOREIGN KEY ("RadiologyMcuOrder_Id") REFERENCES "public"."RadiologyMcuOrder" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION +); diff --git a/cmd/main-migration/migrations/20251207221222.sql b/cmd/main-migration/migrations/20251207221222.sql new file mode 100644 index 00000000..3c806128 --- /dev/null +++ b/cmd/main-migration/migrations/20251207221222.sql @@ -0,0 +1,8 @@ +-- Modify "ApMcuOrder" table +ALTER TABLE "public"."ApMcuOrder" ADD COLUMN "Status_Code" character varying(10) NOT NULL; +-- Modify "CpMcuOrder" table +ALTER TABLE "public"."CpMcuOrder" ADD COLUMN "Status_Code" character varying(10) NOT NULL; +-- Modify "MicroMcuOrder" table +ALTER TABLE "public"."MicroMcuOrder" ADD COLUMN "Status_Code" character varying(10) NOT NULL; +-- Modify "RadiologyMcuOrder" table +ALTER TABLE "public"."RadiologyMcuOrder" ADD COLUMN "Status_Code" character varying(10) NOT NULL; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 632e0ddb..c1ede307 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:1BOh7w/6hkhDj1PptjXT4tLOgmRtIIofGm3ERJ+EfyM= +h1:o4jOACV/QY64oiqrbnZvGei0J65px0JBwAXakl8h+Oc= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -145,4 +145,6 @@ h1:1BOh7w/6hkhDj1PptjXT4tLOgmRtIIofGm3ERJ+EfyM= 20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM= 20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= 20251203205052.sql h1:nk0VK2Uv4bHE3SBfHo/aevVZxtHzr7zAzvmMU8TCCtk= -20251207020537.sql h1:UmtHxX1vZi/BiKxHPOOP7fALRZ3RoRGSGmUma7ttp8w= +20251207020537.sql h1:uqqIQaBoZGoOXVQKkalNXwF2awcA+rhjNVevWEzIIok= +20251207212015.sql h1:muRdWqRKfJQFMfezj2B4n0E6bbjIz1GrzHEyhoxy2mk= +20251207221222.sql h1:+mU/25n3hQLRU6MK8B+Uwzl9YBRezX3xWDtIKnweN78= diff --git a/internal/domain/main-entities/ap-mcu-order/base/entity.go b/internal/domain/main-entities/ap-mcu-order/base/entity.go index 5aa99c20..d098fcfd 100644 --- a/internal/domain/main-entities/ap-mcu-order/base/entity.go +++ b/internal/domain/main-entities/ap-mcu-order/base/entity.go @@ -2,22 +2,24 @@ package apmcuorder import ( ecore "simrs-vx/internal/domain/base-entities/core" + erc "simrs-vx/internal/domain/references/common" ) type ApMcuOrder struct { ecore.BigMain - Encounter_Id uint `json:"encounter_id"` - Number uint64 `json:"number"` - Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` - Substances string `json:"substances"` - Fictations string `json:"fictations"` - Localization string `json:"localization"` - ClinicalDiagnoses string `json:"clinicalDiagnoses"` - Stadium string `json:"stadium"` - ClinicalNotes *string `json:"clinicalNotes"` - CurrentHistory string `json:"currentHistory"` - PastHistory string `json:"pastHistory"` - PrevApMcu *string `json:"prevApMcu"` - PrevApMcuNotes *string `json:"prevApMcuNotes"` - SupportingExams *string `json:"supportingExams"` + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` + Substances string `json:"substances"` + Fictations string `json:"fictations"` + Localization string `json:"localization"` + ClinicalDiagnoses string `json:"clinicalDiagnoses"` + Stadium string `json:"stadium"` + ClinicalNotes *string `json:"clinicalNotes"` + CurrentHistory string `json:"currentHistory"` + PastHistory string `json:"pastHistory"` + PrevApMcu *string `json:"prevApMcu"` + PrevApMcuNotes *string `json:"prevApMcuNotes"` + SupportingExams *string `json:"supportingExams"` + Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"` } diff --git a/internal/domain/main-entities/ap-mcu-order/dto.go b/internal/domain/main-entities/ap-mcu-order/dto.go index 954efad2..80b0b447 100644 --- a/internal/domain/main-entities/ap-mcu-order/dto.go +++ b/internal/domain/main-entities/ap-mcu-order/dto.go @@ -1,6 +1,8 @@ package apmcuorder import ( + la "simrs-vx/internal/lib/auth" + ecore "simrs-vx/internal/domain/base-entities/core" eamob "simrs-vx/internal/domain/main-entities/ap-mcu-order/base" ed "simrs-vx/internal/domain/main-entities/doctor" @@ -9,6 +11,7 @@ import ( type CreateDto struct { eamob.CreateDto + la.AuthInfo } type ReadListDto struct { diff --git a/internal/domain/main-entities/ap-mcu-order/entity.go b/internal/domain/main-entities/ap-mcu-order/entity.go index 703e9ebb..361d0948 100644 --- a/internal/domain/main-entities/ap-mcu-order/entity.go +++ b/internal/domain/main-entities/ap-mcu-order/entity.go @@ -4,6 +4,7 @@ import ( eamob "simrs-vx/internal/domain/main-entities/ap-mcu-order/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 ApMcuOrder struct { @@ -11,3 +12,15 @@ type ApMcuOrder struct { Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` } + +func (d ApMcuOrder) IsNotNew() bool { + return d.Status_Code != erc.DSCNew +} + +func (d ApMcuOrder) IsCompleted() bool { + return d.Status_Code == erc.DSCDone +} + +func (d ApMcuOrder) IsSameDoctor(doctor_code *string) bool { + return d.Doctor_Code == *doctor_code +} diff --git a/internal/domain/main-entities/cp-mcu-order-item/base/entity.go b/internal/domain/main-entities/cp-mcu-order-item/base/entity.go index 49cea380..5abb8494 100644 --- a/internal/domain/main-entities/cp-mcu-order-item/base/entity.go +++ b/internal/domain/main-entities/cp-mcu-order-item/base/entity.go @@ -2,7 +2,7 @@ package cpmcuorderitem import ( ecore "simrs-vx/internal/domain/base-entities/core" - + ems "simrs-vx/internal/domain/main-entities/mcu-src" erc "simrs-vx/internal/domain/references/common" ) @@ -10,6 +10,7 @@ type CpMcuOrderItem struct { ecore.BigMain // adjust this according to the needs CpMcuOrder_Id uint64 `json:"cpMcuOrder_id" gorm:"uniqueIndex:idx_order_src"` McuSrc_Code string `json:"mcuSrc_code" gorm:"uniqueIndex:idx_order_src"` + McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Code;references:Code"` Note *string `json:"note" gorm:"size:1024"` Result *string `json:"result"` Status_Code erc.DataStatusCode `json:"status_code"` diff --git a/internal/domain/main-entities/cp-mcu-order-item/entity.go b/internal/domain/main-entities/cp-mcu-order-item/entity.go index 65ec70cd..5858ab58 100644 --- a/internal/domain/main-entities/cp-mcu-order-item/entity.go +++ b/internal/domain/main-entities/cp-mcu-order-item/entity.go @@ -4,16 +4,12 @@ import ( emo "simrs-vx/internal/domain/main-entities/cp-mcu-order" emoib "simrs-vx/internal/domain/main-entities/cp-mcu-order-item/base" - emosi "simrs-vx/internal/domain/main-entities/mcu-order-sub-item/base" - ems "simrs-vx/internal/domain/main-entities/mcu-src" erc "simrs-vx/internal/domain/references/common" ) type CpMcuOrderItem struct { emoib.CpMcuOrderItem - CpMcuOrder *emo.CpMcuOrder `json:"cpMcuOrder,omitempty" gorm:"foreignKey:McuOrder_Id;references:Id"` - McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Code;references:Code"` - Items []*emosi.McuOrderSubItem `json:"items" gorm:"foreignKey:McuOrderItem_Id;references:Id"` + CpMcuOrder *emo.CpMcuOrder `json:"cpMcuOrder,omitempty" gorm:"foreignKey:CpMcuOrder_Id;references:Id"` } func (d CpMcuOrderItem) IsCompleted() bool { diff --git a/internal/domain/main-entities/cp-mcu-order/base/entity.go b/internal/domain/main-entities/cp-mcu-order/base/entity.go index 883ba0b6..e9531e22 100644 --- a/internal/domain/main-entities/cp-mcu-order/base/entity.go +++ b/internal/domain/main-entities/cp-mcu-order/base/entity.go @@ -5,6 +5,7 @@ import ( ecore "simrs-vx/internal/domain/base-entities/core" ercl "simrs-vx/internal/domain/references/clinical" + erc "simrs-vx/internal/domain/references/common" ) type CpMcuOrder struct { @@ -16,4 +17,5 @@ type CpMcuOrder struct { OtherNotes *string `json:"otherNotes"` ExamScheduleDate *time.Time `json:"examinationDate"` Resume *string `json:"resume"` + Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"` } diff --git a/internal/domain/main-entities/cp-mcu-order/dto.go b/internal/domain/main-entities/cp-mcu-order/dto.go index 5cc2e753..afccfb20 100644 --- a/internal/domain/main-entities/cp-mcu-order/dto.go +++ b/internal/domain/main-entities/cp-mcu-order/dto.go @@ -1,6 +1,8 @@ package cpmcuorder import ( + la "simrs-vx/internal/lib/auth" + ecore "simrs-vx/internal/domain/base-entities/core" ed "simrs-vx/internal/domain/main-entities/doctor" ee "simrs-vx/internal/domain/main-entities/encounter" @@ -11,6 +13,7 @@ type CreateDto struct { Number uint64 `json:"number"` // SHOULD BE AUTOMATIC WITHOUT SYNC UrgencyLevel_Code string `json:"urgencyLevel_code" validate:"required"` OtherNotes string `json:"otherNotes"` + la.AuthInfo } type ReadListDto struct { @@ -26,7 +29,8 @@ type FilterDto struct { } type ReadDetailDto struct { - Id uint64 `json:"id"` + Id uint64 `json:"id"` + Includes string `json:"includes"` } type UpdateDto struct { diff --git a/internal/domain/main-entities/cp-mcu-order/entity.go b/internal/domain/main-entities/cp-mcu-order/entity.go index 92e20ef5..08a3d927 100644 --- a/internal/domain/main-entities/cp-mcu-order/entity.go +++ b/internal/domain/main-entities/cp-mcu-order/entity.go @@ -1,13 +1,28 @@ package cpmcuorder import ( + ecmoi "simrs-vx/internal/domain/main-entities/cp-mcu-order-item/base" eamob "simrs-vx/internal/domain/main-entities/cp-mcu-order/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 CpMcuOrder struct { eamob.CpMcuOrder - Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` - Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` + Items []*ecmoi.CpMcuOrderItem `json:"items" gorm:"foreignKey:CpMcuOrder_Id;references:Id"` +} + +func (d CpMcuOrder) IsNotNew() bool { + return d.Status_Code != erc.DSCNew +} + +func (d CpMcuOrder) IsCompleted() bool { + return d.Status_Code == erc.DSCDone +} + +func (d CpMcuOrder) IsSameDoctor(doctor_code *string) bool { + return d.Doctor_Code == *doctor_code } diff --git a/internal/domain/main-entities/micro-mcu-order-item/entity.go b/internal/domain/main-entities/micro-mcu-order-item/entity.go index 8d818e27..64d701f7 100644 --- a/internal/domain/main-entities/micro-mcu-order-item/entity.go +++ b/internal/domain/main-entities/micro-mcu-order-item/entity.go @@ -1,15 +1,16 @@ package micromcuorderitem import ( + ems "simrs-vx/internal/domain/main-entities/mcu-src" emo "simrs-vx/internal/domain/main-entities/micro-mcu-order" emoib "simrs-vx/internal/domain/main-entities/micro-mcu-order-item/base" - erc "simrs-vx/internal/domain/references/common" ) type MicroMcuOrderItem struct { emoib.MicroMcuOrderItem - MicroMcuOrder *emo.MicroMcuOrder `json:"microMcuOrder,omitempty" gorm:"foreignKey:McuOrder_Id;references:Id"` + MicroMcuOrder *emo.MicroMcuOrder `json:"microMcuOrder,omitempty" gorm:"foreignKey:MicroMcuOrder_Id;references:Id"` + McuSrc *ems.McuSrc `json:"mcuSrc,omitempty" gorm:"foreignKey:McuSrc_Code;references:Code"` } func (d MicroMcuOrderItem) IsCompleted() bool { diff --git a/internal/domain/main-entities/micro-mcu-order/base/entity.go b/internal/domain/main-entities/micro-mcu-order/base/entity.go index 2250ca20..3e611d81 100644 --- a/internal/domain/main-entities/micro-mcu-order/base/entity.go +++ b/internal/domain/main-entities/micro-mcu-order/base/entity.go @@ -3,6 +3,7 @@ package micromcuorder import ( ecore "simrs-vx/internal/domain/base-entities/core" ercl "simrs-vx/internal/domain/references/clinical" + erc "simrs-vx/internal/domain/references/common" ) type MicroMcuOrder struct { @@ -13,4 +14,5 @@ type MicroMcuOrder struct { Stage_Code ercl.McuOrderStageCode `json:"stage_code" gorm:"not null;size:10"` AxillaryTemp float64 `json:"axillaryTemp"` OtherNotes *string `json:"otherNotes"` + Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"` } diff --git a/internal/domain/main-entities/micro-mcu-order/dto.go b/internal/domain/main-entities/micro-mcu-order/dto.go index 82f926db..008f219f 100644 --- a/internal/domain/main-entities/micro-mcu-order/dto.go +++ b/internal/domain/main-entities/micro-mcu-order/dto.go @@ -1,6 +1,8 @@ package micromcuorder import ( + la "simrs-vx/internal/lib/auth" + ecore "simrs-vx/internal/domain/base-entities/core" ed "simrs-vx/internal/domain/main-entities/doctor" ee "simrs-vx/internal/domain/main-entities/encounter" @@ -13,6 +15,7 @@ type CreateDto struct { OrderStage_Code string `json:"orderStage_code" gorm:"not null;size:10"` AxillaryTemp float64 `json:"axillaryTemp"` OtherNotes string `json:"otherNotes"` + la.AuthInfo } type ReadListDto struct { @@ -28,7 +31,8 @@ type FilterDto struct { } type ReadDetailDto struct { - Id uint64 `json:"id"` + Id uint64 `json:"id"` + Includes string `json:"includes"` } type UpdateDto struct { diff --git a/internal/domain/main-entities/micro-mcu-order/entity.go b/internal/domain/main-entities/micro-mcu-order/entity.go index 1c645040..57550c84 100644 --- a/internal/domain/main-entities/micro-mcu-order/entity.go +++ b/internal/domain/main-entities/micro-mcu-order/entity.go @@ -3,11 +3,26 @@ package micromcuorder import ( ed "simrs-vx/internal/domain/main-entities/doctor" ee "simrs-vx/internal/domain/main-entities/encounter" + emmoi "simrs-vx/internal/domain/main-entities/micro-mcu-order-item/base" eamob "simrs-vx/internal/domain/main-entities/micro-mcu-order/base" + erc "simrs-vx/internal/domain/references/common" ) type MicroMcuOrder struct { eamob.MicroMcuOrder - Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` - Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` + Items []*emmoi.MicroMcuOrderItem `json:"items" gorm:"foreignKey:MicroMcuOrder_Id;references:Id"` +} + +func (d MicroMcuOrder) IsNotNew() bool { + return d.Status_Code != erc.DSCNew +} + +func (d MicroMcuOrder) IsCompleted() bool { + return d.Status_Code == erc.DSCDone +} + +func (d MicroMcuOrder) IsSameDoctor(doctor_code *string) bool { + return d.Doctor_Code == *doctor_code } diff --git a/internal/domain/main-entities/radiology-mcu-order-item/entity.go b/internal/domain/main-entities/radiology-mcu-order-item/entity.go index 2e1734a3..da20a56a 100644 --- a/internal/domain/main-entities/radiology-mcu-order-item/entity.go +++ b/internal/domain/main-entities/radiology-mcu-order-item/entity.go @@ -9,7 +9,7 @@ import ( type RadiologyMcuOrderItem struct { emoib.RadiologyMcuOrderItem - RadiologyMcuOrder *emo.RadiologyMcuOrder `json:"radiologyMcuOrder,omitempty" gorm:"foreignKey:McuOrder_Id;references:Id"` + RadiologyMcuOrder *emo.RadiologyMcuOrder `json:"radiologyMcuOrder,omitempty" gorm:"foreignKey:RadiologyMcuOrder_Id;references:Id"` } func (d RadiologyMcuOrderItem) IsCompleted() bool { diff --git a/internal/domain/main-entities/radiology-mcu-order/base/entity.go b/internal/domain/main-entities/radiology-mcu-order/base/entity.go index a771e0a7..6871e689 100644 --- a/internal/domain/main-entities/radiology-mcu-order/base/entity.go +++ b/internal/domain/main-entities/radiology-mcu-order/base/entity.go @@ -2,14 +2,16 @@ package radiologymcuorder import ( ecore "simrs-vx/internal/domain/base-entities/core" + erc "simrs-vx/internal/domain/references/common" ) type RadiologyMcuOrder struct { ecore.BigMain - Encounter_Id uint `json:"encounter_id"` - Number uint64 `json:"number"` - Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` - ClinicalNotes *string `json:"clinicalNotes"` - OtherNotes *string `json:"otherNotes"` - Resume *string `json:"resume"` + Encounter_Id uint `json:"encounter_id"` + Number uint64 `json:"number"` + Doctor_Code string `json:"doctor_code" gorm:"unique;size:20"` + ClinicalNotes *string `json:"clinicalNotes"` + OtherNotes *string `json:"otherNotes"` + Resume *string `json:"resume"` + Status_Code erc.DataStatusCode `json:"status_code" gorm:"not null;size:10"` } diff --git a/internal/domain/main-entities/radiology-mcu-order/dto.go b/internal/domain/main-entities/radiology-mcu-order/dto.go index f24b5668..4250b4b0 100644 --- a/internal/domain/main-entities/radiology-mcu-order/dto.go +++ b/internal/domain/main-entities/radiology-mcu-order/dto.go @@ -1,6 +1,8 @@ package radiologymcuorder import ( + la "simrs-vx/internal/lib/auth" + ecore "simrs-vx/internal/domain/base-entities/core" ed "simrs-vx/internal/domain/main-entities/doctor" ee "simrs-vx/internal/domain/main-entities/encounter" @@ -11,9 +13,10 @@ type CreateDto struct { Encounter_Id uint `json:"encounter_id"` Number *uint64 `json:"number"` // SHOULD BE AUTOMATIC WITHOUT SYNC Doctor_Code string `json:"-" validate:"required"` - ClinicalNotes string `json:"clinicalNotes"` - OtherNotes string `json:"otherNotes"` + ClinicalNotes *string `json:"clinicalNotes"` + OtherNotes *string `json:"otherNotes"` Items []ermoi.SubCreateDto `json:"items" validate:"required"` + la.AuthInfo } type ReadListDto struct { @@ -29,7 +32,8 @@ type FilterDto struct { } type ReadDetailDto struct { - Id uint64 `json:"id"` + Id uint64 `json:"id"` + Includes string `json:"includes"` } type UpdateDto struct { diff --git a/internal/domain/main-entities/radiology-mcu-order/entity.go b/internal/domain/main-entities/radiology-mcu-order/entity.go index 2ff3ec20..1ef8882d 100644 --- a/internal/domain/main-entities/radiology-mcu-order/entity.go +++ b/internal/domain/main-entities/radiology-mcu-order/entity.go @@ -5,6 +5,7 @@ import ( ee "simrs-vx/internal/domain/main-entities/encounter" ermoi "simrs-vx/internal/domain/main-entities/radiology-mcu-order-item/base" eamob "simrs-vx/internal/domain/main-entities/radiology-mcu-order/base" + erc "simrs-vx/internal/domain/references/common" ) type RadiologyMcuOrder struct { @@ -13,3 +14,15 @@ type RadiologyMcuOrder struct { Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"` Items []*ermoi.RadiologyMcuOrderItem `json:"items" gorm:"foreignKey:RadiologyMcuOrder_Id;references:Id"` } + +func (d RadiologyMcuOrder) IsNotNew() bool { + return d.Status_Code != erc.DSCNew +} + +func (d RadiologyMcuOrder) IsCompleted() bool { + return d.Status_Code == erc.DSCDone +} + +func (d RadiologyMcuOrder) IsSameDoctor(doctor_code *string) bool { + return d.Doctor_Code == *doctor_code +} diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 9767b21b..d4f596b1 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -16,6 +16,8 @@ import ( consultation "simrs-vx/internal/domain/main-entities/consultation" controlletter "simrs-vx/internal/domain/main-entities/control-letter" counter "simrs-vx/internal/domain/main-entities/counter" + cpmcuorder "simrs-vx/internal/domain/main-entities/cp-mcu-order" + cpmcuorderitem "simrs-vx/internal/domain/main-entities/cp-mcu-order-item" deathcause "simrs-vx/internal/domain/main-entities/death-cause" device "simrs-vx/internal/domain/main-entities/device" deviceorder "simrs-vx/internal/domain/main-entities/device-order" @@ -68,6 +70,8 @@ import ( medicinemethod "simrs-vx/internal/domain/main-entities/medicine-method" medicinemix "simrs-vx/internal/domain/main-entities/medicine-mix" medicinemixitem "simrs-vx/internal/domain/main-entities/medicine-mix-item" + micromcuorder "simrs-vx/internal/domain/main-entities/micro-mcu-order" + micromcuorderitem "simrs-vx/internal/domain/main-entities/micro-mcu-order-item" midwife "simrs-vx/internal/domain/main-entities/midwife" nurse "simrs-vx/internal/domain/main-entities/nurse" nutritionist "simrs-vx/internal/domain/main-entities/nutritionist" @@ -88,6 +92,8 @@ import ( procedureroomorderitem "simrs-vx/internal/domain/main-entities/procedure-room-order-item" proceduresrc "simrs-vx/internal/domain/main-entities/procedure-src" province "simrs-vx/internal/domain/main-entities/province" + radiologymcuorder "simrs-vx/internal/domain/main-entities/radiology-mcu-order" + radiologymcuorderitem "simrs-vx/internal/domain/main-entities/radiology-mcu-order-item" regency "simrs-vx/internal/domain/main-entities/regency" rehab "simrs-vx/internal/domain/main-entities/rehab" responsibledoctorhist "simrs-vx/internal/domain/main-entities/responsible-doctor-hist" @@ -122,7 +128,6 @@ import ( func getMainEntities() []any { return []any{ &authpartner.AuthPartner{}, - &apmcuorder.ApMcuOrder{}, &user.User{}, &userfes.UserFes{}, &division.Division{}, @@ -202,6 +207,13 @@ func getMainEntities() []any { &mcuorderitem.McuOrderItem{}, &mcusubsrc.McuSubSrc{}, &mcuordersubitem.McuOrderSubItem{}, + &apmcuorder.ApMcuOrder{}, + &radiologymcuorder.RadiologyMcuOrder{}, + &radiologymcuorderitem.RadiologyMcuOrderItem{}, + &cpmcuorder.CpMcuOrder{}, + &cpmcuorderitem.CpMcuOrderItem{}, + µmcuorder.MicroMcuOrder{}, + µmcuorderitem.MicroMcuOrderItem{}, &antibioticsrccategory.AntibioticSrcCategory{}, &antibioticinuse.AntibioticInUse{}, &consultation.Consultation{}, From 2cc7af845da640d67b82d6803167372792fbb5d5 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Mon, 8 Dec 2025 15:15:25 +0700 Subject: [PATCH 30/45] feat (patient): add patient employee checker --- internal/lib/auth/tycovar.go | 4 ++++ .../use-case/main-use-case/patient/case.go | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/internal/lib/auth/tycovar.go b/internal/lib/auth/tycovar.go index c673eb04..c746b795 100644 --- a/internal/lib/auth/tycovar.go +++ b/internal/lib/auth/tycovar.go @@ -103,3 +103,7 @@ func (a AuthInfo) IsNurseIntern() bool { func (a AuthInfo) HasEmployeePosition() bool { return a.Employee_Position_Code != nil } + +func (a AuthInfo) IsReg() bool { + return a.Employee_Position_Code != nil && *a.Employee_Position_Code == string(ero.EPCReg) +} diff --git a/internal/use-case/main-use-case/patient/case.go b/internal/use-case/main-use-case/patient/case.go index 24aa4394..a53072fe 100644 --- a/internal/use-case/main-use-case/patient/case.go +++ b/internal/use-case/main-use-case/patient/case.go @@ -50,6 +50,16 @@ func Create(input e.CreateDto) (*d.Data, error) { return nil, pl.SetLogError(&event, input) } + if !input.AuthInfo.IsReg() { + event.Status = "failed" + event.ErrInfo = pl.ErrorInfo{ + Code: "auth-forbidden", + Detail: "user role is not allowed to create patient, only 'reg' position is allowed", + Raw: errors.New("authentication failed"), + } + return nil, pl.SetLogError(&event, input) + } + input.RegisteredBy_User_Name = &input.AuthInfo.User_Name err := dg.I.Transaction(func(tx *gorm.DB) error { @@ -256,6 +266,16 @@ func Update(input e.UpdateDto) (*d.Data, error) { pl.SetLogInfo(&event, input, "started", "update") mwRunner := newMiddlewareRunner(&event) + if !input.AuthInfo.IsReg() { + event.Status = "failed" + event.ErrInfo = pl.ErrorInfo{ + Code: "auth-forbidden", + Detail: "user role is not allowed to create patient, only 'reg' position is allowed", + Raw: errors.New("authentication failed"), + } + return nil, pl.SetLogError(&event, input) + } + err = dg.I.Transaction(func(tx *gorm.DB) error { pl.SetLogInfo(&event, rdDto, "started", "DBReadDetail") if data, err = ReadDetailData(rdDto, &event, tx); err != nil { From 9b4b6949df5d35b0aec3a4754ba9cd3760f74696 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Mon, 8 Dec 2025 16:02:40 +0700 Subject: [PATCH 31/45] feat (patient): add guard for reg and sys --- internal/lib/auth/tycovar.go | 4 ++++ internal/use-case/main-use-case/patient/case.go | 15 ++------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/internal/lib/auth/tycovar.go b/internal/lib/auth/tycovar.go index c746b795..a958fa6a 100644 --- a/internal/lib/auth/tycovar.go +++ b/internal/lib/auth/tycovar.go @@ -107,3 +107,7 @@ func (a AuthInfo) HasEmployeePosition() bool { func (a AuthInfo) IsReg() bool { return a.Employee_Position_Code != nil && *a.Employee_Position_Code == string(ero.EPCReg) } + +func (a AuthInfo) IsSys() bool { + return a.User_ContractPosition_Code == string(ero.CSCSys) +} diff --git a/internal/use-case/main-use-case/patient/case.go b/internal/use-case/main-use-case/patient/case.go index a53072fe..f82d114d 100644 --- a/internal/use-case/main-use-case/patient/case.go +++ b/internal/use-case/main-use-case/patient/case.go @@ -39,18 +39,7 @@ func Create(input e.CreateDto) (*d.Data, error) { pl.SetLogInfo(&event, input, "started", "create") mwRunner := newMiddlewareRunner(&event) - // check if user has employee position - if !input.AuthInfo.HasEmployeePosition() { - event.Status = "failed" - event.ErrInfo = pl.ErrorInfo{ - Code: "auth-forbidden", - Detail: "user has no employee position", - Raw: errors.New("authentication failed"), - } - return nil, pl.SetLogError(&event, input) - } - - if !input.AuthInfo.IsReg() { + if !input.AuthInfo.IsReg() || !input.AuthInfo.IsSys() { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ Code: "auth-forbidden", @@ -266,7 +255,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { pl.SetLogInfo(&event, input, "started", "update") mwRunner := newMiddlewareRunner(&event) - if !input.AuthInfo.IsReg() { + if !input.AuthInfo.IsReg() || !input.AuthInfo.IsSys() { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ Code: "auth-forbidden", From 5782b86e22f7a3414422d7676b14e41d0d8ed81c Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 8 Dec 2025 16:04:08 +0700 Subject: [PATCH 32/45] migration from server --- cmd/main-migration/migrations/atlas.sum | 148 ++++++++++++------------ 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index c1ede307..9a5298f1 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:o4jOACV/QY64oiqrbnZvGei0J65px0JBwAXakl8h+Oc= +h1:iGd5sCHeyT0TBFNtV83Ge6PW5BjRp8rpw+tgFigOC4Q= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -75,76 +75,76 @@ h1:o4jOACV/QY64oiqrbnZvGei0J65px0JBwAXakl8h+Oc= 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:FInLaEFQByESEwFJKuKnuUSTKmcDpi3ZXaxkKwz2+D8= -20251117005942.sql h1:wD3BWrUSmo1HlW16V3lkaBkJvbAZ0fNk77te7J9NhOc= -20251117075427.sql h1:TqU9VKZa3I8YNXUGQWY3WVBYN+1FvyyaKy0hB1jgAho= -20251118074929.sql h1:p1KsWqCuR1JXA/jVO5BmOhCcaQ8clT7t0YRszAhPFbg= -20251119063438.sql h1:NVGM0X/LHD37EaPl8SNzkNiZDJ7AB1QR+LLwLh6WRdg= -20251119065730.sql h1:U5lzk1WvMB0bw3kwckou7jkEt4bwdYItwHr2Vxqe7w4= -20251119072302.sql h1:qCuI2WMEMF/XNbjV+RXPjBnuCKLu1Fia+mR9HiLWBIs= -20251119072450.sql h1:Xg+bTwqGyKPNFEQhJylvpz1wifdfmDJvcAq6vmNf0Ng= -20251120005512.sql h1:Ek6qpacAI/qVuTYxKno+uJyzn7s5z9pf3t7VA8gTzm4= -20251120074415.sql h1:NNUeJVA03EeBHJhHqPXEZoDv/PnC6yK1/cRhmukyaJo= -20251121033803.sql h1:/vfvFX/3pzSCIHnSbMUT9EMBDykOpVkvyfeTEle9Vas= -20251124071457.sql h1:qg2dhCL9YwD13xnfJ175lW/p6MGfzFKaBqd908FByRc= -20251125125303.sql h1:4JSFv1Pmhbe9tqpLXgO63OwYnGsalStgUXKVWPyc1YE= -20251126064057.sql h1:vAdhz5Nn/gGJy0UKZAEldeXv8HpHtJU/t8ygDVIbTsU= -20251201081333.sql h1:PoC8ADRdwDuohDTB74yW/DaB42igdYa4B6humbrEJBk= -20251201104439.sql h1:tpqdrOf9d2aGwZshqm62nG6SXnfVaO/g6A7z0efPS14= -20251201113804.sql h1:kIEmVoETJXBkab2Q+b3y/pP84eF8W2BdQ47amHCnc+c= -20251201113858.sql h1:KLXKZO5XTQPoEU0YLHE8Fhg9WPKpSN3wNgYPJ+RGFcg= -20251201114751.sql h1:HM17diiPknfSHAmP+kJGP6GzToaPU9/NT+KQBpf3Jq0= -20251201114913.sql h1:gqucFgHFFLA6n/Rdz486cZH5xkaJuwefESLJMJLDue8= -20251202030445.sql h1:QWBVfTepT7DaXP5E0BYoxNM0JwKIQ2qIMXzI4kbz/qE= -20251202044430.sql h1:4QZH9lz0GrQ9rzP1AJ+hJgGalNpp+8FCRckNK7xaTbU= -20251202064000.sql h1:/EN7sT1ol/91qW1aXWrzX+Mc3XOC/7f/LtfA0JRHpbg= -20251202130629.sql h1:9mvalqfhqGCdkcJepJDzHprU2xb0i5sYys1Htf62ioo= -20251202160848.sql h1:Kd2/TziKSMezrt4XgbjQcYvY/Lo9rX0qw7/Lz0/oyKk= -20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM= -20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= -20251203205052.sql h1:nk0VK2Uv4bHE3SBfHo/aevVZxtHzr7zAzvmMU8TCCtk= -20251207020537.sql h1:uqqIQaBoZGoOXVQKkalNXwF2awcA+rhjNVevWEzIIok= -20251207212015.sql h1:muRdWqRKfJQFMfezj2B4n0E6bbjIz1GrzHEyhoxy2mk= -20251207221222.sql h1:+mU/25n3hQLRU6MK8B+Uwzl9YBRezX3xWDtIKnweN78= +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= +20251117005942.sql h1:0XoJKca8IOaB9QKFVF/qPY7jKcIgh6m/LODQuE06SAs= +20251117075427.sql h1:LhY2urosfoSu1/vkHmgsNP4JA4DuWBs9gL59yMqcF8M= +20251118074929.sql h1:3RWBD6BziQVw6WSfthgoVuhTELHER9NrIuZm4hY/F1A= +20251119063438.sql h1:EVTG3ZrHjCmM95YPASZTRPiwHrG6e33A2vO4hLSAaBQ= +20251119065730.sql h1:s98wnZOCW6NbnwDS3H53XIQ60u6B9bDwBLNvy5+Rn64= +20251119072302.sql h1:ZL+VHekLYqgNtOFKlj02WHrAk11dtTxQkmyTKE8IOzY= +20251119072450.sql h1:SiJy2vpSvoPFw4J1SW7HjGSJzrqR62NsjRYAeabV+kc= +20251120005512.sql h1:hJUaWXYJ3HiSquBTw8OKhymjA4O43ehAMGfiOY8W87Q= +20251120074415.sql h1:dNmcqZHqfZwi/wtYvO/pSFgImN2scXL0p/7g0+HLp0s= +20251121033803.sql h1:onlddYGo+tQdGaEdJPqdsx3sncGnwEvqMSCksF6vjjI= +20251124071457.sql h1:ikQLIXFikUbkUd55uJBmEvqLGEC9t0db+Om4TQsWP7M= +20251125125303.sql h1:OLKbNPO36AHtIDursW9AeBvf60sahQKC1iOjHmpx0MA= +20251126064057.sql h1:6al3PTWbw/WGiBcrRrVWppOMLtG+eRaH/qSLbnmh1kQ= +20251201081333.sql h1:dD+jcisoUYnxRYWdtVcnxbDeYjUW12/R/qarYQr+utg= +20251201104439.sql h1:h4tz5uetbCKeOI3agSVmAeh6jUfECYy0LhQ7HooYhzg= +20251201113804.sql h1:DdUzqfLdy4AUpVSRFDrIJXntGmtKgZrtvv8MAT4mMxs= +20251201113858.sql h1:XSpicm4aWjrfeY5EYIiw8Ios9v7BGfzZJxpW/57Qwqs= +20251201114751.sql h1:qx+ShdHLacVFcRwwGrW1zMKFHOjMGdnusk7CEfyV8ig= +20251201114913.sql h1:6l/m2/6fmTIjFmKio0QmB8oTwBDCHTIkbuYTODQ7Gwk= +20251202030445.sql h1:5+6ss5KdN6pll8Qtf0RGGyy/BURNO3dBgIBJOzDb624= +20251202044430.sql h1:nJtlQDGj7ZJtJ07NYcF41JCn9ck50GyDPoitTOe8P/s= +20251202064000.sql h1:yzSMOPZrpvQf+u6CxD6LwNySNH9Ip1u70UEf2vWI5w4= +20251202130629.sql h1:u79EiiYq5irxCcjlOHQcACnCKS05XPDDsL4TzLGrNQA= +20251202160848.sql h1:Aq5rVLbrL4vvNnmfk82V22GTteWVTSq9vk2SYzi3EBo= +20251202180207.sql h1:J0Orufzpi+tNhd5+9eLvonKhYc/WMceVHO1WDVRrHAM= +20251202231005.sql h1:DBunbxmAfPYiO5mHspc4dyTTVFoKrHkZSwk/Ieu5oFA= +20251203205052.sql h1:67NoN6JhDfChBA13dmErBSRDiC1gdVBb2F+8SMzpm4U= +20251207020537.sql h1:SIaioWMbg5W1qJDwoh2r7aGnUTIXs67ZhGEe0XyXVB4= +20251207212015.sql h1:RfXFRdynp6vk5KWFzF2nZc2yFpH9BKP9gqBxuAG/G/Q= +20251207221222.sql h1:6DS9hzcfN3+52WShFeI4f9Gqxd4LCQg1Otn5cRipIWU= From 569fb22080b4ac3a9f0118041ebe29079972a963 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Mon, 8 Dec 2025 16:06:14 +0700 Subject: [PATCH 33/45] fix (patient): fix condition --- internal/use-case/main-use-case/patient/case.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/use-case/main-use-case/patient/case.go b/internal/use-case/main-use-case/patient/case.go index f82d114d..da636263 100644 --- a/internal/use-case/main-use-case/patient/case.go +++ b/internal/use-case/main-use-case/patient/case.go @@ -39,7 +39,7 @@ func Create(input e.CreateDto) (*d.Data, error) { pl.SetLogInfo(&event, input, "started", "create") mwRunner := newMiddlewareRunner(&event) - if !input.AuthInfo.IsReg() || !input.AuthInfo.IsSys() { + if !input.AuthInfo.IsReg() && !input.AuthInfo.IsSys() { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ Code: "auth-forbidden", @@ -255,7 +255,7 @@ func Update(input e.UpdateDto) (*d.Data, error) { pl.SetLogInfo(&event, input, "started", "update") mwRunner := newMiddlewareRunner(&event) - if !input.AuthInfo.IsReg() || !input.AuthInfo.IsSys() { + if !input.AuthInfo.IsReg() && !input.AuthInfo.IsSys() { event.Status = "failed" event.ErrInfo = pl.ErrorInfo{ Code: "auth-forbidden", From f22968e21782642ca57cd3ef43034aa7d1b6ccc0 Mon Sep 17 00:00:00 2001 From: vanilia Date: Tue, 9 Dec 2025 09:28:15 +0700 Subject: [PATCH 34/45] adjust chemo-plan --- cmd/main-migration/migrations/20251209022744.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 5 +++-- internal/domain/main-entities/chemo-plan/entity.go | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 cmd/main-migration/migrations/20251209022744.sql diff --git a/cmd/main-migration/migrations/20251209022744.sql b/cmd/main-migration/migrations/20251209022744.sql new file mode 100644 index 00000000..a8a18481 --- /dev/null +++ b/cmd/main-migration/migrations/20251209022744.sql @@ -0,0 +1,2 @@ +-- Modify "ChemoPlan" table +ALTER TABLE "public"."ChemoPlan" ADD COLUMN "Encounter_Id" bigint NULL, ADD CONSTRAINT "fk_ChemoPlan_Encounter" 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 09459c64..ccfdf7cb 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:BsDkwn1AzNdKnOPVb6PkonyiXM7nTdVcjRdw62i/NlQ= +h1:k6jcZ+rtVsLhO+oTPZVfHgwAInujs4C4iXNJlSwwkA8= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -147,4 +147,5 @@ h1:BsDkwn1AzNdKnOPVb6PkonyiXM7nTdVcjRdw62i/NlQ= 20251205073858.sql h1:Ep03jQ9hJAJILDJfKVcmi3Z6fqmTHSq9gKQtwf070PE= 20251205211957.sql h1:zRHcvLY+nfLdUyMcfpgI8vYQcPzJUWbfjkc4cK0QGHU= 20251205214433.sql h1:tgHB/fNy9XwAOWIqNI6GCqGXeJgSuZs2aHiCEj3BHZA= -20251205221124.sql h1:VthPlq3XcQOYz5VsFivb4Wof8jCAG36fAaerKmM4/OA= +20251205221124.sql h1:wl56/lrR14r7LrScEKwTQ3cNE45wh/0Ye3UEM7gfVNg= +20251209022744.sql h1:FayWjHhPEZEIq7KWIYaV/2/cmKB7A4PR3aspXXd6Brs= diff --git a/internal/domain/main-entities/chemo-plan/entity.go b/internal/domain/main-entities/chemo-plan/entity.go index 1f3f3ca5..2dc5a363 100644 --- a/internal/domain/main-entities/chemo-plan/entity.go +++ b/internal/domain/main-entities/chemo-plan/entity.go @@ -1,6 +1,7 @@ package chemo_plan import ( + ee "simrs-vx/internal/domain/main-entities/encounter" "time" ecore "simrs-vx/internal/domain/base-entities/core" @@ -18,4 +19,6 @@ type ChemoPlan struct { RealizationDate *time.Time `json:"realizationDate"` Notes *string `json:"notes"` Status ere.StatusProtocolChemo `json:"status"` + Encounter_Id *uint `json:"encounter_id"` + Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` } From 4a22609243dfa7bc5851b4195bf26712fc2aee67 Mon Sep 17 00:00:00 2001 From: vanilia Date: Tue, 9 Dec 2025 09:32:36 +0700 Subject: [PATCH 35/45] update migration --- cmd/main-migration/migrations/atlas.sum | 158 ++++++++++++------------ 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 491fb502..1df5b79f 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:k6jcZ+rtVsLhO+oTPZVfHgwAInujs4C4iXNJlSwwkA8= +h1:bj3Rl8P0sdSmP7kBLfjyB30pIf3iUdthY5EBkfOtk7A= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -75,81 +75,81 @@ h1:k6jcZ+rtVsLhO+oTPZVfHgwAInujs4C4iXNJlSwwkA8= 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= -20251117005942.sql h1:0XoJKca8IOaB9QKFVF/qPY7jKcIgh6m/LODQuE06SAs= -20251117075427.sql h1:LhY2urosfoSu1/vkHmgsNP4JA4DuWBs9gL59yMqcF8M= -20251118074929.sql h1:3RWBD6BziQVw6WSfthgoVuhTELHER9NrIuZm4hY/F1A= -20251119063438.sql h1:EVTG3ZrHjCmM95YPASZTRPiwHrG6e33A2vO4hLSAaBQ= -20251119065730.sql h1:s98wnZOCW6NbnwDS3H53XIQ60u6B9bDwBLNvy5+Rn64= -20251119072302.sql h1:ZL+VHekLYqgNtOFKlj02WHrAk11dtTxQkmyTKE8IOzY= -20251119072450.sql h1:SiJy2vpSvoPFw4J1SW7HjGSJzrqR62NsjRYAeabV+kc= -20251120005512.sql h1:hJUaWXYJ3HiSquBTw8OKhymjA4O43ehAMGfiOY8W87Q= -20251120074415.sql h1:dNmcqZHqfZwi/wtYvO/pSFgImN2scXL0p/7g0+HLp0s= -20251121033803.sql h1:onlddYGo+tQdGaEdJPqdsx3sncGnwEvqMSCksF6vjjI= -20251124071457.sql h1:ikQLIXFikUbkUd55uJBmEvqLGEC9t0db+Om4TQsWP7M= -20251125125303.sql h1:OLKbNPO36AHtIDursW9AeBvf60sahQKC1iOjHmpx0MA= -20251126064057.sql h1:6al3PTWbw/WGiBcrRrVWppOMLtG+eRaH/qSLbnmh1kQ= -20251201081333.sql h1:dD+jcisoUYnxRYWdtVcnxbDeYjUW12/R/qarYQr+utg= -20251201104439.sql h1:h4tz5uetbCKeOI3agSVmAeh6jUfECYy0LhQ7HooYhzg= -20251201113804.sql h1:DdUzqfLdy4AUpVSRFDrIJXntGmtKgZrtvv8MAT4mMxs= -20251201113858.sql h1:XSpicm4aWjrfeY5EYIiw8Ios9v7BGfzZJxpW/57Qwqs= -20251201114751.sql h1:qx+ShdHLacVFcRwwGrW1zMKFHOjMGdnusk7CEfyV8ig= -20251201114913.sql h1:6l/m2/6fmTIjFmKio0QmB8oTwBDCHTIkbuYTODQ7Gwk= -20251202030445.sql h1:5+6ss5KdN6pll8Qtf0RGGyy/BURNO3dBgIBJOzDb624= -20251202044430.sql h1:nJtlQDGj7ZJtJ07NYcF41JCn9ck50GyDPoitTOe8P/s= -20251202064000.sql h1:yzSMOPZrpvQf+u6CxD6LwNySNH9Ip1u70UEf2vWI5w4= -20251202130629.sql h1:u79EiiYq5irxCcjlOHQcACnCKS05XPDDsL4TzLGrNQA= -20251202160848.sql h1:Aq5rVLbrL4vvNnmfk82V22GTteWVTSq9vk2SYzi3EBo= -20251202180207.sql h1:J0Orufzpi+tNhd5+9eLvonKhYc/WMceVHO1WDVRrHAM= -20251202231005.sql h1:DBunbxmAfPYiO5mHspc4dyTTVFoKrHkZSwk/Ieu5oFA= -20251203205052.sql h1:67NoN6JhDfChBA13dmErBSRDiC1gdVBb2F+8SMzpm4U= -20251207020537.sql h1:SIaioWMbg5W1qJDwoh2r7aGnUTIXs67ZhGEe0XyXVB4= -20251207212015.sql h1:RfXFRdynp6vk5KWFzF2nZc2yFpH9BKP9gqBxuAG/G/Q= -20251207221222.sql h1:6DS9hzcfN3+52WShFeI4f9Gqxd4LCQg1Otn5cRipIWU= -20251205073858.sql h1:Ep03jQ9hJAJILDJfKVcmi3Z6fqmTHSq9gKQtwf070PE= -20251205211957.sql h1:zRHcvLY+nfLdUyMcfpgI8vYQcPzJUWbfjkc4cK0QGHU= -20251205214433.sql h1:tgHB/fNy9XwAOWIqNI6GCqGXeJgSuZs2aHiCEj3BHZA= -20251205221124.sql h1:wl56/lrR14r7LrScEKwTQ3cNE45wh/0Ye3UEM7gfVNg= -20251209022744.sql h1:FayWjHhPEZEIq7KWIYaV/2/cmKB7A4PR3aspXXd6Brs= \ No newline at end of file +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:wD3BWrUSmo1HlW16V3lkaBkJvbAZ0fNk77te7J9NhOc= +20251117075427.sql h1:TqU9VKZa3I8YNXUGQWY3WVBYN+1FvyyaKy0hB1jgAho= +20251118074929.sql h1:p1KsWqCuR1JXA/jVO5BmOhCcaQ8clT7t0YRszAhPFbg= +20251119063438.sql h1:NVGM0X/LHD37EaPl8SNzkNiZDJ7AB1QR+LLwLh6WRdg= +20251119065730.sql h1:U5lzk1WvMB0bw3kwckou7jkEt4bwdYItwHr2Vxqe7w4= +20251119072302.sql h1:qCuI2WMEMF/XNbjV+RXPjBnuCKLu1Fia+mR9HiLWBIs= +20251119072450.sql h1:Xg+bTwqGyKPNFEQhJylvpz1wifdfmDJvcAq6vmNf0Ng= +20251120005512.sql h1:Ek6qpacAI/qVuTYxKno+uJyzn7s5z9pf3t7VA8gTzm4= +20251120074415.sql h1:NNUeJVA03EeBHJhHqPXEZoDv/PnC6yK1/cRhmukyaJo= +20251121033803.sql h1:/vfvFX/3pzSCIHnSbMUT9EMBDykOpVkvyfeTEle9Vas= +20251124071457.sql h1:qg2dhCL9YwD13xnfJ175lW/p6MGfzFKaBqd908FByRc= +20251125125303.sql h1:4JSFv1Pmhbe9tqpLXgO63OwYnGsalStgUXKVWPyc1YE= +20251126064057.sql h1:vAdhz5Nn/gGJy0UKZAEldeXv8HpHtJU/t8ygDVIbTsU= +20251201081333.sql h1:PoC8ADRdwDuohDTB74yW/DaB42igdYa4B6humbrEJBk= +20251201104439.sql h1:tpqdrOf9d2aGwZshqm62nG6SXnfVaO/g6A7z0efPS14= +20251201113804.sql h1:kIEmVoETJXBkab2Q+b3y/pP84eF8W2BdQ47amHCnc+c= +20251201113858.sql h1:KLXKZO5XTQPoEU0YLHE8Fhg9WPKpSN3wNgYPJ+RGFcg= +20251201114751.sql h1:HM17diiPknfSHAmP+kJGP6GzToaPU9/NT+KQBpf3Jq0= +20251201114913.sql h1:gqucFgHFFLA6n/Rdz486cZH5xkaJuwefESLJMJLDue8= +20251202030445.sql h1:QWBVfTepT7DaXP5E0BYoxNM0JwKIQ2qIMXzI4kbz/qE= +20251202044430.sql h1:4QZH9lz0GrQ9rzP1AJ+hJgGalNpp+8FCRckNK7xaTbU= +20251202064000.sql h1:/EN7sT1ol/91qW1aXWrzX+Mc3XOC/7f/LtfA0JRHpbg= +20251202130629.sql h1:9mvalqfhqGCdkcJepJDzHprU2xb0i5sYys1Htf62ioo= +20251202160848.sql h1:Kd2/TziKSMezrt4XgbjQcYvY/Lo9rX0qw7/Lz0/oyKk= +20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM= +20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= +20251203205052.sql h1:nk0VK2Uv4bHE3SBfHo/aevVZxtHzr7zAzvmMU8TCCtk= +20251205073858.sql h1:46qqXnArgJmzGE/WO7v7Ev8Jh7BudDiGbdANexq/5Dk= +20251205211957.sql h1:3fvtZ/mBWsTIXllXMFOuCLJsp4MivVP56dunehlU0yo= +20251205214433.sql h1:rn3++FEfX7ntcJcOmCEuOMnr27TZqH0KMGRppzFwFTc= +20251205221124.sql h1:CRruUvGZqlVDBmbQSVEl4wFm+uq30AurMMDI6sb8jxg= +20251207020537.sql h1:JspoBMoP1Yk854vtNniepvATINUpODQ9idKiMkNL0OU= +20251207212015.sql h1:pEH0+QnQ5WXNizxcToLk+8XYaAb6q6WJ1/MJViRVtNQ= +20251207221222.sql h1:gpl3V4/3AGqO3WLCpWW2GAtwuhpmNuBqXMiP61wVHX0= +20251209022744.sql h1:0WXCKpMDFAe/aVnosMGmCYp3mw+FIu+foX14sYmq750= From 3e4a49f2169ae8ffe33a40df85901244ff0375b9 Mon Sep 17 00:00:00 2001 From: vanilia Date: Tue, 9 Dec 2025 10:02:01 +0700 Subject: [PATCH 36/45] update migration --- cmd/main-migration/migrations/20251209025908.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 3 ++- internal/domain/main-entities/chemo/entity.go | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 cmd/main-migration/migrations/20251209025908.sql diff --git a/cmd/main-migration/migrations/20251209025908.sql b/cmd/main-migration/migrations/20251209025908.sql new file mode 100644 index 00000000..5a8522d7 --- /dev/null +++ b/cmd/main-migration/migrations/20251209025908.sql @@ -0,0 +1,2 @@ +-- Modify "Chemo" table +ALTER TABLE "public"."Chemo" ADD COLUMN "Class_Code" text NULL; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 1df5b79f..ac03c936 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:bj3Rl8P0sdSmP7kBLfjyB30pIf3iUdthY5EBkfOtk7A= +h1:SSn9Za93bvbyBNVuGwpy9R/E/+1hm802NevovuLsplc= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -153,3 +153,4 @@ h1:bj3Rl8P0sdSmP7kBLfjyB30pIf3iUdthY5EBkfOtk7A= 20251207212015.sql h1:pEH0+QnQ5WXNizxcToLk+8XYaAb6q6WJ1/MJViRVtNQ= 20251207221222.sql h1:gpl3V4/3AGqO3WLCpWW2GAtwuhpmNuBqXMiP61wVHX0= 20251209022744.sql h1:0WXCKpMDFAe/aVnosMGmCYp3mw+FIu+foX14sYmq750= +20251209025908.sql h1:MgO50it1hj7Jj8BD5yKjW8OLC9qS3FFEdelqIsLT1v8= diff --git a/internal/domain/main-entities/chemo/entity.go b/internal/domain/main-entities/chemo/entity.go index 682333ed..cc828835 100644 --- a/internal/domain/main-entities/chemo/entity.go +++ b/internal/domain/main-entities/chemo/entity.go @@ -1,6 +1,7 @@ package chemo import ( + ere "simrs-vx/internal/domain/references/encounter" "time" ecore "simrs-vx/internal/domain/base-entities/core" @@ -27,4 +28,5 @@ type Chemo struct { Doctor_Code *string `json:"doctor_code"` Doctor *ed.Doctor `json:"doctor" gorm:"foreignKey:Doctor_Code;references:Code"` NextChemoDate *time.Time `json:"nextChemoDate"` + Class_Code ere.ChemoClassCode `json:"class_code"` } From 9ba0d06ce38bdc2e7edb17e63ad49ce947d15a2e Mon Sep 17 00:00:00 2001 From: vanilia Date: Tue, 9 Dec 2025 10:05:16 +0700 Subject: [PATCH 37/45] update migration --- internal/use-case/main-use-case/chemo-protocol/helper.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/internal/use-case/main-use-case/chemo-protocol/helper.go b/internal/use-case/main-use-case/chemo-protocol/helper.go index 885e6fbb..66a63dcc 100644 --- a/internal/use-case/main-use-case/chemo-protocol/helper.go +++ b/internal/use-case/main-use-case/chemo-protocol/helper.go @@ -17,12 +17,9 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.ChemoProtocol) { inputSrc = &inputTemp.CreateDto } - data.Encounter_Id = inputSrc.Encounter_Id data.Patient_Weight = inputSrc.Patient_Weight data.Patient_Height = inputSrc.Patient_Height data.Diagnoses = inputSrc.Diagnoses - data.Duration = inputSrc.Duration - data.DurationUnit_Code = inputSrc.DurationUnit_Code data.StartDate = inputSrc.StartDate data.EndDate = inputSrc.EndDate } From 6811ef062390f2e1f11550b7251744ec98d5d4e1 Mon Sep 17 00:00:00 2001 From: ari Date: Tue, 9 Dec 2025 10:13:50 +0700 Subject: [PATCH 38/45] update --- cmd/main-migration/migrations/20251209030538.sql | 2 ++ internal/domain/main-entities/procedure-report/entity.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 cmd/main-migration/migrations/20251209030538.sql diff --git a/cmd/main-migration/migrations/20251209030538.sql b/cmd/main-migration/migrations/20251209030538.sql new file mode 100644 index 00000000..4f0ad77f --- /dev/null +++ b/cmd/main-migration/migrations/20251209030538.sql @@ -0,0 +1,2 @@ +-- Modify "ProcedureReport" table +ALTER TABLE "public"."ProcedureReport" ALTER COLUMN "Nurse_Name" TYPE text; diff --git a/internal/domain/main-entities/procedure-report/entity.go b/internal/domain/main-entities/procedure-report/entity.go index 4a8a7032..cf084bd4 100644 --- a/internal/domain/main-entities/procedure-report/entity.go +++ b/internal/domain/main-entities/procedure-report/entity.go @@ -18,7 +18,7 @@ type ProcedureReport struct { Assistant_Name string `json:"assistant_name"` Instrumentor_Name string `json:"instrumentor_name"` Diagnose *string `json:"diagnose" gorm:"size:1024"` - Nurse_Name string `json:"nurse_name" gorm:"size:10"` + Nurse_Name string `json:"nurse_name"` Anesthesia_Doctor_Code *string `json:"anesthesia_doctor_code" gorm:"size:10"` Anesthesia_Doctor *ed.Doctor `json:"anesthesia,omitempty" gorm:"foreignKey:Anesthesia_Doctor_Code;references:Code"` Anesthesia_Nurse_Name *string `json:"anesthesia_nurse_name"` From e68b5fe01983c5934245424aeeef988fceaf72c7 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Tue, 9 Dec 2025 10:24:20 +0700 Subject: [PATCH 39/45] fix (patient): missing authinfo on update --- internal/interface/main-handler/patient/handler.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/interface/main-handler/patient/handler.go b/internal/interface/main-handler/patient/handler.go index 41fca562..9fb981fc 100644 --- a/internal/interface/main-handler/patient/handler.go +++ b/internal/interface/main-handler/patient/handler.go @@ -59,11 +59,17 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { return } + authInfo, err := pa.GetAuthInfo(r) + if err != nil { + rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil) + } + dto := e.UpdateDto{} if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res { return } dto.Id = uint(id) + dto.AuthInfo = *authInfo res, err := u.Update(dto) rw.DataResponse(w, res, err) } From 3856246488106c4b1e49a2f1d8b98200b8e4b09f Mon Sep 17 00:00:00 2001 From: vanilia Date: Tue, 9 Dec 2025 12:18:13 +0700 Subject: [PATCH 40/45] add reasons in plan --- cmd/main-migration/migrations/20251209051742.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 7 ++++--- internal/domain/main-entities/chemo-plan/dto.go | 1 + internal/domain/main-entities/chemo-plan/entity.go | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 cmd/main-migration/migrations/20251209051742.sql diff --git a/cmd/main-migration/migrations/20251209051742.sql b/cmd/main-migration/migrations/20251209051742.sql new file mode 100644 index 00000000..3bfa7734 --- /dev/null +++ b/cmd/main-migration/migrations/20251209051742.sql @@ -0,0 +1,2 @@ +-- Modify "ChemoPlan" table +ALTER TABLE "public"."ChemoPlan" ADD COLUMN "Reasons" text NULL; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index ac03c936..73ea425b 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:SSn9Za93bvbyBNVuGwpy9R/E/+1hm802NevovuLsplc= +h1:qwmr55vd65DmAFMwH9uQ5sPXIoKGuFngxaRfnlonWvQ= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -152,5 +152,6 @@ h1:SSn9Za93bvbyBNVuGwpy9R/E/+1hm802NevovuLsplc= 20251207020537.sql h1:JspoBMoP1Yk854vtNniepvATINUpODQ9idKiMkNL0OU= 20251207212015.sql h1:pEH0+QnQ5WXNizxcToLk+8XYaAb6q6WJ1/MJViRVtNQ= 20251207221222.sql h1:gpl3V4/3AGqO3WLCpWW2GAtwuhpmNuBqXMiP61wVHX0= -20251209022744.sql h1:0WXCKpMDFAe/aVnosMGmCYp3mw+FIu+foX14sYmq750= -20251209025908.sql h1:MgO50it1hj7Jj8BD5yKjW8OLC9qS3FFEdelqIsLT1v8= +20251209022744.sql h1:r0JbZyReQdcbpjPsWxhKQBIOH9SSZGB1fNySqjbvZpU= +20251209025908.sql h1:UwyF/B49kyahd2U1Pa+2TjJCj/PszQ3HBHqAzMZnQYc= +20251209051742.sql h1:m/k1ul9S4CjuHstP48Fb+58RnUV3jttAB7lvg9Tbp+o= diff --git a/internal/domain/main-entities/chemo-plan/dto.go b/internal/domain/main-entities/chemo-plan/dto.go index ffd9803f..b2c05a61 100644 --- a/internal/domain/main-entities/chemo-plan/dto.go +++ b/internal/domain/main-entities/chemo-plan/dto.go @@ -61,6 +61,7 @@ type ResponseDto struct { RealizationDate *time.Time `json:"realizationDate"` Notes *string `json:"notes"` Status ere.StatusProtocolChemo `json:"status"` + Reasons *string `json:"reasons"` } func (d ChemoPlan) ToResponse() ResponseDto { diff --git a/internal/domain/main-entities/chemo-plan/entity.go b/internal/domain/main-entities/chemo-plan/entity.go index 2dc5a363..1fef099e 100644 --- a/internal/domain/main-entities/chemo-plan/entity.go +++ b/internal/domain/main-entities/chemo-plan/entity.go @@ -21,4 +21,5 @@ type ChemoPlan struct { Status ere.StatusProtocolChemo `json:"status"` Encounter_Id *uint `json:"encounter_id"` Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"` + Reasons *string `json:"reasons"` // json } From 7ef090bd17ef2c1cb09f572efcb2e86c07155e21 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Tue, 9 Dec 2025 12:50:24 +0700 Subject: [PATCH 41/45] update atlas, remove unnecessary code --- cmd/main-migration/migrations/atlas.sum | 14 ++++++++------ internal/interface/main-handler/patient/handler.go | 5 ----- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index ac03c936..d81f6ccb 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:SSn9Za93bvbyBNVuGwpy9R/E/+1hm802NevovuLsplc= +h1:1Uh0B/nQPbiGKWcusDCZ9KUDAIGODzb8qSNiz7+yqrU= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -149,8 +149,10 @@ h1:SSn9Za93bvbyBNVuGwpy9R/E/+1hm802NevovuLsplc= 20251205211957.sql h1:3fvtZ/mBWsTIXllXMFOuCLJsp4MivVP56dunehlU0yo= 20251205214433.sql h1:rn3++FEfX7ntcJcOmCEuOMnr27TZqH0KMGRppzFwFTc= 20251205221124.sql h1:CRruUvGZqlVDBmbQSVEl4wFm+uq30AurMMDI6sb8jxg= -20251207020537.sql h1:JspoBMoP1Yk854vtNniepvATINUpODQ9idKiMkNL0OU= -20251207212015.sql h1:pEH0+QnQ5WXNizxcToLk+8XYaAb6q6WJ1/MJViRVtNQ= -20251207221222.sql h1:gpl3V4/3AGqO3WLCpWW2GAtwuhpmNuBqXMiP61wVHX0= -20251209022744.sql h1:0WXCKpMDFAe/aVnosMGmCYp3mw+FIu+foX14sYmq750= -20251209025908.sql h1:MgO50it1hj7Jj8BD5yKjW8OLC9qS3FFEdelqIsLT1v8= +20251206021053.sql h1:bpuEocu4lOhZ7oLuxd//22dzjfNgU2iaWEqSD1mVwoU= +20251207020537.sql h1:m6uh4NHVF3EKNTVMqOmuBSDFD9oCQk5mAwo05fT46G4= +20251207212015.sql h1:UPelYGTeUR6rm8mU8dfNzgRDEDun0UQ4tkgsaDljn30= +20251207221222.sql h1:bTfUCvCf2UPh+BA2IY2PHQafb9DwY9nhH5FRuMEHy+0= +20251209022744.sql h1:y5/PAiZH/fYCpDJpkQdNRJwWICHH2iNIwM1V+S1P6KA= +20251209025908.sql h1:p3kZA8kyEj+mQZSrdY3k2K1NojQzFJh/MlZJ0Oy6t/k= +20251209030538.sql h1:zltV6/Fu2zJW0/lVBl7MdnWuJcqNTUIRcqYYZ8Fi1wo= diff --git a/internal/interface/main-handler/patient/handler.go b/internal/interface/main-handler/patient/handler.go index ce1c6c52..dc6c3ff5 100644 --- a/internal/interface/main-handler/patient/handler.go +++ b/internal/interface/main-handler/patient/handler.go @@ -69,11 +69,6 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { return } - authInfo, err := pa.GetAuthInfo(r) - if err != nil { - rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil) - } - dto.Id = uint(id) dto.AuthInfo = *authInfo res, err := u.Update(dto) From e3869ea5e996f6dbe866dff16fc348cd3dec5938 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 9 Dec 2025 12:52:30 +0700 Subject: [PATCH 42/45] migration from server --- cmd/main-migration/migrations/atlas.sum | 164 ++++++++++++------------ 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index d81f6ccb..cc3978f3 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:1Uh0B/nQPbiGKWcusDCZ9KUDAIGODzb8qSNiz7+yqrU= +h1:rEaAvMVRfUZCdhjipT3pYEoprBT8VTGN1C6p59FvR3Y= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -75,84 +75,84 @@ h1:1Uh0B/nQPbiGKWcusDCZ9KUDAIGODzb8qSNiz7+yqrU= 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:FInLaEFQByESEwFJKuKnuUSTKmcDpi3ZXaxkKwz2+D8= -20251117005942.sql h1:wD3BWrUSmo1HlW16V3lkaBkJvbAZ0fNk77te7J9NhOc= -20251117075427.sql h1:TqU9VKZa3I8YNXUGQWY3WVBYN+1FvyyaKy0hB1jgAho= -20251118074929.sql h1:p1KsWqCuR1JXA/jVO5BmOhCcaQ8clT7t0YRszAhPFbg= -20251119063438.sql h1:NVGM0X/LHD37EaPl8SNzkNiZDJ7AB1QR+LLwLh6WRdg= -20251119065730.sql h1:U5lzk1WvMB0bw3kwckou7jkEt4bwdYItwHr2Vxqe7w4= -20251119072302.sql h1:qCuI2WMEMF/XNbjV+RXPjBnuCKLu1Fia+mR9HiLWBIs= -20251119072450.sql h1:Xg+bTwqGyKPNFEQhJylvpz1wifdfmDJvcAq6vmNf0Ng= -20251120005512.sql h1:Ek6qpacAI/qVuTYxKno+uJyzn7s5z9pf3t7VA8gTzm4= -20251120074415.sql h1:NNUeJVA03EeBHJhHqPXEZoDv/PnC6yK1/cRhmukyaJo= -20251121033803.sql h1:/vfvFX/3pzSCIHnSbMUT9EMBDykOpVkvyfeTEle9Vas= -20251124071457.sql h1:qg2dhCL9YwD13xnfJ175lW/p6MGfzFKaBqd908FByRc= -20251125125303.sql h1:4JSFv1Pmhbe9tqpLXgO63OwYnGsalStgUXKVWPyc1YE= -20251126064057.sql h1:vAdhz5Nn/gGJy0UKZAEldeXv8HpHtJU/t8ygDVIbTsU= -20251201081333.sql h1:PoC8ADRdwDuohDTB74yW/DaB42igdYa4B6humbrEJBk= -20251201104439.sql h1:tpqdrOf9d2aGwZshqm62nG6SXnfVaO/g6A7z0efPS14= -20251201113804.sql h1:kIEmVoETJXBkab2Q+b3y/pP84eF8W2BdQ47amHCnc+c= -20251201113858.sql h1:KLXKZO5XTQPoEU0YLHE8Fhg9WPKpSN3wNgYPJ+RGFcg= -20251201114751.sql h1:HM17diiPknfSHAmP+kJGP6GzToaPU9/NT+KQBpf3Jq0= -20251201114913.sql h1:gqucFgHFFLA6n/Rdz486cZH5xkaJuwefESLJMJLDue8= -20251202030445.sql h1:QWBVfTepT7DaXP5E0BYoxNM0JwKIQ2qIMXzI4kbz/qE= -20251202044430.sql h1:4QZH9lz0GrQ9rzP1AJ+hJgGalNpp+8FCRckNK7xaTbU= -20251202064000.sql h1:/EN7sT1ol/91qW1aXWrzX+Mc3XOC/7f/LtfA0JRHpbg= -20251202130629.sql h1:9mvalqfhqGCdkcJepJDzHprU2xb0i5sYys1Htf62ioo= -20251202160848.sql h1:Kd2/TziKSMezrt4XgbjQcYvY/Lo9rX0qw7/Lz0/oyKk= -20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM= -20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= -20251203205052.sql h1:nk0VK2Uv4bHE3SBfHo/aevVZxtHzr7zAzvmMU8TCCtk= -20251205073858.sql h1:46qqXnArgJmzGE/WO7v7Ev8Jh7BudDiGbdANexq/5Dk= -20251205211957.sql h1:3fvtZ/mBWsTIXllXMFOuCLJsp4MivVP56dunehlU0yo= -20251205214433.sql h1:rn3++FEfX7ntcJcOmCEuOMnr27TZqH0KMGRppzFwFTc= -20251205221124.sql h1:CRruUvGZqlVDBmbQSVEl4wFm+uq30AurMMDI6sb8jxg= -20251206021053.sql h1:bpuEocu4lOhZ7oLuxd//22dzjfNgU2iaWEqSD1mVwoU= -20251207020537.sql h1:m6uh4NHVF3EKNTVMqOmuBSDFD9oCQk5mAwo05fT46G4= -20251207212015.sql h1:UPelYGTeUR6rm8mU8dfNzgRDEDun0UQ4tkgsaDljn30= -20251207221222.sql h1:bTfUCvCf2UPh+BA2IY2PHQafb9DwY9nhH5FRuMEHy+0= -20251209022744.sql h1:y5/PAiZH/fYCpDJpkQdNRJwWICHH2iNIwM1V+S1P6KA= -20251209025908.sql h1:p3kZA8kyEj+mQZSrdY3k2K1NojQzFJh/MlZJ0Oy6t/k= -20251209030538.sql h1:zltV6/Fu2zJW0/lVBl7MdnWuJcqNTUIRcqYYZ8Fi1wo= +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= +20251117005942.sql h1:0XoJKca8IOaB9QKFVF/qPY7jKcIgh6m/LODQuE06SAs= +20251117075427.sql h1:LhY2urosfoSu1/vkHmgsNP4JA4DuWBs9gL59yMqcF8M= +20251118074929.sql h1:3RWBD6BziQVw6WSfthgoVuhTELHER9NrIuZm4hY/F1A= +20251119063438.sql h1:EVTG3ZrHjCmM95YPASZTRPiwHrG6e33A2vO4hLSAaBQ= +20251119065730.sql h1:s98wnZOCW6NbnwDS3H53XIQ60u6B9bDwBLNvy5+Rn64= +20251119072302.sql h1:ZL+VHekLYqgNtOFKlj02WHrAk11dtTxQkmyTKE8IOzY= +20251119072450.sql h1:SiJy2vpSvoPFw4J1SW7HjGSJzrqR62NsjRYAeabV+kc= +20251120005512.sql h1:hJUaWXYJ3HiSquBTw8OKhymjA4O43ehAMGfiOY8W87Q= +20251120074415.sql h1:dNmcqZHqfZwi/wtYvO/pSFgImN2scXL0p/7g0+HLp0s= +20251121033803.sql h1:onlddYGo+tQdGaEdJPqdsx3sncGnwEvqMSCksF6vjjI= +20251124071457.sql h1:ikQLIXFikUbkUd55uJBmEvqLGEC9t0db+Om4TQsWP7M= +20251125125303.sql h1:OLKbNPO36AHtIDursW9AeBvf60sahQKC1iOjHmpx0MA= +20251126064057.sql h1:6al3PTWbw/WGiBcrRrVWppOMLtG+eRaH/qSLbnmh1kQ= +20251201081333.sql h1:dD+jcisoUYnxRYWdtVcnxbDeYjUW12/R/qarYQr+utg= +20251201104439.sql h1:h4tz5uetbCKeOI3agSVmAeh6jUfECYy0LhQ7HooYhzg= +20251201113804.sql h1:DdUzqfLdy4AUpVSRFDrIJXntGmtKgZrtvv8MAT4mMxs= +20251201113858.sql h1:XSpicm4aWjrfeY5EYIiw8Ios9v7BGfzZJxpW/57Qwqs= +20251201114751.sql h1:qx+ShdHLacVFcRwwGrW1zMKFHOjMGdnusk7CEfyV8ig= +20251201114913.sql h1:6l/m2/6fmTIjFmKio0QmB8oTwBDCHTIkbuYTODQ7Gwk= +20251202030445.sql h1:5+6ss5KdN6pll8Qtf0RGGyy/BURNO3dBgIBJOzDb624= +20251202044430.sql h1:nJtlQDGj7ZJtJ07NYcF41JCn9ck50GyDPoitTOe8P/s= +20251202064000.sql h1:yzSMOPZrpvQf+u6CxD6LwNySNH9Ip1u70UEf2vWI5w4= +20251202130629.sql h1:u79EiiYq5irxCcjlOHQcACnCKS05XPDDsL4TzLGrNQA= +20251202160848.sql h1:Aq5rVLbrL4vvNnmfk82V22GTteWVTSq9vk2SYzi3EBo= +20251202180207.sql h1:J0Orufzpi+tNhd5+9eLvonKhYc/WMceVHO1WDVRrHAM= +20251202231005.sql h1:DBunbxmAfPYiO5mHspc4dyTTVFoKrHkZSwk/Ieu5oFA= +20251203205052.sql h1:67NoN6JhDfChBA13dmErBSRDiC1gdVBb2F+8SMzpm4U= +20251205073858.sql h1:q6kLxs713H2BeVmC4cN6OnWz4Vj4k3G1iemqQnddmL8= +20251205211957.sql h1:aYPG5ESbHjhLRf8Dym1IMLBW2eRuafafoL46vpiRbWs= +20251205214433.sql h1:X9NOCU2CenDxnXe3kOyUB11Zikk+yO9yWNYAwFs/Bms= +20251205221124.sql h1:8ZXiMoNKQIMwXoLzrC44EQpXDUyEP16MiDOwUc9FI0s= +20251206021053.sql h1:jntV1lOgr4viO5wfavoTergWBSYDCbqw7L/UkhwuCYM= +20251207020537.sql h1:UIeD0lLOmo80REhicPlYsjj99xYYybPBph8ewZOQa2M= +20251207212015.sql h1:gMDRyRTNMyH9iNG/9cTflLUf60r5qMteaaTcQoDzNAI= +20251207221222.sql h1:FT+HGmIpvm+Y3w7DmENoeJWHBHjucDPQXPl8xyBRn9Y= +20251209022744.sql h1:eRmSp7hnpz5Mded7sBkc2+VZX6xKzU95rIzZOJC9Lhw= +20251209025908.sql h1:ZDtWUIuMIAcjQ/mMdDXbrbk+De9T2TGqprXcVSZOoT4= +20251209030538.sql h1:iTQimic8fGvHU10V7PSpSe9I0YpRFuNjOeOLY0eGMp8= From 792c7cc9d4b883c2003d825da530325897e752f5 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Tue, 9 Dec 2025 13:43:41 +0700 Subject: [PATCH 43/45] feat/user: added registration entity --- .../migrations/20251209064304.sql | 12 ++++ cmd/main-migration/migrations/atlas.sum | 5 +- .../domain/main-entities/registration/dto.go | 71 +++++++++++++++++++ .../main-entities/registration/entity.go | 15 ++++ internal/interface/migration/main-entities.go | 2 + 5 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 cmd/main-migration/migrations/20251209064304.sql create mode 100644 internal/domain/main-entities/registration/dto.go create mode 100644 internal/domain/main-entities/registration/entity.go diff --git a/cmd/main-migration/migrations/20251209064304.sql b/cmd/main-migration/migrations/20251209064304.sql new file mode 100644 index 00000000..fc289e20 --- /dev/null +++ b/cmd/main-migration/migrations/20251209064304.sql @@ -0,0 +1,12 @@ +-- Create "Registration" table +CREATE TABLE "public"."Registration" ( + "Id" bigserial NOT NULL, + "CreatedAt" timestamptz NULL, + "UpdatedAt" timestamptz NULL, + "DeletedAt" timestamptz NULL, + "Employee_Id" bigint NULL, + "Installation_Code" character varying(20) NULL, + PRIMARY KEY ("Id"), + CONSTRAINT "fk_Registration_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "fk_Registration_Installation" FOREIGN KEY ("Installation_Code") REFERENCES "public"."Installation" ("Code") 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 3ec1b876..c953a07b 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:qjr3k9/ymXjw1nopw49c6+fWtu0n+H8sQgsioqUC9Fo= +h1:JGe2DnXv3QZTmdne3HWeAGA4rppck8cJaiZ0RgoM+Sg= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -144,4 +144,5 @@ h1:qjr3k9/ymXjw1nopw49c6+fWtu0n+H8sQgsioqUC9Fo= 20251202160848.sql h1:Kd2/TziKSMezrt4XgbjQcYvY/Lo9rX0qw7/Lz0/oyKk= 20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM= 20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= -20251203205052.sql h1:az/hGpk7u4YKT7gU+UuEw9guqB9AqdckPF1cYavQ3CA= +20251203205052.sql h1:nk0VK2Uv4bHE3SBfHo/aevVZxtHzr7zAzvmMU8TCCtk= +20251209064304.sql h1:/vp48I71991yaVsOw/g+eFsFydgLGEo+Xfen7Lp8WB4= diff --git a/internal/domain/main-entities/registration/dto.go b/internal/domain/main-entities/registration/dto.go new file mode 100644 index 00000000..b7837aee --- /dev/null +++ b/internal/domain/main-entities/registration/dto.go @@ -0,0 +1,71 @@ +package doctor + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" + ei "simrs-vx/internal/domain/main-entities/installation" +) + +type CreateDto struct { + Employee_Id uint `json:"employee_id"` + Installation_Code string `json:"installation_code" validate:"maxLength=20"` +} + +type ReadListDto struct { + FilterDto + Includes string `json:"includes"` + Pagination ecore.Pagination +} + +type FilterDto struct { + Employee_Id *uint `json:"employee-id"` + Installation_Code *string `json:"installation-code"` +} + +type ReadDetailDto struct { + Id *uint16 `json:"id"` + Code *string `json:"code"` + Employee_Id *uint `json:"employee_id"` +} + +type UpdateDto struct { + Id *uint `json:"id"` + CreateDto +} + +type DeleteDto struct { + Id uint `json:"id"` +} + +type MetaDto struct { + PageNumber int `json:"page_number"` + PageSize int `json:"page_size"` + Count int `json:"count"` +} + +type ResponseDto struct { + ecore.Main + Employee_Id uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty"` + Installation_Code string `json:"installation_code"` + Installation *ei.Installation `json:"installation,omitempty"` +} + +func (d Registration) ToResponse() ResponseDto { + resp := ResponseDto{ + Employee_Id: d.Employee_Id, + Employee: d.Employee, + Installation_Code: d.Installation_Code, + Installation: d.Installation, + } + resp.Main = d.Main + return resp +} + +func ToResponseList(data []Registration) []ResponseDto { + resp := make([]ResponseDto, len(data)) + for i, u := range data { + resp[i] = u.ToResponse() + } + return resp +} diff --git a/internal/domain/main-entities/registration/entity.go b/internal/domain/main-entities/registration/entity.go new file mode 100644 index 00000000..52d81f40 --- /dev/null +++ b/internal/domain/main-entities/registration/entity.go @@ -0,0 +1,15 @@ +package doctor + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + ee "simrs-vx/internal/domain/main-entities/employee" + ei "simrs-vx/internal/domain/main-entities/installation" +) + +type Registration struct { + ecore.Main // adjust this according to the needs + Employee_Id uint `json:"employee_id"` + Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"` + Installation_Code string `json:"installation_code" gorm:"size:20"` + Installation *ei.Installation `json:"installation,omitempty" gorm:"foreignKey:Installation_Code;references:Code"` +} diff --git a/internal/interface/migration/main-entities.go b/internal/interface/migration/main-entities.go index 34530d78..aa4ed3f6 100644 --- a/internal/interface/migration/main-entities.go +++ b/internal/interface/migration/main-entities.go @@ -88,6 +88,7 @@ import ( proceduresrc "simrs-vx/internal/domain/main-entities/procedure-src" province "simrs-vx/internal/domain/main-entities/province" regency "simrs-vx/internal/domain/main-entities/regency" + registration "simrs-vx/internal/domain/main-entities/registration" rehab "simrs-vx/internal/domain/main-entities/rehab" responsibledoctorhist "simrs-vx/internal/domain/main-entities/responsible-doctor-hist" resume "simrs-vx/internal/domain/main-entities/resume" @@ -140,6 +141,7 @@ func getMainEntities() []any { &proceduresrc.ProcedureSrc{}, &employee.Employee{}, &intern.Intern{}, + ®istration.Registration{}, &doctor.Doctor{}, &nurse.Nurse{}, &nutritionist.Nutritionist{}, From 143b873c1134f7a9d75e948d66db4ccb20222057 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Tue, 9 Dec 2025 14:02:30 +0700 Subject: [PATCH 44/45] migration: adjust person entity --- .../migrations/20251209070128.sql | 2 ++ cmd/main-migration/migrations/atlas.sum | 16 ++++++++++++++-- internal/domain/main-entities/person/dto.go | 18 ++++++++++-------- internal/domain/main-entities/person/entity.go | 1 + 4 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 cmd/main-migration/migrations/20251209070128.sql diff --git a/cmd/main-migration/migrations/20251209070128.sql b/cmd/main-migration/migrations/20251209070128.sql new file mode 100644 index 00000000..fb0caac3 --- /dev/null +++ b/cmd/main-migration/migrations/20251209070128.sql @@ -0,0 +1,2 @@ +-- Modify "Person" table +ALTER TABLE "public"."Person" ADD COLUMN "BirthPlace" text NULL; diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index c953a07b..b828c76d 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:JGe2DnXv3QZTmdne3HWeAGA4rppck8cJaiZ0RgoM+Sg= +h1:YJzcjq4dKD7GKlV0GJ88TOtZgg0JRDcVMlAe5ZYT9/U= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -145,4 +145,16 @@ h1:JGe2DnXv3QZTmdne3HWeAGA4rppck8cJaiZ0RgoM+Sg= 20251202180207.sql h1:IHmSMIO3ia+YV5GULixbdlV1joaUAWtnjQHPd8+HKiM= 20251202231005.sql h1:lua0KKoeBptSfs/6ehZE6Azo6YUlNkOJwGFyb1HQWkY= 20251203205052.sql h1:nk0VK2Uv4bHE3SBfHo/aevVZxtHzr7zAzvmMU8TCCtk= -20251209064304.sql h1:/vp48I71991yaVsOw/g+eFsFydgLGEo+Xfen7Lp8WB4= +20251205073858.sql h1:46qqXnArgJmzGE/WO7v7Ev8Jh7BudDiGbdANexq/5Dk= +20251205211957.sql h1:3fvtZ/mBWsTIXllXMFOuCLJsp4MivVP56dunehlU0yo= +20251205214433.sql h1:rn3++FEfX7ntcJcOmCEuOMnr27TZqH0KMGRppzFwFTc= +20251205221124.sql h1:CRruUvGZqlVDBmbQSVEl4wFm+uq30AurMMDI6sb8jxg= +20251206021053.sql h1:bpuEocu4lOhZ7oLuxd//22dzjfNgU2iaWEqSD1mVwoU= +20251207020537.sql h1:m6uh4NHVF3EKNTVMqOmuBSDFD9oCQk5mAwo05fT46G4= +20251207212015.sql h1:UPelYGTeUR6rm8mU8dfNzgRDEDun0UQ4tkgsaDljn30= +20251207221222.sql h1:bTfUCvCf2UPh+BA2IY2PHQafb9DwY9nhH5FRuMEHy+0= +20251209022744.sql h1:y5/PAiZH/fYCpDJpkQdNRJwWICHH2iNIwM1V+S1P6KA= +20251209025908.sql h1:p3kZA8kyEj+mQZSrdY3k2K1NojQzFJh/MlZJ0Oy6t/k= +20251209030538.sql h1:zltV6/Fu2zJW0/lVBl7MdnWuJcqNTUIRcqYYZ8Fi1wo= +20251209064304.sql h1:Mj6Zh+2b/4AkM1HjnJGjAs788kVN0UaL34jeaKQIjT0= +20251209070128.sql h1:rdqSlAmJS5XSc1w9dka3C53zwgibQwRIUqBcgmIPoTM= diff --git a/internal/domain/main-entities/person/dto.go b/internal/domain/main-entities/person/dto.go index 588379df..dbab95b0 100644 --- a/internal/domain/main-entities/person/dto.go +++ b/internal/domain/main-entities/person/dto.go @@ -19,6 +19,7 @@ type CreateDto struct { FrontTitle *string `json:"frontTitle" validate:"maxLength=50"` EndTitle *string `json:"endTitle" validate:"maxLength=50"` BirthDate *time.Time `json:"birthDate,omitempty"` + BirthPlace *string `json:"birthPlace" validate:"maxLength=4"` BirthRegency_Code *string `json:"birthRegency_code" validate:"maxLength=4"` Gender_Code *erp.GenderCode `json:"gender_code"` ResidentIdentityNumber *string `json:"residentIdentityNumber" validate:"nik;maxLength=16"` @@ -46,14 +47,13 @@ type ReadListDto struct { type FilterDto struct { Name string `json:"name"` - FrontTitle *string `json:"frontTitle"` - EndTitle *string `json:"endTitle"` - BirthDate *time.Time `json:"birthDate,omitempty"` - BirthRegency_Code *string `json:"birthRegency-code"` + FrontTitle *string `json:"front-title"` + EndTitle *string `json:"end-title"` + BirthDate *time.Time `json:"birth-date,omitempty"` Gender_Code *erp.GenderCode `json:"gender-code"` - ResidentIdentityNumber *string `json:"residentIdentityNumber"` - PassportNumber *string `json:"passportNumber"` - DrivingLicenseNumber *string `json:"drivingLicenseNumber"` + ResidentIdentityNumber *string `json:"resident-identity-number"` + PassportNumber *string `json:"passport-number"` + DrivingLicenseNumber *string `json:"driving-license-number"` Religion_Code *erp.ReligionCode `json:"religion-code"` Education_Code *erp.EducationCode `json:"education-code"` Ocupation_Code *erp.OcupationCode `json:"occupation-code"` @@ -61,7 +61,7 @@ type FilterDto struct { Nationality *string `json:"nationality"` Ethnic_Code *string `json:"ethnic-code"` Language_Code *string `json:"language-code"` - CommunicationIssueStatus bool `json:"communicationIssueStatus"` + CommunicationIssueStatus bool `json:"communication-issue-status"` Disability *string `json:"disability"` } @@ -94,6 +94,7 @@ type ResponseDto struct { FrontTitle *string `json:"frontTitle"` EndTitle *string `json:"endTitle"` BirthDate *time.Time `json:"birthDate,omitempty"` + BirthPlace *string `json:"birthPlace"` BirthRegency_Code *string `json:"birthRegency_code"` BirthRegency *er.Regency `json:"birthRegency,omitempty"` Gender_Code *erp.GenderCode `json:"gender_code"` @@ -128,6 +129,7 @@ func (d *Person) ToResponse() ResponseDto { FrontTitle: d.FrontTitle, EndTitle: d.EndTitle, BirthDate: d.BirthDate, + BirthPlace: d.BirthPlace, BirthRegency_Code: d.BirthRegency_Code, BirthRegency: d.BirthRegency, Gender_Code: d.Gender_Code, diff --git a/internal/domain/main-entities/person/entity.go b/internal/domain/main-entities/person/entity.go index 3c7d8629..10626229 100644 --- a/internal/domain/main-entities/person/entity.go +++ b/internal/domain/main-entities/person/entity.go @@ -23,6 +23,7 @@ type Person struct { FrontTitle *string `json:"frontTitle" gorm:"size:50"` EndTitle *string `json:"endTitle" gorm:"size:50"` BirthDate *time.Time `json:"birthDate,omitempty"` + BirthPlace *string `json:"birthPlace,omitempty"` BirthRegency_Code *string `json:"birthRegency_code" gorm:"size:4"` BirthRegency *er.Regency `json:"birthRegency,omitempty" gorm:"foreignKey:BirthRegency_Code;references:Code"` Gender_Code *erp.GenderCode `json:"gender_code" gorm:"size:10"` From 591f6e6311742ac5a3b4bdcb63779dfcc195b8eb Mon Sep 17 00:00:00 2001 From: vanilia Date: Tue, 9 Dec 2025 15:30:29 +0700 Subject: [PATCH 45/45] add entity sync --- .../migrations/20251209083238.sql | 72 +++++++++++++++++++ .../migrations/atlas.sum | 5 +- .../domain/simgos-entities/m-dokter/entity.go | 24 +++++++ .../simgos-entities/m_perawat/entity.go | 52 ++++++++++++++ .../domain/sync-entities/doctor/entity.go | 29 ++++++++ internal/domain/sync-entities/nurse/entity.go | 29 ++++++++ .../migration/simgossync-entities.go | 8 +++ 7 files changed, 217 insertions(+), 2 deletions(-) create mode 100644 cmd/simgos-sync-migration/migrations/20251209083238.sql create mode 100644 internal/domain/simgos-entities/m-dokter/entity.go create mode 100644 internal/domain/simgos-entities/m_perawat/entity.go create mode 100644 internal/domain/sync-entities/doctor/entity.go create mode 100644 internal/domain/sync-entities/nurse/entity.go diff --git a/cmd/simgos-sync-migration/migrations/20251209083238.sql b/cmd/simgos-sync-migration/migrations/20251209083238.sql new file mode 100644 index 00000000..9e3f07eb --- /dev/null +++ b/cmd/simgos-sync-migration/migrations/20251209083238.sql @@ -0,0 +1,72 @@ +-- Create "DoctorLink" table +CREATE TABLE "public"."DoctorLink" ( + "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_DoctorLink_Simgos_Id" UNIQUE ("Simgos_Id"), + CONSTRAINT "uni_DoctorLink_Simx_Id" UNIQUE ("Simx_Id") +); +-- Create "DoctorSimgosLog" table +CREATE TABLE "public"."DoctorSimgosLog" ( + "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 "DoctorSimxLog" table +CREATE TABLE "public"."DoctorSimxLog" ( + "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 "NurseLink" table +CREATE TABLE "public"."NurseLink" ( + "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_NurseLink_Simgos_Id" UNIQUE ("Simgos_Id"), + CONSTRAINT "uni_NurseLink_Simx_Id" UNIQUE ("Simx_Id") +); +-- Create "NurseSimgosLog" table +CREATE TABLE "public"."NurseSimgosLog" ( + "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 "NurseSimxLog" table +CREATE TABLE "public"."NurseSimxLog" ( + "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 e82a5610..c06e3535 100644 --- a/cmd/simgos-sync-migration/migrations/atlas.sum +++ b/cmd/simgos-sync-migration/migrations/atlas.sum @@ -1,8 +1,9 @@ -h1:6YZBXq/r79I5tuYyY1+CBzhZsSeukHSs8MyHCC5QuV4= +h1:D3uD6s7yxMG7Roi9DCeYuLeRazZmQnd3rHMmUWf6YMM= 20251113035508.sql h1:rjDlu6yDdy5xv6nrCOr7NialrLSLT23pzduYNq29Hf0= 20251114071129.sql h1:Z0GQ5bJo3C+tplaWzxT8n3J9HLkEaVsRVp5nn7bmYow= 20251117041601.sql h1:l/RPG5mObqCSBjO4mzG+wTq2ieSycvlfOSz4czpUdWY= 20251118082246.sql h1:xLUwA+EvKWIg3X/TJvu7rqbtBzONiINfag5NJpMV29E= 20251118082915.sql h1:hP6FmUVFuADIN2cDg2Z1l7Wx7PQRb+IYQDvKD7J8VAM= 20251126115527.sql h1:Bvg+Y7k+h5s+/UaezUyJb7J7uzEJS7U5Z/RoCixcUtI= -20251201093443.sql h1:m18tksKG3OzbkxXkhfKUUqbkxnJ0VBPi3Cw34Tbywyc= +20251201093443.sql h1:dyiD1WzU9D6RjGhF0AtGfGLEsG6yocuk3HbcZWt9ZRQ= +20251209083238.sql h1:83pG5dPfMh8v0QognjeacK6s3fGxQ0nkijxtKL5y3Dc= diff --git a/internal/domain/simgos-entities/m-dokter/entity.go b/internal/domain/simgos-entities/m-dokter/entity.go new file mode 100644 index 00000000..47cbba6f --- /dev/null +++ b/internal/domain/simgos-entities/m-dokter/entity.go @@ -0,0 +1,24 @@ +package m_dokter + +import "time" + +type MDokter struct { + Kddokter uint `gorm:"column:kddokter;primaryKey;autoIncrement" json:"kddokter"` + Kdpoly uint `gorm:"column:kdpoly" json:"kdpoly"` + Namadokter string `gorm:"column:namadokter" json:"namadokter"` + Kdprofesi *uint `gorm:"column:kdprofesi" json:"kdprofesi"` + Namaprofesi *string `gorm:"column:namaprofesi" json:"namaprofesi"` + Aktif uint16 `gorm:"column:aktif" json:"aktif"` + KdSMF *string `gorm:"column:kdsmf" json:"kdsmf"` + KodeDPJP *string `gorm:"column:kode_dpjp" json:"kode_dpjp"` + NIP *string `gorm:"column:nip" json:"nip"` + Kategori *string `gorm:"column:kategori" json:"kategori"` + TglAkhirSIP *time.Time `gorm:"column:tgl_akhir_sip" json:"tgl_akhir_sip"` + NoHP *string `gorm:"column:no_hp" json:"no_hp"` + Email *string `gorm:"column:email" json:"email"` + TglAkhirSPK *time.Time `gorm:"column:tgl_akhir_spk" json:"tgl_akhir_spk"` +} + +func (MDokter) TableName() string { + return "m_dokter" +} diff --git a/internal/domain/simgos-entities/m_perawat/entity.go b/internal/domain/simgos-entities/m_perawat/entity.go new file mode 100644 index 00000000..c110ba11 --- /dev/null +++ b/internal/domain/simgos-entities/m_perawat/entity.go @@ -0,0 +1,52 @@ +package m_perawat + +import ( + "time" +) + +type MPerawat struct { + Idperawat *uint `json:"idperawat" gorm:"column:idperawat;primaryKey"` + NIP string `json:"nip" gorm:"column:nip"` + UnitKerja *uint `json:"unit_kerja" gorm:"column:unit_kerja"` + Ruang *string `json:"ruang" gorm:"column:ruang"` + Nama string `json:"nama" gorm:"column:nama"` + Tempat *string `json:"tempat" gorm:"column:tempat"` + TglLahir *time.Time `json:"tgllahir" gorm:"column:tgllahir"` + JenisKelamin *string `json:"jeniskelamin" gorm:"column:jeniskelamin"` + Alamat *string `json:"alamat" gorm:"column:alamat"` + Kelurahan *string `json:"kelurahan" gorm:"column:kelurahan"` + Kdkecamatan *uint `json:"kdkecamatan" gorm:"column:kdkecamatan"` + Kota *string `json:"kota" gorm:"column:kota"` + KdProvinsi *uint `json:"kdprovinsi" gorm:"column:kdprovinsi"` + NoTelp *string `json:"notelp" gorm:"column:notelp"` + NoKTP *string `json:"noktp" gorm:"column:noktp"` + Status *uint `json:"status" gorm:"column:status"` + Agama *uint `json:"agama" gorm:"column:agama"` + Pendidikan *uint `json:"pendidikan" gorm:"column:pendidikan"` + AlamatKTP *string `json:"alamat_ktp" gorm:"column:alamat_ktp"` + JabFung *string `json:"jabfung" gorm:"column:jabfung"` + JabStruk *string `json:"jabstruk" gorm:"column:jabstruk"` + LamKer *string `json:"lamker" gorm:"column:lamker"` + TemKer *string `json:"temker" gorm:"column:temker"` + TemKer2 *string `json:"temker2" gorm:"column:temker2"` + PelManKep *string `json:"pelmankep" gorm:"column:pelmankep"` + PelTekKepGaw *string `json:"peltekkepgaw" gorm:"column:peltekkepgaw"` + PelTekKepMedah *string `json:"peltekkepmedah" gorm:"column:peltekkepmedah"` + PelTekKepNak *string `json:"peltekkepnak" gorm:"column:peltekkepnak"` + PelTekKepMat *string `json:"peltekkepmat" gorm:"column:peltekkepmat"` + PelTekKepJiwa *string `json:"peltekkepjiwa" gorm:"column:peltekkepjiwa"` + TemKerTuj *string `json:"temkertuj" gorm:"column:temkertuj"` + TemKerTuj2 *string `json:"temkertuj2" gorm:"column:temkertuj2"` + TglMutasi *time.Time `json:"tglmutasi" gorm:"column:tglmutasi"` + Alasan *string `json:"alasan" gorm:"column:alasan"` + TglKeluar *time.Time `json:"tglkeluar" gorm:"column:tglkeluar"` + ProgPendidikan *uint `json:"progpendidikan" gorm:"column:progpendidikan"` + ProgPeng *string `json:"progpeng" gorm:"column:progpeng"` + JabLain *string `json:"jablain" gorm:"column:jablain"` + PPA uint `json:"ppa" gorm:"column:ppa"` + Aktif uint `json:"aktif" gorm:"column:aktif"` +} + +func (MPerawat) TableName() string { + return "m_perawat" +} diff --git a/internal/domain/sync-entities/doctor/entity.go b/internal/domain/sync-entities/doctor/entity.go new file mode 100644 index 00000000..6a112a01 --- /dev/null +++ b/internal/domain/sync-entities/doctor/entity.go @@ -0,0 +1,29 @@ +package doctor + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + erc "simrs-vx/internal/domain/references/common" + "time" +) + +type DoctorLink struct { + ecore.Main + Simx_Id uint `json:"simx_id" gorm:"unique"` + Simgos_Id uint `json:"simgos_id" gorm:"unique"` +} + +type DoctorSimxLog struct { + ecore.Main + Value *string `json:"value"` + Date *time.Time `json:"date"` + Status erc.ProcessStatusCode `json:"status"` + ErrMessage *string `json:"errMessage"` +} + +type DoctorSimgosLog 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/nurse/entity.go b/internal/domain/sync-entities/nurse/entity.go new file mode 100644 index 00000000..fdf78d38 --- /dev/null +++ b/internal/domain/sync-entities/nurse/entity.go @@ -0,0 +1,29 @@ +package nurse + +import ( + ecore "simrs-vx/internal/domain/base-entities/core" + erc "simrs-vx/internal/domain/references/common" + "time" +) + +type NurseLink struct { + ecore.Main + Simx_Id uint `json:"simx_id" gorm:"unique"` + Simgos_Id uint `json:"simgos_id" gorm:"unique"` +} + +type NurseSimxLog struct { + ecore.Main + Value *string `json:"value"` + Date *time.Time `json:"date"` + Status erc.ProcessStatusCode `json:"status"` + ErrMessage *string `json:"errMessage"` +} + +type NurseSimgosLog struct { + ecore.Main + Value *string `json:"value"` + Date *time.Time `json:"date"` + Status erc.ProcessStatusCode `json:"status"` + ErrMessage *string `json:"errMessage"` +} diff --git a/internal/interface/migration/simgossync-entities.go b/internal/interface/migration/simgossync-entities.go index 2c479521..0480a1e1 100644 --- a/internal/interface/migration/simgossync-entities.go +++ b/internal/interface/migration/simgossync-entities.go @@ -3,9 +3,11 @@ package migration import ( /************** Source ***************/ division "simrs-vx/internal/domain/sync-entities/division" + doctor "simrs-vx/internal/domain/sync-entities/doctor" encounter "simrs-vx/internal/domain/sync-entities/encounter" installation "simrs-vx/internal/domain/sync-entities/installation" internalreference "simrs-vx/internal/domain/sync-entities/internal-reference" + nurse "simrs-vx/internal/domain/sync-entities/nurse" patient "simrs-vx/internal/domain/sync-entities/patient" soapi "simrs-vx/internal/domain/sync-entities/soapi" specialist "simrs-vx/internal/domain/sync-entities/specialist" @@ -42,5 +44,11 @@ func getSyncEntities() []any { &soapi.SoapiLink{}, &soapi.SoapiSimxLog{}, &soapi.SoapiSimgosLog{}, + &doctor.DoctorLink{}, + &doctor.DoctorSimxLog{}, + &doctor.DoctorSimgosLog{}, + &nurse.NurseLink{}, + &nurse.NurseSimxLog{}, + &nurse.NurseSimgosLog{}, } }