feat (encounter): add more filter for list
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user