feat: add active hospital catalog API
This commit is contained in:
29
internal/http/hospitals.go
Normal file
29
internal/http/hospitals.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"primaya-api/cpone-middleware/internal/databaseconfig"
|
||||
)
|
||||
|
||||
type HospitalSummary struct {
|
||||
RSCode string `json:"kode_rs"`
|
||||
Name string `json:"nama"`
|
||||
Status bool `json:"status"`
|
||||
}
|
||||
|
||||
func (h DatabaseSettingsHandler) ListHospitals(w http.ResponseWriter, _ *http.Request) {
|
||||
settings := h.store.List()
|
||||
hospitals := make([]HospitalSummary, 0, len(settings))
|
||||
for _, setting := range settings {
|
||||
if !setting.Active {
|
||||
continue
|
||||
}
|
||||
hospitals = append(hospitals, hospitalSummary(setting))
|
||||
}
|
||||
WriteJSON(w, http.StatusOK, Response{Success: true, Message: "ok", Data: hospitals})
|
||||
}
|
||||
|
||||
func hospitalSummary(setting databaseconfig.PublicSetting) HospitalSummary {
|
||||
return HospitalSummary{RSCode: setting.RSCode, Name: setting.Name, Status: setting.Active}
|
||||
}
|
||||
Reference in New Issue
Block a user