This commit is contained in:
2024-10-22 09:53:16 +07:00
parent 9b14389d7c
commit ab5303e55f
3 changed files with 29 additions and 13 deletions

2
.env
View File

@@ -15,7 +15,7 @@ USER_KEY_DEV=467a2817fde5070f66c9a41fbeb8dc2c
SECRET_KEY_DEV=8pP3D5431E
BASEURL_BPJS_DEV=https://apijkn-dev.bpjs-kesehatan.go.id/
SURAT_KONTROL_RS_DEV=vclaim-rest-dev
SURAT_KONTROL_RS=vclaim-rest
INSERT_SURAT_KONTROL=/RencanaKontrol/insert
UPDATE_SURAT_KONTROL=/RencanaKontrol/Update
DELETE_SURAT_KONTROL=/RencanaKontrol/Delete

View File

@@ -115,6 +115,11 @@ func GetDataSuratKontrol() ([]*suratkontrol.GetDataSuratKontrol, error) {
left join daftar_subspesialis ds on dp."Subspesialis" = ds."id"
where dsk."Status_surat_kontrol" = '1'`).Scan(&dataSurKon).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
errMsg := errors.New("DPJP anda belum ada subspesialis")
log.Println(errMsg)
return nil, errMsg
}
log.Println(err)
return nil, err
}
@@ -159,6 +164,11 @@ func GetDataSuratKontrolByID(idxdaftar string) (*suratkontrol.GetDataSuratKontro
left join daftar_subspesialis ds on dp."Subspesialis" = ds."id"
where dsk."Status_surat_kontrol" = '1' and dkp2."IDXDAFTAR" = ?`, idxdaftar).First(&dataSurKon).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
errMsg := errors.New("DPJP anda belum ada subspesialis")
log.Println(errMsg)
return nil, errMsg
}
log.Println(err)
return nil, err
}

View File

@@ -17,8 +17,8 @@ import (
)
func InsertSuratKontrol(c *gin.Context) {
baseUrl := os.Getenv("BASEURL_BPJS_DEV")
endpoint := os.Getenv("SURAT_KONTROL_RS_DEV")
baseUrl := os.Getenv("BASEURL_BPJS")
endpoint := os.Getenv("SURAT_KONTROL_RS")
param := os.Getenv("INSERT_SURAT_KONTROL")
url := baseUrl + endpoint + param
@@ -157,8 +157,8 @@ func InsertSuratKontrol(c *gin.Context) {
}
func UpdateSuratKontrol(c *gin.Context) {
baseUrl := os.Getenv("BASEURL_BPJS_DEV")
endpoint := os.Getenv("SURAT_KONTROL_RS_DEV")
baseUrl := os.Getenv("BASEURL_BPJS")
endpoint := os.Getenv("SURAT_KONTROL_RS")
param := os.Getenv("UPDATE_SURAT_KONTROL")
url := baseUrl + endpoint + param
@@ -299,8 +299,8 @@ func UpdateSuratKontrol(c *gin.Context) {
}
func DeleteSuratKontrol(c *gin.Context) {
baseUrl := os.Getenv("BASEURL_BPJS_DEV")
endpoint := os.Getenv("SURAT_KONTROL_RS_DEV")
baseUrl := os.Getenv("BASEURL_BPJS")
endpoint := os.Getenv("SURAT_KONTROL_RS")
param := os.Getenv("DELETE_SURAT_KONTROL")
url := baseUrl + endpoint + param
@@ -384,8 +384,8 @@ func DeleteSuratKontrol(c *gin.Context) {
}
func GetNomorSuratKontrol(c *gin.Context) {
baseUrl := os.Getenv("BASEURL_BPJS_DEV")
endpoint := os.Getenv("SURAT_KONTROL_RS_DEV")
baseUrl := os.Getenv("BASEURL_BPJS")
endpoint := os.Getenv("SURAT_KONTROL_RS")
param := os.Getenv("GET_NOMOR_SURAT_KONTROL")
noSurat := c.Param("noSuratKontrol")
url := baseUrl + endpoint + param + noSurat
@@ -414,8 +414,8 @@ func GetNomorSuratKontrol(c *gin.Context) {
}
func GetSuratKontrolBySEP(c *gin.Context) {
baseUrl := os.Getenv("BASEURL_BPJS_DEV")
endpoint := os.Getenv("SURAT_KONTROL_RS_DEV")
baseUrl := os.Getenv("BASEURL_BPJS")
endpoint := os.Getenv("SURAT_KONTROL_RS")
param := os.Getenv("GET_SURAT_KONTROL_SEP")
noSEP := c.Param("noSEP")
url := baseUrl + endpoint + param + noSEP
@@ -447,7 +447,10 @@ func GetDataSurKon(c *gin.Context) {
data, err := suratkontrol.GetDataSuratKontrol()
if err != nil {
log.Println(err)
c.JSON(http.StatusInternalServerError, err)
c.JSON(http.StatusInternalServerError, &sk.MetadataString{
Code: "",
Message: err.Error(),
})
return
}
var resSurKon []*sk.ResponseGetDataSuratKontrol
@@ -533,7 +536,10 @@ func PrintSurKon(c *gin.Context) {
data, err := suratkontrol.GetDataSuratKontrolByID(id)
if err != nil {
log.Println(err)
c.JSON(http.StatusInternalServerError, err)
c.JSON(http.StatusInternalServerError, &sk.MetadataString{
Code: "",
Message: err.Error(),
})
return
}