endpoint table antrian per spesialis
This commit is contained in:
@@ -338,6 +338,47 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/dashboard/table-antrian-per-spesialis/": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Dashboard"
|
||||
],
|
||||
"summary": "Get Table Antrian per Spesialis",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "tahun dalam int",
|
||||
"name": "year",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "bulan dalam int",
|
||||
"name": "month",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/dashboard.TableAntreanPerSpesialis"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/shared.BaseErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/reference/diagnosa/": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -954,6 +995,29 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"dashboard.TableAntreanPerSpesialis": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"batal": {
|
||||
"type": "integer"
|
||||
},
|
||||
"belum": {
|
||||
"type": "integer"
|
||||
},
|
||||
"selesai": {
|
||||
"type": "integer"
|
||||
},
|
||||
"spesialis": {
|
||||
"type": "string"
|
||||
},
|
||||
"total": {
|
||||
"type": "integer"
|
||||
},
|
||||
"tunda": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"diagnosa.DiagnosaResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -332,6 +332,47 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/dashboard/table-antrian-per-spesialis/": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Dashboard"
|
||||
],
|
||||
"summary": "Get Table Antrian per Spesialis",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "tahun dalam int",
|
||||
"name": "year",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "bulan dalam int",
|
||||
"name": "month",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/dashboard.TableAntreanPerSpesialis"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/shared.BaseErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/reference/diagnosa/": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -948,6 +989,29 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"dashboard.TableAntreanPerSpesialis": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"batal": {
|
||||
"type": "integer"
|
||||
},
|
||||
"belum": {
|
||||
"type": "integer"
|
||||
},
|
||||
"selesai": {
|
||||
"type": "integer"
|
||||
},
|
||||
"spesialis": {
|
||||
"type": "string"
|
||||
},
|
||||
"total": {
|
||||
"type": "integer"
|
||||
},
|
||||
"tunda": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"diagnosa.DiagnosaResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -244,6 +244,21 @@ definitions:
|
||||
statust:
|
||||
type: string
|
||||
type: object
|
||||
dashboard.TableAntreanPerSpesialis:
|
||||
properties:
|
||||
batal:
|
||||
type: integer
|
||||
belum:
|
||||
type: integer
|
||||
selesai:
|
||||
type: integer
|
||||
spesialis:
|
||||
type: string
|
||||
total:
|
||||
type: integer
|
||||
tunda:
|
||||
type: integer
|
||||
type: object
|
||||
diagnosa.DiagnosaResponse:
|
||||
properties:
|
||||
keterangan:
|
||||
@@ -592,6 +607,33 @@ paths:
|
||||
summary: Get Perbandingan Status Antrean
|
||||
tags:
|
||||
- Dashboard
|
||||
/dashboard/table-antrian-per-spesialis/:
|
||||
get:
|
||||
parameters:
|
||||
- description: tahun dalam int
|
||||
in: query
|
||||
name: year
|
||||
required: true
|
||||
type: integer
|
||||
- description: bulan dalam int
|
||||
in: query
|
||||
name: month
|
||||
required: true
|
||||
type: integer
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/dashboard.TableAntreanPerSpesialis'
|
||||
type: array
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/shared.BaseErrorResponse'
|
||||
summary: Get Table Antrian per Spesialis
|
||||
tags:
|
||||
- Dashboard
|
||||
/reference/diagnosa/:
|
||||
get:
|
||||
parameters:
|
||||
|
||||
@@ -145,3 +145,44 @@ func (h DashboardHandler) GetPerbandinganKategoriAntrean(c *gin.Context) {
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// GetTableAntrianPerSpesialis godoc
|
||||
// @Summary Get Table Antrian per Spesialis
|
||||
// @Tags Dashboard
|
||||
// @Param year query int true "tahun dalam int"
|
||||
// @Param month query int true "bulan dalam int"
|
||||
// @Success 200 {object} []TableAntreanPerSpesialis
|
||||
// @Failure 500 {object} shared.BaseErrorResponse
|
||||
// @Router /dashboard/table-antrian-per-spesialis/ [get]
|
||||
func (h DashboardHandler) GetTableAntrianPerSpesialis(c *gin.Context) {
|
||||
var req PeriodeDashboardRequest
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
c.JSON(400, shared.BaseErrorResponse{
|
||||
Success: false,
|
||||
Code: 400,
|
||||
Message: "error bind json",
|
||||
Errors: shared.ValidationError(err),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
data, err := h.repo.GetTableAntrianPerSpesialis(c, req)
|
||||
|
||||
if err != nil {
|
||||
errorResponse := baseResponse.BaseErrorResponse{
|
||||
Success: false,
|
||||
Code: 500,
|
||||
Message: err.Error(),
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, errorResponse)
|
||||
return
|
||||
}
|
||||
|
||||
response := baseResponse.ToBaseResponse(
|
||||
data,
|
||||
true,
|
||||
200,
|
||||
"success get table antrean per spesialis")
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
@@ -44,6 +44,24 @@ type PerbandinganKategoriAntrean struct {
|
||||
Jumlah int `db:"jumlah" json:"jumlah"`
|
||||
}
|
||||
|
||||
type TableAntreanPerSpesialis struct {
|
||||
Spesialis string `db:"spesialis"`
|
||||
Total int `db:"total"`
|
||||
Belum int `db:"belum"`
|
||||
Selesai int `db:"selesai"`
|
||||
Tunda int `db:"tunda"`
|
||||
Batal int `db:"batal"`
|
||||
}
|
||||
|
||||
type TableAntreanPerSubSpesialis struct {
|
||||
Spesialis string `db:"spesialis"`
|
||||
SubSpesialis string `db:"sub_spesialis"`
|
||||
Total int `db:"total"`
|
||||
Belum int `db:"belum"`
|
||||
Selesai int `db:"selesai"`
|
||||
Tunda int `db:"tunda"`
|
||||
}
|
||||
|
||||
type ListModelAntrianPerSpesialis []AntrianPerSpesialisModel
|
||||
|
||||
func (list ListModelAntrianPerSpesialis) ParseToResponse() []AntrianPerSpesialisResponse {
|
||||
|
||||
@@ -17,6 +17,8 @@ type IDashboardRepository interface {
|
||||
GetAntrianPerSpesialis(c *gin.Context) (ListModelAntrianPerSpesialis, error)
|
||||
GetPerbandinganStatusAntrean(c *gin.Context, req PeriodeDashboardRequest) (ListPerbandinganStatusAntrean, error)
|
||||
GetPerbandinganKategoriAntrean(c *gin.Context, req PeriodeDashboardRequest) ([]PerbandinganKategoriAntrean, error)
|
||||
GetTableAntrianPerSpesialis(c *gin.Context, req PeriodeDashboardRequest) ([]TableAntreanPerSpesialis, error)
|
||||
GetTableAntrianPerSubSpesialis(c *gin.Context, req PeriodeDashboardRequest) ([]TableAntreanPerSubSpesialis, error)
|
||||
}
|
||||
|
||||
type dashboardRepo struct {
|
||||
@@ -235,3 +237,52 @@ func (r dashboardRepo) GetPerbandinganKategoriAntrean(c *gin.Context, req Period
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r dashboardRepo) GetTableAntrianPerSpesialis(c *gin.Context, req PeriodeDashboardRequest) ([]TableAntreanPerSpesialis, error) {
|
||||
var result []TableAntreanPerSpesialis
|
||||
|
||||
query := queryUtils.DynamicQuery{
|
||||
From: TBL_NAME,
|
||||
Aliases: "dpo",
|
||||
Fields: []queryUtils.SelectField{
|
||||
{Expression: "ds.Spesialis", Alias: "spesialis"},
|
||||
{Expression: "count(dpo.id) as total"},
|
||||
{Expression: "count(dpo.id) filter (where dpo.\"Status_operasi\" = ('1')) as belum"},
|
||||
{Expression: "count(dpo.id) filter (where dpo.\"Status_operasi\" = ('2')) as selesai"},
|
||||
{Expression: "count(dpo.id) filter (where dpo.\"Status_operasi\" = ('3')) as tunda"},
|
||||
{Expression: "count(dpo.id) filter (where dpo.\"Status_operasi\" = ('4')) as batal"},
|
||||
},
|
||||
Joins: []queryUtils.Join{
|
||||
{
|
||||
Type: "LEFT",
|
||||
Table: "daftar_spesialis",
|
||||
Alias: "ds",
|
||||
OnConditions: queryUtils.FilterGroup{
|
||||
Filters: []queryUtils.DynamicFilter{
|
||||
{Column: "dpo.Spesialis", Operator: queryUtils.OpEqual, Value: "ds.id"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
GroupBy: []string{"ds.Spesialis"},
|
||||
}
|
||||
|
||||
dbconn, err := r.db.GetSQLXDB(DB_NAME)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
err = r.queryBuilder.ExecuteQuery(
|
||||
c, dbconn, query, &result)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r dashboardRepo) GetTableAntrianPerSubSpesialis(c *gin.Context, req PeriodeDashboardRequest) ([]TableAntreanPerSubSpesialis, error) {
|
||||
var result []TableAntreanPerSubSpesialis
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -14,4 +14,5 @@ func RegisterRoutes(r *gin.RouterGroup, dbService database.Service) {
|
||||
r.GET("/antrian-per-spesialis", dashboardHandler.GetAntrianPerSpesialis)
|
||||
r.GET("/perbandingan-status-antrian", dashboardHandler.GetPerbandinganStatusAntrean)
|
||||
r.GET("/perbandingan-kategori-antrian", dashboardHandler.GetPerbandinganKategoriAntrean)
|
||||
r.GET("/table-antrian-per-spesialis", dashboardHandler.GetTableAntrianPerSpesialis)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user