first commit

This commit is contained in:
meninjar
2026-04-14 01:23:34 +00:00
commit edfaa886ff
443 changed files with 1245931 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
package antrol
// Poli merepresentasikan data referensi poli dari API Antrean RS BPJS
type Poli struct {
KdPoli string `json:"kdpoli"`
NmPoli string `json:"nmpoli"`
KdSubSpesialis string `json:"kdsubspesialis"`
NmSubSpesialis string `json:"nmsubspesialis"`
}
@@ -0,0 +1,47 @@
package antrol
import (
"context"
"encoding/json"
"fmt"
"service/internal/interfaces/bpjs"
)
type Repository interface {
GetRefPoli(ctx context.Context) ([]Poli, error)
}
type repository struct {
client bpjs.BpjsClient
}
func NewRepository(client bpjs.BpjsClient) Repository {
return &repository{client: client}
}
// GetRefPoli fetches referensi poli from BPJS API
//
// # This function will return an array of Poli and error if any
//
// Context is used to pass the request context to the underlying
// client
//
// The function will return an error if the request to BPJS API
// fails or if the response cannot be unmarshalled into an array
// of Poli
//
// The function will return an empty array and nil error if the request
// to BPJS API succeeds but the response is an empty array
func (r *repository) GetRefPoli(ctx context.Context) ([]Poli, error) {
respBytes, err := r.client.DoRequest(ctx, "GET", "ref/poli", nil)
if err != nil {
return nil, err
}
var result []Poli
if err := json.Unmarshal(respBytes, &result); err != nil {
return nil, fmt.Errorf("failed to unmarshal ref poli antrol response: %w", err)
}
return result, nil
}
+26
View File
@@ -0,0 +1,26 @@
package antrol
import (
"context"
"service/pkg/errors"
)
type Service interface {
GetRefPoli(ctx context.Context) ([]Poli, error)
}
type service struct {
repo Repository
}
func NewService(repo Repository) Service {
return &service{repo: repo}
}
func (s *service) GetRefPoli(ctx context.Context) ([]Poli, error) {
res, err := s.repo.GetRefPoli(ctx)
if err != nil {
return nil, errors.ExternalError().Message("Gagal mengambil referensi poli Antrean RS BPJS").Cause(err).Build()
}
return res, nil
}