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

No files matched your search

@@ -0,0 +1,11 @@
package dpho
// DPHOData merepresentasikan detail referensi DPHO dari API Apotek
type DPHOData struct {
KodeObat string `json:"kodeobat"`
NamaObat string `json:"namaobat"`
PRB string `json:"prb"`
Kronis string `json:"kronis"`
Kemo string `json:"kemo"`
Harga string `json:"harga"`
}
@@ -0,0 +1,42 @@
package dpho
import (
"context"
"encoding/json"
"fmt"
"service/internal/interfaces/bpjs"
)
type Repository interface {
GetDPHO(ctx context.Context) ([]DPHOData, error)
}
type repository struct {
client bpjs.BpjsClient
}
func NewRepository(client bpjs.BpjsClient) Repository {
return &repository{client: client}
}
func (r *repository) GetDPHO(ctx context.Context) ([]DPHOData, error) {
respBytes, err := r.client.DoRequest(ctx, "GET", "referensi/dpho", nil)
if err != nil {
return nil, err
}
// Coba parsing ke dalam format object { "list": [...] }
var result struct {
List []DPHOData `json:"list"`
}
if err := json.Unmarshal(respBytes, &result); err != nil {
// Fallback jika API mengembalikan array langsung [...]
var directList []DPHOData
if err2 := json.Unmarshal(respBytes, &directList); err2 == nil {
return directList, nil
}
return nil, fmt.Errorf("failed to unmarshal apotek dpho response: %w", err)
}
return result.List, nil
}
@@ -0,0 +1,26 @@
package dpho
import (
"context"
"service/pkg/errors"
)
type Service interface {
GetDPHO(ctx context.Context) ([]DPHOData, error)
}
type service struct {
repo Repository
}
func NewService(repo Repository) Service {
return &service{repo: repo}
}
func (s *service) GetDPHO(ctx context.Context) ([]DPHOData, error) {
res, err := s.repo.GetDPHO(ctx)
if err != nil {
return nil, errors.ExternalError().Message("Gagal mengambil referensi DPHO Apotek BPJS").Cause(err).Build()
}
return res, nil
}