Merge pull request #192 from dikstub-rssa/fix/anything-moko
feat (encounter): add more filter for list
This commit is contained in:
@@ -78,11 +78,14 @@ type TRujukan struct {
|
||||
|
||||
type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Pagination ecore.Pagination
|
||||
Person_Name *string `json:"person-name"`
|
||||
StartDate *string `json:"start-date"`
|
||||
EndDate *string `json:"end-date"`
|
||||
Includes string `json:"includes"`
|
||||
Pagination ecore.Pagination
|
||||
Patient_Identifier *string `json:"patient-identifier"`
|
||||
StartDate *string `json:"start-date"`
|
||||
EndDate *string `json:"end-date"`
|
||||
PaymentMethod_Code *string `json:"paymentMethod-code"`
|
||||
Status_Code *string `json:"status-code"`
|
||||
Unit_Code *string `json:"unit-code"`
|
||||
|
||||
pa.AuthInfo
|
||||
}
|
||||
@@ -92,7 +95,6 @@ type FilterDto struct {
|
||||
Patient *ep.Patient `json:"patient,omitempty"`
|
||||
RegisteredAt *time.Time `json:"registeredAt"`
|
||||
Class_Code ere.EncounterClassCode `json:"class-code" validate:"maxLength=10"`
|
||||
Unit_Code *string `json:"unit-code"`
|
||||
Specialist_Code *string `json:"specialist-code"`
|
||||
Subspecialist_Code *string `json:"subspecialist-code"`
|
||||
VisitDate time.Time `json:"visitDate"`
|
||||
|
||||
@@ -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