Merge branch 'dev' into feat/order-things

This commit is contained in:
2025-12-04 13:54:28 +07:00
3 changed files with 21 additions and 5 deletions
@@ -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 {
@@ -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
}
@@ -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(\"Encounter\".\"RegisteredAt\") >= DATE(?) AND DATE(\"Encounter\".\"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)).