on going
This commit is contained in:
@@ -35,6 +35,7 @@ type FilterDto struct {
|
|||||||
Status_Code *erc.DataVerifiedCode `json:"status-code"`
|
Status_Code *erc.DataVerifiedCode `json:"status-code"`
|
||||||
VerifiedBy_User_Id *uint `json:"verifiedBy-user-id"`
|
VerifiedBy_User_Id *uint `json:"verifiedBy-user-id"`
|
||||||
SrcUnit_Code *string `json:"srcUnit-code"`
|
SrcUnit_Code *string `json:"srcUnit-code"`
|
||||||
|
Patient_Id *uint `json:"patient-id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReadDetailDto struct {
|
type ReadDetailDto struct {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func getChemoEncounterReg(event *pl.Event) (*ec.Chemo, error) {
|
|||||||
if err := tx.Model(&ec.Chemo{}).
|
if err := tx.Model(&ec.Chemo{}).
|
||||||
Joins(`LEFT JOIN "Encounter" "e" ON "e"."Id" = "Chemo"."Encounter_Id"`).
|
Joins(`LEFT JOIN "Encounter" "e" ON "e"."Id" = "Chemo"."Encounter_Id"`).
|
||||||
Joins(`LEFT JOIN "Ambulatory" "a" ON "a"."Encounter_Id" = "e"."Id"`).
|
Joins(`LEFT JOIN "Ambulatory" "a" ON "a"."Encounter_Id" = "e"."Id"`).
|
||||||
Where(`"Chemo"."Status_Code" = ? AND a"."Class_Code" = ?`, erc.DVCVerified, ere.ACCReg).
|
Where(`"Chemo"."Status_Code" = ? AND "a"."Class_Code" = ?`, erc.DVCVerified, ere.ACCReg).
|
||||||
Order("\"CreatedAt\" DESC").
|
Order("\"CreatedAt\" DESC").
|
||||||
First(&data).
|
First(&data).
|
||||||
Error; err != nil {
|
Error; err != nil {
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
e "simrs-vx/internal/domain/main-entities/chemo"
|
|
||||||
|
|
||||||
erc "simrs-vx/internal/domain/references/common"
|
|
||||||
|
|
||||||
dg "github.com/karincake/apem/db-gorm-pg"
|
dg "github.com/karincake/apem/db-gorm-pg"
|
||||||
d "github.com/karincake/dodol"
|
d "github.com/karincake/dodol"
|
||||||
|
|
||||||
@@ -15,6 +11,13 @@ import (
|
|||||||
pu "simrs-vx/pkg/use-case-helper"
|
pu "simrs-vx/pkg/use-case-helper"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
|
erc "simrs-vx/internal/domain/references/common"
|
||||||
|
|
||||||
|
e "simrs-vx/internal/domain/main-entities/chemo"
|
||||||
|
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||||
|
|
||||||
|
ue "simrs-vx/internal/use-case/main-use-case/encounter"
|
||||||
)
|
)
|
||||||
|
|
||||||
const source = "chemo"
|
const source = "chemo"
|
||||||
@@ -83,6 +86,15 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
|
|||||||
// Start log
|
// Start log
|
||||||
pl.SetLogInfo(&event, input, "started", "readList")
|
pl.SetLogInfo(&event, input, "started", "readList")
|
||||||
|
|
||||||
|
if input.Encounter_Id == nil {
|
||||||
|
event.Status = "failed"
|
||||||
|
event.ErrInfo = pl.ErrorInfo{
|
||||||
|
Code: "data-validation-fail",
|
||||||
|
Detail: "Encounter-Id is required",
|
||||||
|
}
|
||||||
|
return nil, pl.SetLogError(&event, input)
|
||||||
|
}
|
||||||
|
|
||||||
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
err = dg.I.Transaction(func(tx *gorm.DB) error {
|
||||||
mwRunner := newMiddlewareRunner(&event, tx)
|
mwRunner := newMiddlewareRunner(&event, tx)
|
||||||
mwRunner.setMwType(pu.MWTPre)
|
mwRunner.setMwType(pu.MWTPre)
|
||||||
@@ -91,6 +103,15 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get Encounter
|
||||||
|
dataEncounter, err := ue.ReadDetailData(ee.ReadDetailDto{Id: *input.Encounter_Id}, &event)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
input.Patient_Id = dataEncounter.Patient_Id
|
||||||
|
input.Encounter_Id = nil
|
||||||
|
|
||||||
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
|
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Ch
|
|||||||
|
|
||||||
tx = tx.
|
tx = tx.
|
||||||
Model(&e.Chemo{}).
|
Model(&e.Chemo{}).
|
||||||
|
Joins(`LEFT JOIN "Encounter" "e" ON "e"."Id" = "Chemo"."Encounter_Id"`).
|
||||||
|
Joins(`LEFT JOIN "Patient" "p" ON "e"."Patient_Id" = "p"."Id"`).
|
||||||
|
Where(`"p"."Id" = ?`, input.Patient_Id).
|
||||||
Scopes(gh.Preload(input.Includes)).
|
Scopes(gh.Preload(input.Includes)).
|
||||||
Scopes(gh.Filter(input.FilterDto)).
|
Scopes(gh.Filter(input.FilterDto)).
|
||||||
Count(&count).
|
Count(&count).
|
||||||
|
|||||||
Reference in New Issue
Block a user