feat (encounter): add filter by range registered at, and patient name

This commit is contained in:
dpurbosakti
2025-12-03 17:32:36 +07:00
parent 18c5e41695
commit 203b6f51d5
2 changed files with 19 additions and 3 deletions
@@ -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(\"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)).