api reference diagnosa
This commit is contained in:
+78
-4
@@ -136,6 +136,39 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/reference/diagnosa/": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Reference"
|
||||
],
|
||||
"summary": "Get List Diagnosa",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Search keyword",
|
||||
"name": "search",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/diagnosa.DiagnosaModel"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/shared.BaseErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/reference/dokter/": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -325,9 +358,14 @@ const docTemplate = `{
|
||||
"definitions": {
|
||||
"antrianoperasi.CreatePasienOperasiRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"diagnosisItems",
|
||||
"tindakanItems"
|
||||
],
|
||||
"properties": {
|
||||
"diagnosisItems": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "#/definitions/antrianoperasi.DiagnosisItemRequest"
|
||||
}
|
||||
@@ -349,6 +387,7 @@ const docTemplate = `{
|
||||
},
|
||||
"tindakanItems": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "#/definitions/antrianoperasi.TindakanItemRequest"
|
||||
}
|
||||
@@ -357,6 +396,11 @@ const docTemplate = `{
|
||||
},
|
||||
"antrianoperasi.DiagnosisItemRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"diagnosa",
|
||||
"jenisDiagnosa",
|
||||
"kodeDiagnosa"
|
||||
],
|
||||
"properties": {
|
||||
"diagnosa": {
|
||||
"type": "string"
|
||||
@@ -388,6 +432,9 @@ const docTemplate = `{
|
||||
},
|
||||
"antrianoperasi.FormDataRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"nomorTelepon"
|
||||
],
|
||||
"properties": {
|
||||
"alamat": {
|
||||
"type": "string"
|
||||
@@ -406,6 +453,7 @@ const docTemplate = `{
|
||||
},
|
||||
"nomorTelepon": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -422,7 +470,10 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"diagnosa": {
|
||||
"type": "string"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
@@ -433,9 +484,6 @@ const docTemplate = `{
|
||||
"kategori": {
|
||||
"type": "string"
|
||||
},
|
||||
"kodeDiagnosa": {
|
||||
"type": "string"
|
||||
},
|
||||
"namaPasien": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -465,11 +513,18 @@ const docTemplate = `{
|
||||
},
|
||||
"tglDaftar": {
|
||||
"type": "string"
|
||||
},
|
||||
"tindakan": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"antrianoperasi.RencanaOperasiRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"spesialis",
|
||||
"subSpesialis"
|
||||
],
|
||||
"properties": {
|
||||
"kategoriOperasi": {
|
||||
"type": "integer"
|
||||
@@ -507,6 +562,11 @@ const docTemplate = `{
|
||||
},
|
||||
"antrianoperasi.TindakanItemRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"kodeTindakan",
|
||||
"tindakan",
|
||||
"tindakanTambahan"
|
||||
],
|
||||
"properties": {
|
||||
"kodeTindakan": {
|
||||
"type": "string"
|
||||
@@ -533,6 +593,20 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"diagnosa.DiagnosaModel": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"jenisPenyakit": {
|
||||
"type": "string"
|
||||
},
|
||||
"kodeDiagnosa": {
|
||||
"type": "string"
|
||||
},
|
||||
"sebabPenyakit": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dokter.DokterResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
+78
-4
@@ -130,6 +130,39 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/reference/diagnosa/": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Reference"
|
||||
],
|
||||
"summary": "Get List Diagnosa",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Search keyword",
|
||||
"name": "search",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/diagnosa.DiagnosaModel"
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/shared.BaseErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/reference/dokter/": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -319,9 +352,14 @@
|
||||
"definitions": {
|
||||
"antrianoperasi.CreatePasienOperasiRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"diagnosisItems",
|
||||
"tindakanItems"
|
||||
],
|
||||
"properties": {
|
||||
"diagnosisItems": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "#/definitions/antrianoperasi.DiagnosisItemRequest"
|
||||
}
|
||||
@@ -343,6 +381,7 @@
|
||||
},
|
||||
"tindakanItems": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "#/definitions/antrianoperasi.TindakanItemRequest"
|
||||
}
|
||||
@@ -351,6 +390,11 @@
|
||||
},
|
||||
"antrianoperasi.DiagnosisItemRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"diagnosa",
|
||||
"jenisDiagnosa",
|
||||
"kodeDiagnosa"
|
||||
],
|
||||
"properties": {
|
||||
"diagnosa": {
|
||||
"type": "string"
|
||||
@@ -382,6 +426,9 @@
|
||||
},
|
||||
"antrianoperasi.FormDataRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"nomorTelepon"
|
||||
],
|
||||
"properties": {
|
||||
"alamat": {
|
||||
"type": "string"
|
||||
@@ -400,6 +447,7 @@
|
||||
},
|
||||
"nomorTelepon": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -416,7 +464,10 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"diagnosa": {
|
||||
"type": "string"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
@@ -427,9 +478,6 @@
|
||||
"kategori": {
|
||||
"type": "string"
|
||||
},
|
||||
"kodeDiagnosa": {
|
||||
"type": "string"
|
||||
},
|
||||
"namaPasien": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -459,11 +507,18 @@
|
||||
},
|
||||
"tglDaftar": {
|
||||
"type": "string"
|
||||
},
|
||||
"tindakan": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"antrianoperasi.RencanaOperasiRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"spesialis",
|
||||
"subSpesialis"
|
||||
],
|
||||
"properties": {
|
||||
"kategoriOperasi": {
|
||||
"type": "integer"
|
||||
@@ -501,6 +556,11 @@
|
||||
},
|
||||
"antrianoperasi.TindakanItemRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"kodeTindakan",
|
||||
"tindakan",
|
||||
"tindakanTambahan"
|
||||
],
|
||||
"properties": {
|
||||
"kodeTindakan": {
|
||||
"type": "string"
|
||||
@@ -527,6 +587,20 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"diagnosa.DiagnosaModel": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"jenisPenyakit": {
|
||||
"type": "string"
|
||||
},
|
||||
"kodeDiagnosa": {
|
||||
"type": "string"
|
||||
},
|
||||
"sebabPenyakit": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dokter.DokterResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
+54
-3
@@ -5,6 +5,7 @@ definitions:
|
||||
diagnosisItems:
|
||||
items:
|
||||
$ref: '#/definitions/antrianoperasi.DiagnosisItemRequest'
|
||||
minItems: 1
|
||||
type: array
|
||||
dokterPelaksanaItems:
|
||||
items:
|
||||
@@ -19,7 +20,11 @@ definitions:
|
||||
tindakanItems:
|
||||
items:
|
||||
$ref: '#/definitions/antrianoperasi.TindakanItemRequest'
|
||||
minItems: 1
|
||||
type: array
|
||||
required:
|
||||
- diagnosisItems
|
||||
- tindakanItems
|
||||
type: object
|
||||
antrianoperasi.DiagnosisItemRequest:
|
||||
properties:
|
||||
@@ -29,6 +34,10 @@ definitions:
|
||||
type: string
|
||||
kodeDiagnosa:
|
||||
type: string
|
||||
required:
|
||||
- diagnosa
|
||||
- jenisDiagnosa
|
||||
- kodeDiagnosa
|
||||
type: object
|
||||
antrianoperasi.DokterPelaksanaItemRequest:
|
||||
properties:
|
||||
@@ -56,24 +65,27 @@ definitions:
|
||||
nomorTelepon:
|
||||
items:
|
||||
type: string
|
||||
minItems: 1
|
||||
type: array
|
||||
tanggalLahir:
|
||||
type: string
|
||||
umur:
|
||||
type: string
|
||||
required:
|
||||
- nomorTelepon
|
||||
type: object
|
||||
antrianoperasi.PasienOperasi:
|
||||
properties:
|
||||
diagnosa:
|
||||
type: string
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
id:
|
||||
type: string
|
||||
jenisKelamin:
|
||||
type: string
|
||||
kategori:
|
||||
type: string
|
||||
kodeDiagnosa:
|
||||
type: string
|
||||
namaPasien:
|
||||
type: string
|
||||
noKtp:
|
||||
@@ -94,6 +106,8 @@ definitions:
|
||||
type: string
|
||||
tglDaftar:
|
||||
type: string
|
||||
tindakan:
|
||||
type: string
|
||||
type: object
|
||||
antrianoperasi.RencanaOperasiRequest:
|
||||
properties:
|
||||
@@ -109,6 +123,9 @@ definitions:
|
||||
type: integer
|
||||
tanggalDaftar:
|
||||
type: string
|
||||
required:
|
||||
- spesialis
|
||||
- subSpesialis
|
||||
type: object
|
||||
antrianoperasi.StatusPasienRequest:
|
||||
properties:
|
||||
@@ -127,6 +144,10 @@ definitions:
|
||||
type: string
|
||||
tindakanTambahan:
|
||||
type: string
|
||||
required:
|
||||
- kodeTindakan
|
||||
- tindakan
|
||||
- tindakanTambahan
|
||||
type: object
|
||||
dashboard.AntrianPerKategori:
|
||||
properties:
|
||||
@@ -137,6 +158,15 @@ definitions:
|
||||
kategori:
|
||||
type: string
|
||||
type: object
|
||||
diagnosa.DiagnosaModel:
|
||||
properties:
|
||||
jenisPenyakit:
|
||||
type: string
|
||||
kodeDiagnosa:
|
||||
type: string
|
||||
sebabPenyakit:
|
||||
type: string
|
||||
type: object
|
||||
dokter.DokterResponse:
|
||||
properties:
|
||||
hfis_code:
|
||||
@@ -319,6 +349,27 @@ paths:
|
||||
summary: Get Antrian Per Kategori
|
||||
tags:
|
||||
- Dashboard
|
||||
/reference/diagnosa/:
|
||||
get:
|
||||
parameters:
|
||||
- description: Search keyword
|
||||
in: query
|
||||
name: search
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/diagnosa.DiagnosaModel'
|
||||
type: array
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/shared.BaseErrorResponse'
|
||||
summary: Get List Diagnosa
|
||||
tags:
|
||||
- Reference
|
||||
/reference/dokter/:
|
||||
get:
|
||||
parameters:
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package diagnosa
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
baseResponse "antrian-operasi/internal/shared"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type DiagnosaHandler struct {
|
||||
repo IDiagnosaRepository
|
||||
}
|
||||
|
||||
func NewDiagnosaHandler(repo IDiagnosaRepository) DiagnosaHandler {
|
||||
return DiagnosaHandler{repo}
|
||||
}
|
||||
|
||||
// List Diagnosa godoc
|
||||
// @Summary Get List Diagnosa
|
||||
// @Tags Reference
|
||||
// @Param search query string false "Search keyword"
|
||||
// @Success 200 {object} []DiagnosaModel
|
||||
// @Failure 500 {object} shared.BaseErrorResponse
|
||||
// @Router /reference/diagnosa/ [get]
|
||||
func (h DiagnosaHandler) ListDiagnosa(c *gin.Context) {
|
||||
list, err := h.repo.SearchableListDiagnosa(c)
|
||||
if err != nil {
|
||||
errorResponse := baseResponse.BaseErrorResponse{
|
||||
Success: false,
|
||||
Code: 500,
|
||||
Message: err.Error(),
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, errorResponse)
|
||||
return
|
||||
}
|
||||
|
||||
response := baseResponse.ToBaseResponse(list.ToResponseList(), true, 200, "success get diagnosa")
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package diagnosa
|
||||
|
||||
type DiagnosaModel struct {
|
||||
KodeDiagnosa string `db:"icd_code"`
|
||||
JenisPenyakit string `db:"jenis_penyakit"`
|
||||
SebabPenyakit *string `db:"sebabpenyakit"`
|
||||
}
|
||||
|
||||
type DiagnosaResponse struct {
|
||||
KodeDiagnosa string `db:"kode_diagnosa"`
|
||||
Diagnosa string `db:"diagnosa"`
|
||||
}
|
||||
|
||||
func (m DiagnosaModel) ToResponse() DiagnosaResponse {
|
||||
return DiagnosaResponse{
|
||||
KodeDiagnosa: m.KodeDiagnosa,
|
||||
Diagnosa: m.JenisPenyakit,
|
||||
}
|
||||
}
|
||||
|
||||
type ListDiagnosaModel []DiagnosaModel
|
||||
|
||||
func (rows ListDiagnosaModel) ToResponseList() []DiagnosaResponse {
|
||||
result := make([]DiagnosaResponse, 0, len(rows))
|
||||
for _, item := range rows {
|
||||
result = append(result, item.ToResponse())
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package diagnosa
|
||||
|
||||
import (
|
||||
"antrian-operasi/internal/database"
|
||||
|
||||
queryUtils "antrian-operasi/internal/utils/query"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
const DB_NAME = "db_simrs"
|
||||
const TBL_NAME = "icd"
|
||||
|
||||
type IDiagnosaRepository interface {
|
||||
SearchableListDiagnosa(c *gin.Context) (ListDiagnosaModel, error)
|
||||
}
|
||||
|
||||
type diagnosaRepo struct {
|
||||
queryBuilder *queryUtils.QueryBuilder
|
||||
db database.Service
|
||||
}
|
||||
|
||||
func NewRepository(dbService database.Service) IDiagnosaRepository {
|
||||
queryBuilder := queryUtils.NewQueryBuilder(queryUtils.DBTypePostgreSQL).
|
||||
SetAllowedColumns([]string{
|
||||
"icd_code", "jenis_penyakit", "sebabpenyakit",
|
||||
}).
|
||||
SetSecurityOptions(false, 100)
|
||||
|
||||
return diagnosaRepo{
|
||||
queryBuilder: queryBuilder,
|
||||
db: dbService,
|
||||
}
|
||||
}
|
||||
|
||||
func (r diagnosaRepo) SearchableListDiagnosa(c *gin.Context) (ListDiagnosaModel, error) {
|
||||
var result ListDiagnosaModel
|
||||
search := c.Query("search")
|
||||
|
||||
query := queryUtils.DynamicQuery{
|
||||
From: TBL_NAME,
|
||||
Fields: []queryUtils.SelectField{
|
||||
{Expression: "icd_code"},
|
||||
{Expression: "jenis_penyakit"},
|
||||
{Expression: "sebabpenyakit"},
|
||||
},
|
||||
Limit: 10,
|
||||
}
|
||||
|
||||
if search != "" {
|
||||
searchFilters := []queryUtils.DynamicFilter{
|
||||
{Column: "icd_code", Operator: queryUtils.OpILike, Value: "%" + search + "%"},
|
||||
{Column: "jenis_penyakit", Operator: queryUtils.OpILike, Value: "%" + search + "%"},
|
||||
{Column: "sebabpenyakit", Operator: queryUtils.OpILike, Value: "%" + search + "%"},
|
||||
}
|
||||
query.Filters = append(query.Filters, queryUtils.FilterGroup{Filters: searchFilters, LogicOp: "OR"})
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package diagnosa
|
||||
|
||||
import (
|
||||
"antrian-operasi/internal/database"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func RegisterRoutes(r *gin.RouterGroup, dbService database.Service) {
|
||||
diagnosaRepo := NewRepository(dbService)
|
||||
DiagnosaHandler := NewDiagnosaHandler(diagnosaRepo)
|
||||
|
||||
kategori := r.Group("/diagnosa")
|
||||
{
|
||||
kategori.GET("", DiagnosaHandler.ListDiagnosa)
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"antrian-operasi/internal/database"
|
||||
antrianoperasi "antrian-operasi/internal/domain/antrian_operasi"
|
||||
"antrian-operasi/internal/domain/dashboard"
|
||||
"antrian-operasi/internal/domain/reference/diagnosa"
|
||||
"antrian-operasi/internal/domain/reference/dokter"
|
||||
"antrian-operasi/internal/domain/reference/kategori"
|
||||
"antrian-operasi/internal/domain/reference/pasien"
|
||||
@@ -42,6 +43,7 @@ func RegisterRoutes(cfg *config.Config, dbService database.Service) *gin.Engine
|
||||
spesialis.RegisterRoutes(reference, dbService)
|
||||
dokter.RegisterRoutes(reference, dbService)
|
||||
pasien.RegisterRoutes(reference, dbService)
|
||||
diagnosa.RegisterRoutes(reference, dbService)
|
||||
}
|
||||
dboard := api.Group("dashboard")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user