fix response postdata
This commit is contained in:
No files matched your search
@@ -101,5 +101,6 @@ func GetDataSuratKontrol() ([]*suratkontrol.GetDataSuratKontrol, error) {
|
||||
}
|
||||
|
||||
func UpdateDataSuratKontrol(reqUpdate *suratkontrol.UpdateDataSuratKontrol) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -205,6 +205,7 @@ func GetDokterByDPJP(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("Response :", res)
|
||||
c.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
@@ -262,5 +263,6 @@ func GetDokterBySpesialis(c *gin.Context) {
|
||||
HFISCode: v.HFISCode,
|
||||
})
|
||||
}
|
||||
log.Println("Response :", resDokter)
|
||||
c.JSON(http.StatusOK, resDokter)
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func PostData(url string, header *config.Header, headers map[string]string, requ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Println("Res: ", string(res))
|
||||
log.Println("Res:", string(res))
|
||||
|
||||
var resSuratKontrolRaw suratkontrol.ResponseInsertRaw
|
||||
err = json.Unmarshal([]byte(string(res)), &resSuratKontrolRaw)
|
||||
@@ -58,7 +58,7 @@ func PostData(url string, header *config.Header, headers map[string]string, requ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Println("metadata : ", resSuratKontrolRaw.MetaData.Code)
|
||||
log.Println("ResponseRaw : ", resSuratKontrolRaw)
|
||||
|
||||
responses := &suratkontrol.ResponseInsert{}
|
||||
if resSuratKontrolRaw.MetaData.Code != "200" {
|
||||
@@ -77,7 +77,7 @@ func PostData(url string, header *config.Header, headers map[string]string, requ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var resSuratKontrol *suratkontrol.ResponseSuratKontrol
|
||||
var resSuratKontrol suratkontrol.ResponseSuratKontrol
|
||||
|
||||
log.Println("dataresp: ", dataResp)
|
||||
|
||||
@@ -89,7 +89,7 @@ func PostData(url string, header *config.Header, headers map[string]string, requ
|
||||
|
||||
responses = &suratkontrol.ResponseInsert{
|
||||
MetaData: resSuratKontrolRaw.MetaData,
|
||||
Response: *resSuratKontrol,
|
||||
Response: resSuratKontrol,
|
||||
}
|
||||
|
||||
return responses, nil
|
||||
|
||||
@@ -49,7 +49,6 @@ func InsertSuratKontrol(c *gin.Context) {
|
||||
kunjunganPasien, err := suratkontrol.GetDataKunjunganPasien(req.IDXDaftar)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
c.JSON(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
reqSuratKontrol := &sk.RequestHeaderRencanaKontrol{
|
||||
@@ -63,7 +62,8 @@ func InsertSuratKontrol(c *gin.Context) {
|
||||
}
|
||||
res, err := PostData(url, header, headers, reqSuratKontrol)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, res)
|
||||
log.Println(err)
|
||||
c.JSON(http.StatusInternalServerError, res.MetaData)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ func InsertSuratKontrol(c *gin.Context) {
|
||||
Kelamin: res.Response.Kelamin,
|
||||
TglLahir: res.Response.TglLahir,
|
||||
NamaDiagnosa: res.Response.NamaDiagnosa,
|
||||
SusSpesialis: req.Subspesialis,
|
||||
SubSpesialis: req.Subspesialis,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ func UpdateSuratKontrol(c *gin.Context) {
|
||||
param := os.Getenv("UPDATE_SURAT_KONTROL")
|
||||
url := baseUrl + endpoint + param
|
||||
|
||||
var req sk.RequestUpdateRencanaKontrol
|
||||
var req sk.ReqUpdateRencanaKontrol
|
||||
|
||||
err := c.Bind(req)
|
||||
if err != nil {
|
||||
@@ -139,8 +139,8 @@ func UpdateSuratKontrol(c *gin.Context) {
|
||||
Request: &sk.ReqUpdateRencanaKontrol{
|
||||
NoSuratKontrol: req.NoSuratKontrol,
|
||||
NoSEP: req.NoSEP,
|
||||
KodeDokter: req.KodeHFIS,
|
||||
PoliKontrol: req.KodeHFIS,
|
||||
KodeDokter: req.KodeDokter,
|
||||
PoliKontrol: req.PoliKontrol,
|
||||
TglRencanaKontrol: req.TglRencanaKontrol,
|
||||
User: req.User,
|
||||
},
|
||||
@@ -171,50 +171,59 @@ func UpdateSuratKontrol(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
// func DeleteSuratKontrol(c *gin.Context) {
|
||||
// baseUrl := os.Getenv("BASEURL_BPJS_DEV")
|
||||
// endpoint := os.Getenv("SURAT_KONTROL_RS_DEV")
|
||||
// param := os.Getenv("UPDATE_SURAT_KONTROL")
|
||||
// url := baseUrl + endpoint + param
|
||||
func DeleteSuratKontrol(c *gin.Context) {
|
||||
baseUrl := os.Getenv("BASEURL_BPJS_DEV")
|
||||
endpoint := os.Getenv("SURAT_KONTROL_RS_DEV")
|
||||
param := os.Getenv("DELETE_SURAT_KONTROL")
|
||||
url := baseUrl + endpoint + param
|
||||
|
||||
// var req sk.RequestInsertRencanaKontrol
|
||||
var req sk.ReqDeleteRencanaKontrol
|
||||
|
||||
// err := c.Bind(req)
|
||||
// if err != nil {
|
||||
// log.Println(err)
|
||||
// c.JSON(http.StatusInternalServerError, err)
|
||||
// return
|
||||
// }
|
||||
err := c.Bind(req)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
c.JSON(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
// conf := config.ConfigBpjs{}
|
||||
conf := config.ConfigBpjs{}
|
||||
|
||||
// header := cfg.SetHeaderDev(conf)
|
||||
header := cfg.SetHeaderDev(conf)
|
||||
|
||||
// headers := map[string]string{
|
||||
// "X-cons-id": header.ConsID,
|
||||
// "X-timestamp": header.TimeStamp,
|
||||
// "X-signature": header.XSignature,
|
||||
// "user_key": header.UserKey,
|
||||
// "Content-Type": "Application/x-www-form-urlencoded",
|
||||
// }
|
||||
// log.Println("Headers : ", headers)
|
||||
headers := map[string]string{
|
||||
"X-cons-id": header.ConsID,
|
||||
"X-timestamp": header.TimeStamp,
|
||||
"X-signature": header.XSignature,
|
||||
"user_key": header.UserKey,
|
||||
"Content-Type": "Application/x-www-form-urlencoded",
|
||||
}
|
||||
log.Println("Headers : ", headers)
|
||||
|
||||
// request := &sk.RequestHeaderRencanaKontrol{
|
||||
// Request: &sk.RequestDeleteRencanaKontrol{
|
||||
// NoSuratKontrol: "",
|
||||
// User: "",
|
||||
// },
|
||||
// }
|
||||
request := &sk.RequestHeaderRencanaKontrol{
|
||||
Request: &sk.TSuratKontrol{
|
||||
RequestDelete: sk.RequestDeleteRencanaKontrol{
|
||||
NoSuratKontrol: req.NomorSurKon,
|
||||
User: req.User,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// res, err := ResponseDeleteSuratKontrol(url, header, headers, request)
|
||||
// if err != nil {
|
||||
// log.Printf("Error making external API request: %v", err)
|
||||
// c.JSON(http.StatusInternalServerError, err)
|
||||
// return
|
||||
// }
|
||||
res, err := ResponseDeleteSuratKontrol(url, header, headers, request)
|
||||
if err != nil {
|
||||
log.Printf("Error making external API request: %v", err)
|
||||
c.JSON(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
// c.JSON(http.StatusOK, res)
|
||||
// }
|
||||
// err = suratkontrol.UpdateDataSuratKontrol()
|
||||
// if err != nil {
|
||||
// log.Println(err)
|
||||
// c.JSON(http.StatusInternalServerError, err)
|
||||
// return
|
||||
// }
|
||||
|
||||
c.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
func GetNomorSuratKontrol(c *gin.Context) {
|
||||
baseUrl := os.Getenv("BASEURL_BPJS_DEV")
|
||||
|
||||
@@ -5,7 +5,9 @@ import (
|
||||
"bridging-rssa/handlers/bpjs"
|
||||
"bridging-rssa/handlers/bpjs/jadwal_dokter"
|
||||
suratkontrol "bridging-rssa/handlers/bpjs/surat_kontrol"
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
_ "bridging-rssa/docs"
|
||||
|
||||
@@ -33,6 +35,7 @@ func main() {
|
||||
r := gin.Default()
|
||||
|
||||
v1 := r.Group("/api")
|
||||
r.POST("/test", testHandler)
|
||||
|
||||
subspesialis := v1.Group("/subspesialis")
|
||||
{
|
||||
@@ -53,8 +56,8 @@ func main() {
|
||||
suratKontrol.GET("/noSuratKontrol/:noSuratKontrol", suratkontrol.GetNomorSuratKontrol)
|
||||
suratKontrol.GET("/noSEP/:noSEP", suratkontrol.GetSuratKontrolBySEP)
|
||||
suratKontrol.POST("/insert", suratkontrol.InsertSuratKontrol)
|
||||
// suratKontrol.PUT("/update", suratkontrol.UpdateSuratKontrol)
|
||||
// suratKontrol.DELETE("/delete", suratkontrol.UpdateSuratKontrol)
|
||||
suratKontrol.PUT("/update", suratkontrol.UpdateSuratKontrol)
|
||||
suratKontrol.DELETE("/delete", suratkontrol.DeleteSuratKontrol)
|
||||
}
|
||||
|
||||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
@@ -67,9 +70,14 @@ func main() {
|
||||
AllowHeaders: []string{"Origin", "Content-Type"},
|
||||
AllowCredentials: true,
|
||||
}))
|
||||
|
||||
log.Println("JALAN DI PORT : 8080")
|
||||
err = r.Run(":8080")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
func testHandler(c *gin.Context) {
|
||||
err := errors.New("Nomor SEP tidak ditemukan")
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
}
|
||||
@@ -31,6 +31,12 @@ type RequestInsertRencanaKontrol struct {
|
||||
User string `json:"user"`
|
||||
}
|
||||
|
||||
type ReqDeleteRencanaKontrol struct {
|
||||
IDDataSurKon string `json:"id"`
|
||||
NomorSurKon string `json:"Nomor_surat_kontrol"`
|
||||
User string `json:"user"`
|
||||
}
|
||||
|
||||
type RequestUpdateRencanaKontrol struct {
|
||||
NoSuratKontrol string `json:"noSuratKontrol"`
|
||||
NoSEP string `json:"noSEP"`
|
||||
@@ -40,8 +46,11 @@ type RequestUpdateRencanaKontrol struct {
|
||||
User string `json:"user"`
|
||||
}
|
||||
|
||||
type TSuratKontrol struct {
|
||||
RequestDelete RequestDeleteRencanaKontrol `json:"t_suratkontrol"`
|
||||
}
|
||||
|
||||
type RequestDeleteRencanaKontrol struct {
|
||||
TSuratKontrol string `json:"t_suratkontrol"`
|
||||
NoSuratKontrol string `json:"noSuratKontrol"`
|
||||
User string `json:"user"`
|
||||
}
|
||||
@@ -63,7 +72,7 @@ type Metadata struct {
|
||||
|
||||
type ResponseInsertRaw struct {
|
||||
Response string `json:"response"`
|
||||
MetaData MetadataString `json:"metadata"`
|
||||
MetaData MetadataString `json:"metaData"`
|
||||
}
|
||||
|
||||
type MetadataString struct {
|
||||
@@ -95,7 +104,7 @@ type ResponseData struct {
|
||||
Kelamin string `json:"kelamin"`
|
||||
TglLahir string `json:"tglLahir"`
|
||||
NamaDiagnosa string `json:"namaDiagnosa"`
|
||||
SusSpesialis string `json:"subspesialis"`
|
||||
SubSpesialis string `json:"subspesialis"`
|
||||
}
|
||||
|
||||
type ResponseSuratKontrol struct {
|
||||
|
||||
Reference in New Issue
Block a user