feat (encounter): add filter by range registered at, and patient name
This commit is contained in:
@@ -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)).
|
||||
|
||||
Reference in New Issue
Block a user