Perbaikan Lanjutan
This commit is contained in:
@@ -11,6 +11,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@@ -21,6 +23,7 @@ type Config struct {
|
||||
Bpjs BpjsConfig
|
||||
SatuSehat SatuSehatConfig
|
||||
Swagger SwaggerConfig
|
||||
Validator *validator.Validate
|
||||
}
|
||||
|
||||
type SwaggerConfig struct {
|
||||
@@ -173,6 +176,9 @@ func LoadConfig() *Config {
|
||||
},
|
||||
}
|
||||
|
||||
// Initialize validator
|
||||
config.Validator = validator.New()
|
||||
|
||||
// Load database configurations
|
||||
config.loadDatabaseConfigs()
|
||||
|
||||
|
||||
510
internal/handlers/test.txt/sw
Normal file
510
internal/handlers/test.txt/sw
Normal file
@@ -0,0 +1,510 @@
|
||||
// Code generated by generate-dynamic-handler.go DO NOT EDIT.
|
||||
// Generated at 2025-09-01 13:38:57
|
||||
// Service: VClaim (vclaim)
|
||||
// Description: BPJS VClaim service for eligibility and SEP management
|
||||
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"api-service/internal/config"
|
||||
"api-service/internal/models"
|
||||
"api-service/internal/models/vclaim/peserta"
|
||||
"api-service/internal/models/vclaim/sep"
|
||||
"api-service/internal/services"
|
||||
"api-service/pkg/logger"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// VClaimHandler handles VClaim BPJS services
|
||||
type VClaimHandler struct {
|
||||
service services.VClaimService
|
||||
validator *validator.Validate
|
||||
logger logger.Logger
|
||||
config config.BpjsConfig
|
||||
}
|
||||
|
||||
// VClaimHandlerConfig contains configuration for VClaimHandler
|
||||
type VClaimHandlerConfig struct {
|
||||
BpjsConfig config.BpjsConfig
|
||||
Logger logger.Logger
|
||||
Validator *validator.Validate
|
||||
}
|
||||
|
||||
// NewVClaimHandler creates a new VClaimHandler
|
||||
func NewVClaimHandler(cfg VClaimHandlerConfig) *VClaimHandler {
|
||||
return &VClaimHandler{
|
||||
service: services.NewService(cfg.BpjsConfig),
|
||||
validator: cfg.Validator,
|
||||
logger: cfg.Logger,
|
||||
config: cfg.BpjsConfig,
|
||||
}
|
||||
}
|
||||
|
||||
// GetPesertaBynokartu godoc
|
||||
// @Summary Get participant data by card number
|
||||
// @Description Get participant eligibility information from BPJS by card number
|
||||
// @Tags vclaim,peserta
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
// @Param nokartu path string true "BPJS card number" example("0000054321654")
|
||||
// @Success 200 {object} peserta.PesertaResponse "Successfully retrieved participant data"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid card number format"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 404 {object} models.ErrorResponseBpjs "Not found - participant not found"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /peserta/{nokartu} [get]
|
||||
func (h *VClaimHandler) GetPesertaBynokartu(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// Generate request ID if not present
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing GetPesertaBynokartu request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
"endpoint": "peserta/{nokartu}",
|
||||
"nokartu": c.Param("nokartu"),
|
||||
})
|
||||
|
||||
// Extract path parameters
|
||||
nokartu := c.Param("nokartu")
|
||||
if nokartu == "" {
|
||||
h.logger.Error("Missing required parameter: nokartu", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter: nokartu",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response peserta.PesertaResponse
|
||||
endpoint := "peserta/{nokartu}"
|
||||
endpoint = strings.Replace(endpoint, "{nokartu}", nokartu, 1)
|
||||
|
||||
err := h.service.Get(ctx, endpoint, &response)
|
||||
if err != nil {
|
||||
h.logger.Error("Failed to get PesertaBynokartu", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// GetPesertaBynik godoc
|
||||
// @Summary Get participant data by NIK
|
||||
// @Description Get participant eligibility information from BPJS by National ID Number (NIK)
|
||||
// @Tags vclaim,peserta
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
// @Param nik path string true "National ID Number (NIK)" example("3201234567890123")
|
||||
// @Success 200 {object} peserta.PesertaResponse "Successfully retrieved participant data"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid NIK format"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 404 {object} models.ErrorResponseBpjs "Not found - participant not found"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /peserta/nik/{nik} [get]
|
||||
func (h *VClaimHandler) GetPesertaBynik(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// Generate request ID if not present
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing GetPesertaBynik request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
"endpoint": "peserta/nik/{nik}",
|
||||
"nik": c.Param("nik"),
|
||||
})
|
||||
|
||||
// Extract path parameters
|
||||
nik := c.Param("nik")
|
||||
if nik == "" {
|
||||
h.logger.Error("Missing required parameter: nik", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter: nik",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response peserta.PesertaResponse
|
||||
endpoint := "peserta/nik/{nik}"
|
||||
endpoint = strings.Replace(endpoint, "{nik}", nik, 1)
|
||||
|
||||
err := h.service.Get(ctx, endpoint, &response)
|
||||
if err != nil {
|
||||
h.logger.Error("Failed to get PesertaBynik", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// GetSepSep godoc
|
||||
// @Summary Get SEP data by number
|
||||
// @Description Get SEP (Surat Eligibilitas Peserta) information by SEP number
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
// @Param nosep path string true "SEP Number" example("0301R0010717V000001")
|
||||
// @Success 200 {object} sep.SepResponse "Successfully retrieved SEP data"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid SEP number format"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 404 {object} models.ErrorResponseBpjs "Not found - SEP not found"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /sep/{nosep} [get]
|
||||
func (h *VClaimHandler) GetSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// Generate request ID if not present
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing GetSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
"endpoint": "sep/{nosep}",
|
||||
"nosep": c.Param("nosep"),
|
||||
})
|
||||
|
||||
// Extract path parameters
|
||||
nosep := c.Param("nosep")
|
||||
if nosep == "" {
|
||||
h.logger.Error("Missing required parameter: nosep", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter: nosep",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response sep.SepResponse
|
||||
endpoint := "sep/{nosep}"
|
||||
endpoint = strings.Replace(endpoint, "{nosep}", nosep, 1)
|
||||
|
||||
err := h.service.Get(ctx, endpoint, &response)
|
||||
if err != nil {
|
||||
h.logger.Error("Failed to get SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// CreateSepSep godoc
|
||||
// @Summary Create new SEP
|
||||
// @Description Create a new SEP (Surat Eligibilitas Peserta) for participant
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
// @Param request body sep.SepRequest true "SEP creation data"
|
||||
// @Success 201 {object} sep.SepResponse "Successfully created SEP"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid request body or validation error"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 409 {object} models.ErrorResponseBpjs "Conflict - SEP already exists"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /sep [post]
|
||||
func (h *VClaimHandler) CreateSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing CreateSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
var req sep.SepRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
h.logger.Error("Invalid request body", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Invalid request body: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Validate request
|
||||
if err := h.validator.Struct(&req); err != nil {
|
||||
h.logger.Error("Validation failed", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Validation failed: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response sep.SepResponse
|
||||
err := h.service.Post(ctx, "sep", &req, &response)
|
||||
if err != nil {
|
||||
h.logger.Error("Failed to create SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
|
||||
c.JSON(http.StatusCreated, response)
|
||||
}
|
||||
|
||||
// UpdateSepSep godoc
|
||||
// @Summary Update existing SEP
|
||||
// @Description Update an existing SEP (Surat Eligibilitas Peserta) by SEP number
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
// @Param nosep path string true "SEP Number to update" example("0301R0010717V000001")
|
||||
// @Param request body sep.SepRequest true "SEP update data"
|
||||
// @Success 200 {object} sep.SepResponse "Successfully updated SEP"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid request body or validation error"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 404 {object} models.ErrorResponseBpjs "Not found - SEP not found"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /sep/{nosep} [put]
|
||||
func (h *VClaimHandler) UpdateSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing UpdateSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
nosep := c.Param("nosep")
|
||||
if nosep == "" {
|
||||
h.logger.Error("Missing required parameter: nosep", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter: nosep",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var req sep.SepRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
h.logger.Error("Invalid request body", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Invalid request body: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Validate request
|
||||
if err := h.validator.Struct(&req); err != nil {
|
||||
h.logger.Error("Validation failed", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Validation failed: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response sep.SepResponse
|
||||
endpoint := "sep/{nosep}"
|
||||
endpoint = strings.Replace(endpoint, "{nosep}", nosep, 1)
|
||||
|
||||
err := h.service.Put(ctx, endpoint, &req, &response)
|
||||
if err != nil {
|
||||
h.logger.Error("Failed to update SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// DeleteSepSep godoc
|
||||
// @Summary Delete SEP
|
||||
// @Description Delete an existing SEP (Surat Eligibilitas Peserta) by SEP number
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
// @Param nosep path string true "SEP Number to delete" example("0301R0010717V000001")
|
||||
// @Success 200 {object} sep.SepResponse "Successfully deleted SEP"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid SEP number format"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 404 {object} models.ErrorResponseBpjs "Not found - SEP not found"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /sep/{nosep} [delete]
|
||||
func (h *VClaimHandler) DeleteSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing DeleteSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
nosep := c.Param("nosep")
|
||||
if nosep == "" {
|
||||
h.logger.Error("Missing required parameter: nosep", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter: nosep",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response sep.SepResponse
|
||||
endpoint := "sep/{nosep}"
|
||||
endpoint = strings.Replace(endpoint, "{nosep}", nosep, 1)
|
||||
|
||||
err := h.service.Delete(ctx, endpoint, &response)
|
||||
if err != nil {
|
||||
h.logger.Error("Failed to delete SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
543
internal/handlers/test.txt/vclaim.backup
Normal file
543
internal/handlers/test.txt/vclaim.backup
Normal file
@@ -0,0 +1,543 @@
|
||||
// Code generated by generate-dynamic-handler.go; DO NOT EDIT.
|
||||
// Generated at: 2025-09-01 13:38:57
|
||||
// Service: VClaim (vclaim)
|
||||
// Description: BPJS VClaim service for eligibility and SEP management
|
||||
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"api-service/internal/config"
|
||||
"api-service/internal/models"
|
||||
"api-service/internal/models/vclaim/peserta"
|
||||
"api-service/internal/models/vclaim/sep"
|
||||
services "api-service/internal/services/bpjs"
|
||||
"api-service/pkg/logger"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// VClaimHandler handles VClaim BPJS services
|
||||
type VClaimHandler struct {
|
||||
service services.VClaimService
|
||||
validator *validator.Validate
|
||||
logger logger.Logger
|
||||
config config.BpjsConfig
|
||||
}
|
||||
|
||||
// VClaimHandlerConfig contains configuration for VClaimHandler
|
||||
type VClaimHandlerConfig struct {
|
||||
BpjsConfig config.BpjsConfig
|
||||
Logger logger.Logger
|
||||
Validator *validator.Validate
|
||||
}
|
||||
|
||||
// NewVClaimHandler creates a new VClaimHandler
|
||||
func NewVClaimHandler(cfg VClaimHandlerConfig) *VClaimHandler {
|
||||
return &VClaimHandler{
|
||||
service: services.NewService(cfg.BpjsConfig),
|
||||
validator: cfg.Validator,
|
||||
logger: cfg.Logger,
|
||||
config: cfg.BpjsConfig,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
GetPesertaBynokartu godoc
|
||||
@Summary Get PesertaBynokartu data
|
||||
@Description Get participant eligibility information by card number
|
||||
@Tags vclaim,peserta,nokartu
|
||||
@Accept json
|
||||
@Produce json
|
||||
@Param nokartu path string true "nokartu"
|
||||
@Success 200 {object} peserta.PesertaResponse
|
||||
@Failure 400 {object} models.ErrorResponseBpjs
|
||||
@Failure 500 {object} models.ErrorResponseBpjs
|
||||
@Router /peserta/:nokartu [get]
|
||||
*/
|
||||
func (h *VClaimHandler) GetPesertaBynokartu(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// Generate request ID if not present
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing GetPesertaBynokartu request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
"endpoint": "/peserta/:nokartu",
|
||||
|
||||
"nokartu": c.Param("nokartu"),
|
||||
})
|
||||
|
||||
// Extract path parameters
|
||||
|
||||
nokartu := c.Param("nokartu")
|
||||
if nokartu == "" {
|
||||
|
||||
h.logger.Error("Missing required parameter nokartu", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter nokartu",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response peserta.PesertaResponse
|
||||
|
||||
endpoint := "/peserta/:nokartu"
|
||||
|
||||
endpoint = strings.Replace(endpoint, ":nokartu", nokartu, 1)
|
||||
|
||||
err := h.service.Get(ctx, endpoint, &response)
|
||||
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to get PesertaBynokartu", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
/*
|
||||
GetPesertaBynik godoc
|
||||
@Summary Get PesertaBynik data
|
||||
@Description Get participant eligibility information by NIK
|
||||
@Tags vclaim,peserta,nik
|
||||
@Accept json
|
||||
@Produce json
|
||||
@Param nik path string true "nik"
|
||||
@Success 200 {object} peserta.PesertaResponse
|
||||
@Failure 400 {object} models.ErrorResponseBpjs
|
||||
@Failure 500 {object} models.ErrorResponseBpjs
|
||||
@Router /peserta/nik/:nik [get]
|
||||
*/
|
||||
func (h *VClaimHandler) GetPesertaBynik(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// Generate request ID if not present
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing GetPesertaBynik request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
"endpoint": "/peserta/nik/:nik",
|
||||
|
||||
"nik": c.Param("nik"),
|
||||
})
|
||||
|
||||
// Extract path parameters
|
||||
|
||||
nik := c.Param("nik")
|
||||
if nik == "" {
|
||||
|
||||
h.logger.Error("Missing required parameter nik", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter nik",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response peserta.PesertaResponse
|
||||
|
||||
endpoint := "/peserta/nik/:nik"
|
||||
|
||||
endpoint = strings.Replace(endpoint, ":nik", nik, 1)
|
||||
|
||||
err := h.service.Get(ctx, endpoint, &response)
|
||||
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to get PesertaBynik", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
/*
|
||||
GetSepSep godoc
|
||||
@Summary Get SepSep data
|
||||
@Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
@Tags vclaim,sep
|
||||
@Accept json
|
||||
@Produce json
|
||||
@Param nosep path string true "nosep"
|
||||
@Success 200 {object} sep.SepResponse
|
||||
@Failure 400 {object} models.ErrorResponseBpjs
|
||||
@Failure 500 {object} models.ErrorResponseBpjs
|
||||
@Router /sep/:nosep [get]
|
||||
*/
|
||||
func (h *VClaimHandler) GetSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// Generate request ID if not present
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing GetSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
"endpoint": "/sep/:nosep",
|
||||
|
||||
"nosep": c.Param("nosep"),
|
||||
})
|
||||
|
||||
// Extract path parameters
|
||||
|
||||
nosep := c.Param("nosep")
|
||||
if nosep == "" {
|
||||
|
||||
h.logger.Error("Missing required parameter nosep", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter nosep",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response sep.SepResponse
|
||||
|
||||
endpoint := "/sep/:nosep"
|
||||
|
||||
endpoint = strings.Replace(endpoint, ":nosep", nosep, 1)
|
||||
|
||||
err := h.service.Get(ctx, endpoint, &response)
|
||||
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to get SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
/*
|
||||
CreateSepSep godoc
|
||||
@Summary Create SepSep
|
||||
@Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
@Tags vclaim,sep
|
||||
@Accept json
|
||||
@Produce json
|
||||
@Param request body sep.SepRequest true "SepSep data"
|
||||
@Success 201 {object} sep.SepResponse
|
||||
@Failure 400 {object} models.ErrorResponseBpjs
|
||||
@Failure 500 {object} models.ErrorResponseBpjs
|
||||
@Router /sep [post]
|
||||
*/
|
||||
func (h *VClaimHandler) CreateSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing CreateSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
var req sep.SepRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
|
||||
h.logger.Error("Invalid request body", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Invalid request body: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Validate request
|
||||
if err := h.validator.Struct(&req); err != nil {
|
||||
|
||||
h.logger.Error("Validation failed", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Validation failed: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response sep.SepResponse
|
||||
err := h.service.Post(ctx, "/sep", &req, &response)
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to create SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
c.JSON(http.StatusCreated, response)
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateSepSep godoc
|
||||
@Summary Update SepSep
|
||||
@Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
@Tags vclaim,sep
|
||||
@Accept json
|
||||
@Produce json
|
||||
@Param nosep path string true "nosep"
|
||||
@Param request body sep.SepRequest true "SepSep data"
|
||||
@Success 200 {object} sep.SepResponse
|
||||
@Failure 400 {object} models.ErrorResponseBpjs
|
||||
@Failure 500 {object} models.ErrorResponseBpjs
|
||||
@Router /sep/:nosep [put]
|
||||
*/
|
||||
func (h *VClaimHandler) UpdateSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing UpdateSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
nosep := c.Param("nosep")
|
||||
if nosep == "" {
|
||||
|
||||
h.logger.Error("Missing required parameter nosep", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter nosep",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var req sep.SepRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
|
||||
h.logger.Error("Invalid request body", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Invalid request body: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Validate request
|
||||
if err := h.validator.Struct(&req); err != nil {
|
||||
|
||||
h.logger.Error("Validation failed", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Validation failed: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response sep.SepResponse
|
||||
|
||||
endpoint := "/sep/:nosep"
|
||||
|
||||
endpoint = strings.Replace(endpoint, ":nosep", nosep, 1)
|
||||
|
||||
err := h.service.Put(ctx, endpoint, &req, &response)
|
||||
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to update SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteSepSep godoc
|
||||
@Summary Delete SepSep
|
||||
@Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
@Tags vclaim,sep
|
||||
@Accept json
|
||||
@Produce json
|
||||
@Param nosep path string true "nosep"
|
||||
@Success 200 {object} sep.SepResponse
|
||||
@Failure 400 {object} models.ErrorResponseBpjs
|
||||
@Failure 500 {object} models.ErrorResponseBpjs
|
||||
@Router /sep/:nosep [delete]
|
||||
*/
|
||||
func (h *VClaimHandler) DeleteSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing DeleteSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
nosep := c.Param("nosep")
|
||||
if nosep == "" {
|
||||
|
||||
h.logger.Error("Missing required parameter nosep", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter nosep",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response sep.SepResponse
|
||||
|
||||
endpoint := "/sep/:nosep"
|
||||
|
||||
endpoint = strings.Replace(endpoint, ":nosep", nosep, 1)
|
||||
|
||||
err := h.service.Delete(ctx, endpoint, &response)
|
||||
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to delete SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
// Code generated by generate-dynamic-handler.go; DO NOT EDIT.
|
||||
// Generated at: 2025-09-01 11:57:39
|
||||
|
||||
// Service: VClaim (vclaim)
|
||||
// Description: BPJS VClaim service for eligibility and SEP management
|
||||
|
||||
@@ -7,11 +6,15 @@ package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"api-service/internal/config"
|
||||
"api-service/internal/models/reference"
|
||||
"api-service/internal/models"
|
||||
"api-service/internal/models/vclaim/peserta"
|
||||
"api-service/internal/models/vclaim/sep"
|
||||
"api-service/internal/services/bpjs"
|
||||
"api-service/pkg/logger"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -19,22 +22,9 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// VClaimService defines VClaim service interface
|
||||
type VClaimService interface {
|
||||
GetPeserta(ctx context.Context, nokartu string) (*reference.PesertaData, error)
|
||||
|
||||
GetSep(ctx context.Context, nosep string) (*reference.SepData, error)
|
||||
|
||||
CreateSep(ctx context.Context, req *reference.SepRequest) (*reference.SepData, error)
|
||||
|
||||
UpdateSep(ctx context.Context, nosep string, req *reference.SepRequest) (*reference.SepData, error)
|
||||
|
||||
DeleteSep(ctx context.Context, nosep string) error
|
||||
}
|
||||
|
||||
// VClaimHandler handles VClaim BPJS services
|
||||
type VClaimHandler struct {
|
||||
service VClaimService
|
||||
service services.VClaimService
|
||||
validator *validator.Validate
|
||||
logger logger.Logger
|
||||
config config.BpjsConfig
|
||||
@@ -48,31 +38,34 @@ type VClaimHandlerConfig struct {
|
||||
}
|
||||
|
||||
// NewVClaimHandler creates a new VClaimHandler
|
||||
func NewVClaimHandler(cfg VClaimHandlerConfig, service VClaimService) *VClaimHandler {
|
||||
func NewVClaimHandler(cfg VClaimHandlerConfig) *VClaimHandler {
|
||||
return &VClaimHandler{
|
||||
service: service,
|
||||
service: services.NewService(cfg.BpjsConfig),
|
||||
validator: cfg.Validator,
|
||||
logger: cfg.Logger,
|
||||
config: cfg.BpjsConfig,
|
||||
}
|
||||
}
|
||||
|
||||
// GetPESERTA retrieves Peserta data
|
||||
|
||||
// @Summary Get Peserta data
|
||||
// @Description Get participant eligibility information
|
||||
// @Tags vclaim,peserta
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// GetPESERTABYNIK godoc
|
||||
// @Summary Get PesertaBynik data
|
||||
// @Description Get participant eligibility information by NIK
|
||||
// @Tags vclaim,peserta,nik
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
|
||||
// @Param nokartu path string true "nokartu"
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
|
||||
// @Success 200 {object} reference.PesertaResponse
|
||||
// @Failure 400 {object} reference.ErrorResponse
|
||||
// @Failure 500 {object} reference.ErrorResponse
|
||||
// @Router /peserta/:nokartu [get]
|
||||
// @Param nik path string true "nik" example("example_value")
|
||||
|
||||
func (h *VClaimHandler) GetPeserta(c *gin.Context) {
|
||||
// @Success 200 {object} peserta.PesertaResponse "Successfully retrieved PesertaBynik data"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid parameters"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 404 {object} models.ErrorResponseBpjs "Not found - PesertaBynik not found"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /peserta/nik/:nik [get]
|
||||
func (h *VClaimHandler) GetPesertaBynik(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
@@ -83,43 +76,145 @@ func (h *VClaimHandler) GetPeserta(c *gin.Context) {
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing GetPeserta request", map[string]interface{}{
|
||||
|
||||
h.logger.Info("Processing GetPesertaBynik request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
"endpoint": "/peserta/:nokartu",
|
||||
|
||||
"nokartu": c.Param("nokartu"),
|
||||
"endpoint": "/peserta/nik/:nik",
|
||||
|
||||
"nik": c.Param("nik"),
|
||||
|
||||
})
|
||||
|
||||
|
||||
// Extract path parameters
|
||||
|
||||
nik := c.Param("nik")
|
||||
if nik == "" {
|
||||
|
||||
h.logger.Error("Missing required parameter nik", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter nik",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Call service method
|
||||
var response peserta.PesertaResponse
|
||||
|
||||
endpoint := "/peserta/nik/:nik"
|
||||
|
||||
endpoint = strings.Replace(endpoint, ":nik", nik, 1)
|
||||
|
||||
err := h.service.Get(ctx, endpoint, &response)
|
||||
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to get PesertaBynik", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// GetPESERTABYNOKARTU godoc
|
||||
// @Summary Get PesertaBynokartu data
|
||||
// @Description Get participant eligibility information by card number
|
||||
// @Tags vclaim,peserta,nokartu
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
|
||||
// @Param nokartu path string true "nokartu" example("example_value")
|
||||
|
||||
// @Success 200 {object} peserta.PesertaResponse "Successfully retrieved PesertaBynokartu data"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid parameters"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 404 {object} models.ErrorResponseBpjs "Not found - PesertaBynokartu not found"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /peserta/:nokartu [get]
|
||||
func (h *VClaimHandler) GetPesertaBynokartu(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// Generate request ID if not present
|
||||
requestID := c.GetHeader("X-Request-ID")
|
||||
if requestID == "" {
|
||||
requestID = uuid.New().String()
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
|
||||
h.logger.Info("Processing GetPesertaBynokartu request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
"endpoint": "/peserta/:nokartu",
|
||||
|
||||
"nokartu": c.Param("nokartu"),
|
||||
|
||||
})
|
||||
|
||||
|
||||
// Extract path parameters
|
||||
|
||||
nokartu := c.Param("nokartu")
|
||||
if nokartu == "" {
|
||||
|
||||
|
||||
h.logger.Error("Missing required parameter nokartu", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter nokartu",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Call service method
|
||||
var response reference.PesertaResponse
|
||||
|
||||
result, err := h.service.GetPeserta(ctx, nokartu)
|
||||
|
||||
var response peserta.PesertaResponse
|
||||
|
||||
endpoint := "/peserta/:nokartu"
|
||||
|
||||
endpoint = strings.Replace(endpoint, ":nokartu", nokartu, 1)
|
||||
|
||||
err := h.service.Get(ctx, endpoint, &response)
|
||||
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to get Peserta", map[string]interface{}{
|
||||
|
||||
h.logger.Error("Failed to get PesertaBynokartu", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
@@ -130,26 +225,35 @@ func (h *VClaimHandler) GetPeserta(c *gin.Context) {
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
response.Data = result
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// GetSEP retrieves Sep data
|
||||
|
||||
// @Summary Get Sep data
|
||||
// @Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
|
||||
// @Param nosep path string true "nosep"
|
||||
|
||||
// @Success 200 {object} reference.SepResponse
|
||||
// @Failure 400 {object} reference.ErrorResponse
|
||||
// @Failure 500 {object} reference.ErrorResponse
|
||||
// @Router /sep/:nosep [get]
|
||||
|
||||
func (h *VClaimHandler) GetSep(c *gin.Context) {
|
||||
|
||||
|
||||
|
||||
|
||||
// GetSEPSEP godoc
|
||||
// @Summary Get SepSep data
|
||||
// @Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
|
||||
// @Param nosep path string true "nosep" example("example_value")
|
||||
|
||||
// @Success 200 {object} sep.SepResponse "Successfully retrieved SepSep data"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid parameters"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 404 {object} models.ErrorResponseBpjs "Not found - SepSep not found"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /sep/:nosep [get]
|
||||
func (h *VClaimHandler) GetSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
@@ -160,43 +264,51 @@ func (h *VClaimHandler) GetSep(c *gin.Context) {
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing GetSep request", map[string]interface{}{
|
||||
|
||||
h.logger.Info("Processing GetSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
"endpoint": "/sep/:nosep",
|
||||
|
||||
|
||||
"nosep": c.Param("nosep"),
|
||||
|
||||
})
|
||||
|
||||
|
||||
// Extract path parameters
|
||||
|
||||
|
||||
nosep := c.Param("nosep")
|
||||
if nosep == "" {
|
||||
|
||||
|
||||
h.logger.Error("Missing required parameter nosep", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter nosep",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Call service method
|
||||
var response reference.SepResponse
|
||||
|
||||
result, err := h.service.GetSep(ctx, nosep)
|
||||
|
||||
var response sep.SepResponse
|
||||
|
||||
endpoint := "/sep/:nosep"
|
||||
|
||||
endpoint = strings.Replace(endpoint, ":nosep", nosep, 1)
|
||||
|
||||
err := h.service.Get(ctx, endpoint, &response)
|
||||
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to get Sep", map[string]interface{}{
|
||||
|
||||
h.logger.Error("Failed to get SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
@@ -207,25 +319,27 @@ func (h *VClaimHandler) GetSep(c *gin.Context) {
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
response.Data = result
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// CreateSEP creates new Sep
|
||||
|
||||
// @Summary Create Sep
|
||||
// @Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
|
||||
// @Param request body reference.SepRequest true "Sep data"
|
||||
// @Success 201 {object} reference.SepResponse
|
||||
// @Failure 400 {object} reference.ErrorResponse
|
||||
// @Failure 500 {object} reference.ErrorResponse
|
||||
// @Router /sep [post]
|
||||
// CreateSEPSEP godoc
|
||||
// @Summary Create new SepSep
|
||||
// @Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
|
||||
func (h *VClaimHandler) CreateSep(c *gin.Context) {
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
// @Param request body sep.SepRequest true "SepSep data"
|
||||
// @Success 201 {object} sep.SepResponse "Successfully created SepSep"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid request body or validation error"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 409 {object} models.ErrorResponseBpjs "Conflict - SepSep already exists"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /sep [post]
|
||||
func (h *VClaimHandler) CreateSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
@@ -235,19 +349,21 @@ func (h *VClaimHandler) CreateSep(c *gin.Context) {
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing CreateSep request", map[string]interface{}{
|
||||
|
||||
h.logger.Info("Processing CreateSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
|
||||
var req reference.SepRequest
|
||||
var req sep.SepRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
|
||||
|
||||
h.logger.Error("Invalid request body", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Invalid request body: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
@@ -257,13 +373,13 @@ func (h *VClaimHandler) CreateSep(c *gin.Context) {
|
||||
|
||||
// Validate request
|
||||
if err := h.validator.Struct(&req); err != nil {
|
||||
|
||||
|
||||
h.logger.Error("Validation failed", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Validation failed: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
@@ -272,16 +388,16 @@ func (h *VClaimHandler) CreateSep(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response reference.SepResponse
|
||||
result, err := h.service.CreateSep(ctx, &req)
|
||||
var response sep.SepResponse
|
||||
err := h.service.Post(ctx, "/sep", &req, &response)
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to create Sep", map[string]interface{}{
|
||||
|
||||
h.logger.Error("Failed to create SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
@@ -292,27 +408,30 @@ func (h *VClaimHandler) CreateSep(c *gin.Context) {
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
response.Data = result
|
||||
c.JSON(http.StatusCreated, response)
|
||||
}
|
||||
|
||||
// UpdateSEP updates existing Sep
|
||||
|
||||
// @Summary Update Sep
|
||||
// @Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
|
||||
// @Param nosep path string true "nosep"
|
||||
// UpdateSEPSEP godoc
|
||||
// @Summary Update existing SepSep
|
||||
// @Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
|
||||
// @Param request body reference.SepRequest true "Sep data"
|
||||
// @Success 200 {object} reference.SepResponse
|
||||
// @Failure 400 {object} reference.ErrorResponse
|
||||
// @Failure 500 {object} reference.ErrorResponse
|
||||
// @Router /sep/:nosep [put]
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
|
||||
func (h *VClaimHandler) UpdateSep(c *gin.Context) {
|
||||
// @Param nosep path string true "nosep" example("example_value")
|
||||
|
||||
// @Param request body sep.SepRequest true "SepSep data"
|
||||
// @Success 200 {object} sep.SepResponse "Successfully updated SepSep"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid parameters or request body"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 404 {object} models.ErrorResponseBpjs "Not found - SepSep not found"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /sep/:nosep [put]
|
||||
func (h *VClaimHandler) UpdateSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
@@ -322,34 +441,38 @@ func (h *VClaimHandler) UpdateSep(c *gin.Context) {
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing UpdateSep request", map[string]interface{}{
|
||||
|
||||
h.logger.Info("Processing UpdateSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
|
||||
|
||||
nosep := c.Param("nosep")
|
||||
if nosep == "" {
|
||||
|
||||
|
||||
h.logger.Error("Missing required parameter nosep", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter nosep",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var req reference.SepRequest
|
||||
var req sep.SepRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
|
||||
|
||||
h.logger.Error("Invalid request body", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Invalid request body: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
@@ -359,13 +482,13 @@ func (h *VClaimHandler) UpdateSep(c *gin.Context) {
|
||||
|
||||
// Validate request
|
||||
if err := h.validator.Struct(&req); err != nil {
|
||||
|
||||
|
||||
h.logger.Error("Validation failed", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Validation failed: " + err.Error(),
|
||||
RequestID: requestID,
|
||||
@@ -374,18 +497,22 @@ func (h *VClaimHandler) UpdateSep(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Call service method
|
||||
var response reference.SepResponse
|
||||
|
||||
result, err := h.service.UpdateSep(ctx, nosep, &req)
|
||||
|
||||
var response sep.SepResponse
|
||||
|
||||
endpoint := "/sep/:nosep"
|
||||
|
||||
endpoint = strings.Replace(endpoint, ":nosep", nosep, 1)
|
||||
|
||||
err := h.service.Put(ctx, endpoint, &req, &response)
|
||||
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to update Sep", map[string]interface{}{
|
||||
|
||||
h.logger.Error("Failed to update SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
@@ -396,26 +523,29 @@ func (h *VClaimHandler) UpdateSep(c *gin.Context) {
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
response.Data = result
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// DeleteSEP deletes existing Sep
|
||||
|
||||
// @Summary Delete Sep
|
||||
// @Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
|
||||
// @Param nosep path string true "nosep"
|
||||
// DeleteSEPSEP godoc
|
||||
// @Summary Delete existing SepSep
|
||||
// @Description Manage SEP (Surat Eligibilitas Peserta)
|
||||
// @Tags vclaim,sep
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
|
||||
// @Success 204 {object} nil
|
||||
// @Failure 400 {object} reference.ErrorResponse
|
||||
// @Failure 500 {object} reference.ErrorResponse
|
||||
// @Router /sep/:nosep [delete]
|
||||
// @Param X-Request-ID header string false "Request ID for tracking"
|
||||
|
||||
func (h *VClaimHandler) DeleteSep(c *gin.Context) {
|
||||
// @Param nosep path string true "nosep" example("example_value")
|
||||
|
||||
// @Success 200 {object} sep.SepResponse "Successfully deleted SepSep"
|
||||
// @Failure 400 {object} models.ErrorResponseBpjs "Bad request - invalid parameters"
|
||||
// @Failure 401 {object} models.ErrorResponseBpjs "Unauthorized - invalid API credentials"
|
||||
// @Failure 404 {object} models.ErrorResponseBpjs "Not found - SepSep not found"
|
||||
// @Failure 500 {object} models.ErrorResponseBpjs "Internal server error"
|
||||
// @Router /sep/:nosep [delete]
|
||||
func (h *VClaimHandler) DeleteSepSep(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
@@ -425,37 +555,46 @@ func (h *VClaimHandler) DeleteSep(c *gin.Context) {
|
||||
c.Header("X-Request-ID", requestID)
|
||||
}
|
||||
|
||||
h.logger.Info("Processing DeleteSep request", map[string]interface{}{
|
||||
|
||||
h.logger.Info("Processing DeleteSepSep request", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
|
||||
|
||||
nosep := c.Param("nosep")
|
||||
if nosep == "" {
|
||||
|
||||
|
||||
h.logger.Error("Missing required parameter nosep", map[string]interface{}{
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusBadRequest, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusBadRequest, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Missing required parameter nosep",
|
||||
RequestID: requestID,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Call service method
|
||||
|
||||
err := h.service.DeleteSep(ctx, nosep)
|
||||
|
||||
var response sep.SepResponse
|
||||
|
||||
endpoint := "/sep/:nosep"
|
||||
|
||||
endpoint = strings.Replace(endpoint, ":nosep", nosep, 1)
|
||||
|
||||
err := h.service.Delete(ctx, endpoint, &response)
|
||||
|
||||
if err != nil {
|
||||
|
||||
h.logger.Error("Failed to delete Sep", map[string]interface{}{
|
||||
|
||||
h.logger.Error("Failed to delete SepSep", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"request_id": requestID,
|
||||
})
|
||||
|
||||
c.JSON(http.StatusInternalServerError, reference.ErrorResponse{
|
||||
|
||||
c.JSON(http.StatusInternalServerError, models.ErrorResponseBpjs{
|
||||
Status: "error",
|
||||
Message: "Internal server error",
|
||||
RequestID: requestID,
|
||||
@@ -463,5 +602,10 @@ func (h *VClaimHandler) DeleteSep(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.Status(http.StatusNoContent)
|
||||
// Ensure response has proper fields
|
||||
response.Status = "success"
|
||||
response.RequestID = requestID
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
|
||||
|
||||
43
internal/models/aplicare/monitoring/monitoring.go
Normal file
43
internal/models/aplicare/monitoring/monitoring.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package aplicare
|
||||
|
||||
import "api-service/internal/models"
|
||||
|
||||
// === MONITORING MODELS ===
|
||||
|
||||
// MonitoringRequest represents monitoring data request
|
||||
type MonitoringRequest struct {
|
||||
models.BaseRequest
|
||||
TanggalAwal string `json:"tanggal_awal" validate:"required"`
|
||||
TanggalAkhir string `json:"tanggal_akhir" validate:"required"`
|
||||
JenisLaporan string `json:"jenis_laporan" validate:"required,oneof=kunjungan klaim rujukan sep"`
|
||||
PPK string `json:"ppk,omitempty"`
|
||||
StatusData string `json:"status_data,omitempty"`
|
||||
models.PaginationRequest
|
||||
}
|
||||
|
||||
// MonitoringData represents monitoring information
|
||||
type MonitoringData struct {
|
||||
Tanggal string `json:"tanggal"`
|
||||
PPK string `json:"ppk"`
|
||||
NamaPPK string `json:"nama_ppk"`
|
||||
JumlahKasus int `json:"jumlah_kasus"`
|
||||
TotalTarif float64 `json:"total_tarif"`
|
||||
StatusData string `json:"status_data"`
|
||||
Keterangan string `json:"keterangan,omitempty"`
|
||||
}
|
||||
|
||||
// MonitoringResponse represents monitoring API response
|
||||
type MonitoringResponse struct {
|
||||
models.BaseResponse
|
||||
Data []MonitoringData `json:"data,omitempty"`
|
||||
Summary *MonitoringSummary `json:"summary,omitempty"`
|
||||
Pagination *models.PaginationResponse `json:"pagination,omitempty"`
|
||||
}
|
||||
|
||||
// MonitoringSummary represents monitoring summary
|
||||
type MonitoringSummary struct {
|
||||
TotalKasus int `json:"total_kasus"`
|
||||
TotalTarif float64 `json:"total_tarif"`
|
||||
RataRataTarif float64 `json:"rata_rata_tarif"`
|
||||
PeriodeLaporan string `json:"periode_laporan"`
|
||||
}
|
||||
32
internal/models/aplicare/reference/reference.go
Normal file
32
internal/models/aplicare/reference/reference.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package aplicare
|
||||
|
||||
import "api-service/internal/models"
|
||||
|
||||
// === REFERENSI MODELS ===
|
||||
|
||||
// ReferensiRequest represents referensi lookup request
|
||||
type ReferensiRequest struct {
|
||||
models.BaseRequest
|
||||
JenisReferensi string `json:"jenis_referensi" validate:"required,oneof=diagnosa procedure obat alkes faskes dokter poli"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
KodeReferensi string `json:"kode_referensi,omitempty"`
|
||||
models.PaginationRequest
|
||||
}
|
||||
|
||||
// ReferensiData represents referensi information
|
||||
type ReferensiData struct {
|
||||
Kode string `json:"kode"`
|
||||
Nama string `json:"nama"`
|
||||
Kategori string `json:"kategori,omitempty"`
|
||||
Status string `json:"status"`
|
||||
TglBerlaku string `json:"tgl_berlaku,omitempty"`
|
||||
TglBerakhir string `json:"tgl_berakhir,omitempty"`
|
||||
Keterangan string `json:"keterangan,omitempty"`
|
||||
}
|
||||
|
||||
// ReferensiResponse represents referensi API response
|
||||
type ReferensiResponse struct {
|
||||
models.BaseResponse
|
||||
Data []ReferensiData `json:"data,omitempty"`
|
||||
Pagination *models.PaginationResponse `json:"pagination,omitempty"`
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package reference
|
||||
package eclaim
|
||||
|
||||
import "api-service/internal/models"
|
||||
|
||||
// === KLAIM MODELS ===
|
||||
|
||||
// KlaimRequest represents klaim submission request
|
||||
type KlaimRequest struct {
|
||||
BaseRequest
|
||||
models.BaseRequest
|
||||
NoSep string `json:"nomor_sep" validate:"required"`
|
||||
NoKartu string `json:"nomor_kartu" validate:"required"`
|
||||
NoMR string `json:"nomor_mr" validate:"required"`
|
||||
@@ -87,7 +89,7 @@ type SpecialCMGInfo struct {
|
||||
|
||||
// KlaimResponse represents klaim API response
|
||||
type KlaimResponse struct {
|
||||
BaseResponse
|
||||
models.BaseResponse
|
||||
Data *KlaimResponseData `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
@@ -106,7 +108,7 @@ type KlaimResponseData struct {
|
||||
|
||||
// GrouperRequest represents grouper processing request
|
||||
type GrouperRequest struct {
|
||||
BaseRequest
|
||||
models.BaseRequest
|
||||
NoSep string `json:"nomor_sep" validate:"required"`
|
||||
NoKartu string `json:"nomor_kartu" validate:"required"`
|
||||
TglMasuk string `json:"tgl_masuk" validate:"required"`
|
||||
@@ -143,6 +145,6 @@ type TopUpInfo struct {
|
||||
|
||||
// GrouperResponse represents grouper API response
|
||||
type GrouperResponse struct {
|
||||
BaseResponse
|
||||
models.BaseResponse
|
||||
Data *GrouperResult `json:"data,omitempty"`
|
||||
}
|
||||
@@ -63,6 +63,54 @@ type ErrorResponse struct {
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
}
|
||||
|
||||
// BaseRequest contains common fields for all BPJS requests
|
||||
type BaseRequest struct {
|
||||
RequestID string `json:"request_id,omitempty"`
|
||||
Timestamp time.Time `json:"timestamp,omitempty"`
|
||||
}
|
||||
|
||||
// BaseResponse contains common response fields
|
||||
type BaseResponse struct {
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message,omitempty"`
|
||||
RequestID string `json:"request_id,omitempty"`
|
||||
Timestamp string `json:"timestamp,omitempty"`
|
||||
}
|
||||
|
||||
// ErrorResponse represents error response structure
|
||||
type ErrorResponseBpjs struct {
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message"`
|
||||
RequestID string `json:"request_id,omitempty"`
|
||||
Errors map[string]interface{} `json:"errors,omitempty"`
|
||||
Code string `json:"code,omitempty"`
|
||||
}
|
||||
|
||||
// PaginationRequest contains pagination parameters
|
||||
type PaginationRequest struct {
|
||||
Page int `json:"page" validate:"min=1"`
|
||||
Limit int `json:"limit" validate:"min=1,max=100"`
|
||||
SortBy string `json:"sort_by,omitempty"`
|
||||
SortDir string `json:"sort_dir,omitempty" validate:"omitempty,oneof=asc desc"`
|
||||
}
|
||||
|
||||
// PaginationResponse contains pagination metadata
|
||||
type PaginationResponse struct {
|
||||
CurrentPage int `json:"current_page"`
|
||||
TotalPages int `json:"total_pages"`
|
||||
TotalItems int64 `json:"total_items"`
|
||||
ItemsPerPage int `json:"items_per_page"`
|
||||
HasNext bool `json:"has_next"`
|
||||
HasPrev bool `json:"has_previous"`
|
||||
}
|
||||
|
||||
// MetaInfo contains additional metadata
|
||||
type MetaInfo struct {
|
||||
Version string `json:"version"`
|
||||
Environment string `json:"environment"`
|
||||
ServerTime string `json:"server_time"`
|
||||
}
|
||||
|
||||
// Validation constants
|
||||
const (
|
||||
StatusDraft = "draft"
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
package reference
|
||||
|
||||
// === REFERENSI MODELS ===
|
||||
|
||||
// ReferensiRequest represents referensi lookup request
|
||||
type ReferensiRequest struct {
|
||||
BaseRequest
|
||||
JenisReferensi string `json:"jenis_referensi" validate:"required,oneof=diagnosa procedure obat alkes faskes dokter poli"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
KodeReferensi string `json:"kode_referensi,omitempty"`
|
||||
PaginationRequest
|
||||
}
|
||||
|
||||
// ReferensiData represents referensi information
|
||||
type ReferensiData struct {
|
||||
Kode string `json:"kode"`
|
||||
Nama string `json:"nama"`
|
||||
Kategori string `json:"kategori,omitempty"`
|
||||
Status string `json:"status"`
|
||||
TglBerlaku string `json:"tgl_berlaku,omitempty"`
|
||||
TglBerakhir string `json:"tgl_berakhir,omitempty"`
|
||||
Keterangan string `json:"keterangan,omitempty"`
|
||||
}
|
||||
|
||||
// ReferensiResponse represents referensi API response
|
||||
type ReferensiResponse struct {
|
||||
BaseResponse
|
||||
Data []ReferensiData `json:"data,omitempty"`
|
||||
Pagination *PaginationResponse `json:"pagination,omitempty"`
|
||||
}
|
||||
|
||||
// === MONITORING MODELS ===
|
||||
|
||||
// MonitoringRequest represents monitoring data request
|
||||
type MonitoringRequest struct {
|
||||
BaseRequest
|
||||
TanggalAwal string `json:"tanggal_awal" validate:"required"`
|
||||
TanggalAkhir string `json:"tanggal_akhir" validate:"required"`
|
||||
JenisLaporan string `json:"jenis_laporan" validate:"required,oneof=kunjungan klaim rujukan sep"`
|
||||
PPK string `json:"ppk,omitempty"`
|
||||
StatusData string `json:"status_data,omitempty"`
|
||||
PaginationRequest
|
||||
}
|
||||
|
||||
// MonitoringData represents monitoring information
|
||||
type MonitoringData struct {
|
||||
Tanggal string `json:"tanggal"`
|
||||
PPK string `json:"ppk"`
|
||||
NamaPPK string `json:"nama_ppk"`
|
||||
JumlahKasus int `json:"jumlah_kasus"`
|
||||
TotalTarif float64 `json:"total_tarif"`
|
||||
StatusData string `json:"status_data"`
|
||||
Keterangan string `json:"keterangan,omitempty"`
|
||||
}
|
||||
|
||||
// MonitoringResponse represents monitoring API response
|
||||
type MonitoringResponse struct {
|
||||
BaseResponse
|
||||
Data []MonitoringData `json:"data,omitempty"`
|
||||
Summary *MonitoringSummary `json:"summary,omitempty"`
|
||||
Pagination *PaginationResponse `json:"pagination,omitempty"`
|
||||
}
|
||||
|
||||
// MonitoringSummary represents monitoring summary
|
||||
type MonitoringSummary struct {
|
||||
TotalKasus int `json:"total_kasus"`
|
||||
TotalTarif float64 `json:"total_tarif"`
|
||||
RataRataTarif float64 `json:"rata_rata_tarif"`
|
||||
PeriodeLaporan string `json:"periode_laporan"`
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package reference
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// BaseRequest contains common fields for all BPJS requests
|
||||
type BaseRequest struct {
|
||||
RequestID string `json:"request_id,omitempty"`
|
||||
Timestamp time.Time `json:"timestamp,omitempty"`
|
||||
}
|
||||
|
||||
// BaseResponse contains common response fields
|
||||
type BaseResponse struct {
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message,omitempty"`
|
||||
RequestID string `json:"request_id,omitempty"`
|
||||
Timestamp string `json:"timestamp,omitempty"`
|
||||
}
|
||||
|
||||
// ErrorResponse represents error response structure
|
||||
type ErrorResponse struct {
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message"`
|
||||
RequestID string `json:"request_id,omitempty"`
|
||||
Errors map[string]interface{} `json:"errors,omitempty"`
|
||||
Code string `json:"code,omitempty"`
|
||||
}
|
||||
|
||||
// PaginationRequest contains pagination parameters
|
||||
type PaginationRequest struct {
|
||||
Page int `json:"page" validate:"min=1"`
|
||||
Limit int `json:"limit" validate:"min=1,max=100"`
|
||||
SortBy string `json:"sort_by,omitempty"`
|
||||
SortDir string `json:"sort_dir,omitempty" validate:"omitempty,oneof=asc desc"`
|
||||
}
|
||||
|
||||
// PaginationResponse contains pagination metadata
|
||||
type PaginationResponse struct {
|
||||
CurrentPage int `json:"current_page"`
|
||||
TotalPages int `json:"total_pages"`
|
||||
TotalItems int64 `json:"total_items"`
|
||||
ItemsPerPage int `json:"items_per_page"`
|
||||
HasNext bool `json:"has_next"`
|
||||
HasPrev bool `json:"has_previous"`
|
||||
}
|
||||
|
||||
// MetaInfo contains additional metadata
|
||||
type MetaInfo struct {
|
||||
Version string `json:"version"`
|
||||
Environment string `json:"environment"`
|
||||
ServerTime string `json:"server_time"`
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// internal/models/reference/services.go
|
||||
package reference
|
||||
|
||||
// VClaimService defines VClaim service interface
|
||||
// type VClaimService interface {
|
||||
// GetPESERTA(ctx context.Context, nokartu string) (*PesertaData, error)
|
||||
// CreateSEP(ctx context.Context, req *SEPRequest) (*SEPData, error)
|
||||
// GetSEP(ctx context.Context, nosep string) (*SEPData, error)
|
||||
// UpdateSEP(ctx context.Context, nosep string, req *SEPRequest) (*SEPData, error)
|
||||
// DeleteSEP(ctx context.Context, nosep string) error
|
||||
// GetRujukan(ctx context.Context, norujukan string) (*RujukanData, error)
|
||||
// }
|
||||
|
||||
// // EClaimService defines EClaim service interface
|
||||
// type EClaimService interface {
|
||||
// CreateKlaim(ctx context.Context, req *KlaimRequest) (*KlaimResponseData, error)
|
||||
// GetKlaim(ctx context.Context, noKlaim string) (*KlaimResponseData, error)
|
||||
// UpdateKlaim(ctx context.Context, noKlaim string, req *KlaimRequest) (*KlaimResponseData, error)
|
||||
// ProcessGrouper(ctx context.Context, req *GrouperRequest) (*GrouperResult, error)
|
||||
// }
|
||||
|
||||
// // AplicareService defines Aplicare service interface
|
||||
// type AplicareService interface {
|
||||
// GetReferensi(ctx context.Context, req *ReferensiRequest) ([]ReferensiData, *PaginationResponse, error)
|
||||
// GetMonitoring(ctx context.Context, req *MonitoringRequest) ([]MonitoringData, *MonitoringSummary, *PaginationResponse, error)
|
||||
// CreateMonitoring(ctx context.Context, req *MonitoringRequest) error
|
||||
// }
|
||||
@@ -1,144 +0,0 @@
|
||||
// internal/models/reference/vclaim.go
|
||||
package reference
|
||||
|
||||
// === PESERTA MODELS ===
|
||||
|
||||
// PesertaRequest represents peserta lookup request
|
||||
type PesertaRequest struct {
|
||||
BaseRequest
|
||||
NoKartu string `json:"nokartu" validate:"required,min=13,max=13"`
|
||||
NIK string `json:"nik,omitempty" validate:"omitempty,min=16,max=16"`
|
||||
TanggalSEP string `json:"tglsep" validate:"required" example:"2024-01-15"`
|
||||
NoTelepon string `json:"notelp,omitempty" validate:"omitempty,max=15"`
|
||||
}
|
||||
|
||||
// PesertaData represents peserta information from BPJS
|
||||
type PesertaData struct {
|
||||
NoKartu string `json:"noKartu"`
|
||||
NIK string `json:"nik"`
|
||||
Nama string `json:"nama"`
|
||||
Pisa string `json:"pisa"`
|
||||
Sex string `json:"sex"`
|
||||
TanggalLahir string `json:"tglLahir"`
|
||||
TelephoneMsisdn string `json:"tglTAT"`
|
||||
TelephoneAsat string `json:"tglTMT"`
|
||||
KodeCabang string `json:"kdCabang"`
|
||||
NamaCabang string `json:"nmCabang"`
|
||||
KodeJenisPeserta string `json:"kdJnsPst"`
|
||||
NamaJenisPeserta string `json:"nmJnsPst"`
|
||||
KelasRawat string `json:"klsRawat"`
|
||||
Status string `json:"statusPeserta"`
|
||||
Aktif string `json:"aktif"`
|
||||
KeteranganAktif string `json:"ketAktif"`
|
||||
NoSKTM string `json:"noSKTM,omitempty"`
|
||||
NoKTP string `json:"noKtp"`
|
||||
Asuransi string `json:"asuransi,omitempty"`
|
||||
CoB string `json:"cob,omitempty"`
|
||||
TunggakanIuran string `json:"tglTunggak,omitempty"`
|
||||
MR struct {
|
||||
NoMR string `json:"noMR"`
|
||||
NamaMR string `json:"nmMR"`
|
||||
Sex string `json:"sex"`
|
||||
TglLahir string `json:"tglLahir"`
|
||||
TglMeninggal string `json:"tglMeninggal,omitempty"`
|
||||
} `json:"mr,omitempty"`
|
||||
}
|
||||
|
||||
// PesertaResponse represents peserta API response
|
||||
type PesertaResponse struct {
|
||||
BaseResponse
|
||||
Data *PesertaData `json:"data,omitempty"`
|
||||
MetaData interface{} `json:"metaData,omitempty"`
|
||||
}
|
||||
|
||||
// === SEP (Surat Eligibilitas Peserta) MODELS ===
|
||||
|
||||
// SEPRequest represents SEP creation/update request
|
||||
type SepRequest struct {
|
||||
BaseRequest
|
||||
NoKartu string `json:"noKartu" validate:"required"`
|
||||
TglSep string `json:"tglSep" validate:"required"`
|
||||
PPKPelayanan string `json:"ppkPelayanan" validate:"required"`
|
||||
JnsPelayanan string `json:"jnsPelayanan" validate:"required,oneof=1 2"`
|
||||
KlsRawat string `json:"klsRawat" validate:"required,oneof=1 2 3"`
|
||||
NoMR string `json:"noMR" validate:"required"`
|
||||
Rujukan *SepRujukan `json:"rujukan"`
|
||||
Catatan string `json:"catatan,omitempty"`
|
||||
Diagnosa string `json:"diagnosa" validate:"required"`
|
||||
PoliTujuan string `json:"poli" validate:"required"`
|
||||
ExternalUser string `json:"user" validate:"required"`
|
||||
NoTelp string `json:"noTelp,omitempty"`
|
||||
}
|
||||
|
||||
// SEPRujukan represents rujukan information in SEP
|
||||
type SepRujukan struct {
|
||||
AsalRujukan string `json:"asalRujukan" validate:"required,oneof=1 2"`
|
||||
TglRujukan string `json:"tglRujukan" validate:"required"`
|
||||
NoRujukan string `json:"noRujukan" validate:"required"`
|
||||
PPKRujukan string `json:"ppkRujukan" validate:"required"`
|
||||
}
|
||||
|
||||
// SEPData represents SEP response data
|
||||
type SepData struct {
|
||||
NoSep string `json:"noSep"`
|
||||
TglSep string `json:"tglSep"`
|
||||
JnsPelayanan string `json:"jnsPelayanan"`
|
||||
PoliTujuan string `json:"poli"`
|
||||
KlsRawat string `json:"klsRawat"`
|
||||
NoMR string `json:"noMR"`
|
||||
Rujukan SepRujukan `json:"rujukan"`
|
||||
Catatan string `json:"catatan"`
|
||||
Diagnosa string `json:"diagnosa"`
|
||||
Peserta PesertaData `json:"peserta"`
|
||||
Informasi struct {
|
||||
NoSKDP string `json:"noSKDP,omitempty"`
|
||||
DPJPLayan string `json:"dpjpLayan"`
|
||||
NoTelepon string `json:"noTelp"`
|
||||
SubSpesialis string `json:"subSpesialis,omitempty"`
|
||||
} `json:"informasi"`
|
||||
}
|
||||
|
||||
// SEPResponse represents SEP API response
|
||||
type SepResponse struct {
|
||||
BaseResponse
|
||||
Data *SepData `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
// === RUJUKAN MODELS ===
|
||||
|
||||
// RujukanRequest represents rujukan lookup request
|
||||
type RujukanRequest struct {
|
||||
BaseRequest
|
||||
NoRujukan string `json:"noRujukan" validate:"required"`
|
||||
NoKartu string `json:"noKartu,omitempty"`
|
||||
}
|
||||
|
||||
// RujukanData represents rujukan information
|
||||
type RujukanData struct {
|
||||
NoRujukan string `json:"noRujukan"`
|
||||
TglRujukan string `json:"tglRujukan"`
|
||||
NoKartu string `json:"noKartu"`
|
||||
Nama string `json:"nama"`
|
||||
KelasRawat string `json:"kelasRawat"`
|
||||
Diagnosa struct {
|
||||
KodeDiagnosa string `json:"kdDiagnosa"`
|
||||
NamaDiagnosa string `json:"nmDiagnosa"`
|
||||
} `json:"diagnosa"`
|
||||
PoliRujukan struct {
|
||||
KodePoli string `json:"kdPoli"`
|
||||
NamaPoli string `json:"nmPoli"`
|
||||
} `json:"poliRujukan"`
|
||||
ProvPerujuk struct {
|
||||
KodeProvider string `json:"kdProvider"`
|
||||
NamaProvider string `json:"nmProvider"`
|
||||
} `json:"provPerujuk"`
|
||||
PelayananInfo string `json:"pelayanan"`
|
||||
StatusRujukan string `json:"statusRujukan"`
|
||||
}
|
||||
|
||||
// RujukanResponse represents rujukan API response
|
||||
type RujukanResponse struct {
|
||||
BaseResponse
|
||||
Data *RujukanData `json:"data,omitempty"`
|
||||
List []RujukanData `json:"list,omitempty"`
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package reference
|
||||
package models
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
53
internal/models/vclaim/peserta/peserta.go
Normal file
53
internal/models/vclaim/peserta/peserta.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package peserta
|
||||
|
||||
import "api-service/internal/models"
|
||||
|
||||
// === PESERTA MODELS ===
|
||||
|
||||
// PesertaRequest represents peserta lookup request
|
||||
type PesertaRequest struct {
|
||||
models.BaseRequest
|
||||
NoKartu string `json:"nokartu" validate:"required,min=13,max=13"`
|
||||
NIK string `json:"nik,omitempty" validate:"omitempty,min=16,max=16"`
|
||||
TanggalSEP string `json:"tglsep" validate:"required" example:"2024-01-15"`
|
||||
NoTelepon string `json:"notelp,omitempty" validate:"omitempty,max=15"`
|
||||
}
|
||||
|
||||
// PesertaData represents peserta information from BPJS
|
||||
type PesertaData struct {
|
||||
NoKartu string `json:"noKartu"`
|
||||
NIK string `json:"nik"`
|
||||
Nama string `json:"nama"`
|
||||
Pisa string `json:"pisa"`
|
||||
Sex string `json:"sex"`
|
||||
TanggalLahir string `json:"tglLahir"`
|
||||
TelephoneMsisdn string `json:"tglTAT"`
|
||||
TelephoneAsat string `json:"tglTMT"`
|
||||
KodeCabang string `json:"kdCabang"`
|
||||
NamaCabang string `json:"nmCabang"`
|
||||
KodeJenisPeserta string `json:"kdJnsPst"`
|
||||
NamaJenisPeserta string `json:"nmJnsPst"`
|
||||
KelasRawat string `json:"klsRawat"`
|
||||
Status string `json:"statusPeserta"`
|
||||
Aktif string `json:"aktif"`
|
||||
KeteranganAktif string `json:"ketAktif"`
|
||||
NoSKTM string `json:"noSKTM,omitempty"`
|
||||
NoKTP string `json:"noKtp"`
|
||||
Asuransi string `json:"asuransi,omitempty"`
|
||||
CoB string `json:"cob,omitempty"`
|
||||
TunggakanIuran string `json:"tglTunggak,omitempty"`
|
||||
MR struct {
|
||||
NoMR string `json:"noMR"`
|
||||
NamaMR string `json:"nmMR"`
|
||||
Sex string `json:"sex"`
|
||||
TglLahir string `json:"tglLahir"`
|
||||
TglMeninggal string `json:"tglMeninggal,omitempty"`
|
||||
} `json:"mr,omitempty"`
|
||||
}
|
||||
|
||||
// PesertaResponse represents peserta API response
|
||||
type PesertaResponse struct {
|
||||
models.BaseResponse
|
||||
Data *PesertaData `json:"data,omitempty"`
|
||||
MetaData interface{} `json:"metaData,omitempty"`
|
||||
}
|
||||
42
internal/models/vclaim/rujukan/rujukan.go
Normal file
42
internal/models/vclaim/rujukan/rujukan.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package vclaim
|
||||
|
||||
import "api-service/internal/models"
|
||||
|
||||
// === RUJUKAN MODELS ===
|
||||
|
||||
// RujukanRequest represents rujukan lookup request
|
||||
type RujukanRequest struct {
|
||||
models.BaseRequest
|
||||
NoRujukan string `json:"noRujukan" validate:"required"`
|
||||
NoKartu string `json:"noKartu,omitempty"`
|
||||
}
|
||||
|
||||
// RujukanData represents rujukan information
|
||||
type RujukanData struct {
|
||||
NoRujukan string `json:"noRujukan"`
|
||||
TglRujukan string `json:"tglRujukan"`
|
||||
NoKartu string `json:"noKartu"`
|
||||
Nama string `json:"nama"`
|
||||
KelasRawat string `json:"kelasRawat"`
|
||||
Diagnosa struct {
|
||||
KodeDiagnosa string `json:"kdDiagnosa"`
|
||||
NamaDiagnosa string `json:"nmDiagnosa"`
|
||||
} `json:"diagnosa"`
|
||||
PoliRujukan struct {
|
||||
KodePoli string `json:"kdPoli"`
|
||||
NamaPoli string `json:"nmPoli"`
|
||||
} `json:"poliRujukan"`
|
||||
ProvPerujuk struct {
|
||||
KodeProvider string `json:"kdProvider"`
|
||||
NamaProvider string `json:"nmProvider"`
|
||||
} `json:"provPerujuk"`
|
||||
PelayananInfo string `json:"pelayanan"`
|
||||
StatusRujukan string `json:"statusRujukan"`
|
||||
}
|
||||
|
||||
// RujukanResponse represents rujukan API response
|
||||
type RujukanResponse struct {
|
||||
models.BaseResponse
|
||||
Data *RujukanData `json:"data,omitempty"`
|
||||
List []RujukanData `json:"list,omitempty"`
|
||||
}
|
||||
59
internal/models/vclaim/sep/sep.go
Normal file
59
internal/models/vclaim/sep/sep.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package sep
|
||||
|
||||
import (
|
||||
"api-service/internal/models"
|
||||
"api-service/internal/models/vclaim/peserta"
|
||||
)
|
||||
|
||||
// === SEP (Surat Eligibilitas Peserta) MODELS ===
|
||||
|
||||
// SEPRequest represents SEP creation/update request
|
||||
type SepRequest struct {
|
||||
models.BaseRequest
|
||||
NoKartu string `json:"noKartu" validate:"required"`
|
||||
TglSep string `json:"tglSep" validate:"required"`
|
||||
PPKPelayanan string `json:"ppkPelayanan" validate:"required"`
|
||||
JnsPelayanan string `json:"jnsPelayanan" validate:"required,oneof=1 2"`
|
||||
KlsRawat string `json:"klsRawat" validate:"required,oneof=1 2 3"`
|
||||
NoMR string `json:"noMR" validate:"required"`
|
||||
Rujukan *SepRujukan `json:"rujukan"`
|
||||
Catatan string `json:"catatan,omitempty"`
|
||||
Diagnosa string `json:"diagnosa" validate:"required"`
|
||||
PoliTujuan string `json:"poli" validate:"required"`
|
||||
ExternalUser string `json:"user" validate:"required"`
|
||||
NoTelp string `json:"noTelp,omitempty"`
|
||||
}
|
||||
|
||||
// SEPRujukan represents rujukan information in SEP
|
||||
type SepRujukan struct {
|
||||
AsalRujukan string `json:"asalRujukan" validate:"required,oneof=1 2"`
|
||||
TglRujukan string `json:"tglRujukan" validate:"required"`
|
||||
NoRujukan string `json:"noRujukan" validate:"required"`
|
||||
PPKRujukan string `json:"ppkRujukan" validate:"required"`
|
||||
}
|
||||
|
||||
// SEPData represents SEP response data
|
||||
type SepData struct {
|
||||
NoSep string `json:"noSep"`
|
||||
TglSep string `json:"tglSep"`
|
||||
JnsPelayanan string `json:"jnsPelayanan"`
|
||||
PoliTujuan string `json:"poli"`
|
||||
KlsRawat string `json:"klsRawat"`
|
||||
NoMR string `json:"noMR"`
|
||||
Rujukan SepRujukan `json:"rujukan"`
|
||||
Catatan string `json:"catatan"`
|
||||
Diagnosa string `json:"diagnosa"`
|
||||
Peserta peserta.PesertaData `json:"peserta"`
|
||||
Informasi struct {
|
||||
NoSKDP string `json:"noSKDP,omitempty"`
|
||||
DPJPLayan string `json:"dpjpLayan"`
|
||||
NoTelepon string `json:"noTelp"`
|
||||
SubSpesialis string `json:"subSpesialis,omitempty"`
|
||||
} `json:"informasi"`
|
||||
}
|
||||
|
||||
// SEPResponse represents SEP API response
|
||||
type SepResponse struct {
|
||||
models.BaseResponse
|
||||
Data *SepData `json:"data,omitempty"`
|
||||
}
|
||||
@@ -100,12 +100,5 @@ func RegisterRoutes(cfg *config.Config) *gin.Engine {
|
||||
protectedRetribusi.DELETE("/:id", retribusiHandler.DeleteRetribusi) // DELETE /api/v1/retribusi/:id
|
||||
}
|
||||
|
||||
// BPJS endpoints (sensitive data - should be protected)
|
||||
// bpjsPesertaHandler := bpjsPesertaHandlers.NewPesertaHandler(cfg.Bpjs)
|
||||
// protectedBpjs := protected.Group("/bpjs")
|
||||
// {
|
||||
// protectedBpjs.GET("/peserta/nik/:nik/tglSEP/:tglSEP", bpjsPesertaHandler.GetPesertaByNIK)
|
||||
// }
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
@@ -21,9 +21,11 @@ type VClaimService interface {
|
||||
Get(ctx context.Context, endpoint string, result interface{}) error
|
||||
Post(ctx context.Context, endpoint string, payload interface{}, result interface{}) error
|
||||
Put(ctx context.Context, endpoint string, payload interface{}, result interface{}) error
|
||||
Patch(ctx context.Context, endpoint string, payload interface{}, result interface{}) error
|
||||
Delete(ctx context.Context, endpoint string, result interface{}) error
|
||||
GetRawResponse(ctx context.Context, endpoint string) (*ResponDTOVclaim, error)
|
||||
PostRawResponse(ctx context.Context, endpoint string, payload interface{}) (*ResponDTOVclaim, error)
|
||||
PatchRawResponse(ctx context.Context, endpoint string, payload interface{}) (*ResponDTOVclaim, error)
|
||||
}
|
||||
|
||||
// Service struct for VClaim service
|
||||
@@ -311,6 +313,33 @@ func (s *Service) Delete(ctx context.Context, endpoint string, result interface{
|
||||
return mapToResult(resp, result)
|
||||
}
|
||||
|
||||
// Patch performs HTTP PATCH request
|
||||
func (s *Service) Patch(ctx context.Context, endpoint string, payload interface{}, result interface{}) error {
|
||||
var buf bytes.Buffer
|
||||
if payload != nil {
|
||||
if err := json.NewEncoder(&buf).Encode(payload); err != nil {
|
||||
return fmt.Errorf("failed to encode payload: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
req, err := s.prepareRequest(ctx, http.MethodPatch, endpoint, &buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
res, err := s.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to execute PATCH request: %w", err)
|
||||
}
|
||||
|
||||
resp, err := s.processResponse(res)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return mapToResult(resp, result)
|
||||
}
|
||||
|
||||
// GetRawResponse returns raw response without mapping
|
||||
func (s *Service) GetRawResponse(ctx context.Context, endpoint string) (*ResponDTOVclaim, error) {
|
||||
req, err := s.prepareRequest(ctx, http.MethodGet, endpoint, nil)
|
||||
@@ -348,6 +377,28 @@ func (s *Service) PostRawResponse(ctx context.Context, endpoint string, payload
|
||||
return s.processResponse(res)
|
||||
}
|
||||
|
||||
// PatchRawResponse returns raw response without mapping
|
||||
func (s *Service) PatchRawResponse(ctx context.Context, endpoint string, payload interface{}) (*ResponDTOVclaim, error) {
|
||||
var buf bytes.Buffer
|
||||
if payload != nil {
|
||||
if err := json.NewEncoder(&buf).Encode(payload); err != nil {
|
||||
return nil, fmt.Errorf("failed to encode payload: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
req, err := s.prepareRequest(ctx, http.MethodPatch, endpoint, &buf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res, err := s.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute PATCH request: %w", err)
|
||||
}
|
||||
|
||||
return s.processResponse(res)
|
||||
}
|
||||
|
||||
// mapToResult maps the final response to the result interface
|
||||
func mapToResult(resp *ResponDTOVclaim, result interface{}) error {
|
||||
respBytes, err := json.Marshal(resp)
|
||||
|
||||
Reference in New Issue
Block a user