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
}
+24
View File
@@ -0,0 +1,24 @@
package bed
// BedData merepresentasikan payload untuk membuat, mengubah, atau mengambil data ketersediaan Bed
type BedData struct {
KodeKelas string `json:"kodekelas"`
KodeRuang string `json:"koderuang"`
NamaRuang string `json:"namaruang"`
Kapasitas int `json:"kapasitas"`
Tersedia int `json:"tersedia"`
TersediaPria int `json:"tersediapria"`
TersediaWanita int `json:"tersediawanita"`
TersediaPriaWanita int `json:"tersediapriawanita"`
}
// BedDeletePayload merepresentasikan payload untuk menghapus data Bed
type BedDeletePayload struct {
KodeKelas string `json:"kodekelas"`
KodeRuang string `json:"koderuang"`
}
// BedReadResponse merepresentasikan balikan dari endpoint GET Read Bed
type BedReadResponse struct {
List []BedData `json:"list"`
}
+60
View File
@@ -0,0 +1,60 @@
package bed
import (
"context"
"encoding/json"
"fmt"
"service/internal/interfaces/bpjs"
)
type Repository interface {
Read(ctx context.Context, kdPpk string, start, limit int) ([]BedData, error)
Create(ctx context.Context, kdPpk string, payload BedData) error
Update(ctx context.Context, kdPpk string, payload BedData) error
Delete(ctx context.Context, kdPpk string, payload BedDeletePayload) error
}
type repository struct {
client bpjs.BpjsClient
}
func NewRepository(client bpjs.BpjsClient) Repository {
return &repository{client: client}
}
func (r *repository) Read(ctx context.Context, kdPpk string, start, limit int) ([]BedData, error) {
endpoint := fmt.Sprintf("rest/bed/read/%s/%d/%d", kdPpk, start, limit)
respBytes, err := r.client.DoRequest(ctx, "GET", endpoint, nil)
if err != nil {
return nil, err
}
var result BedReadResponse
if err := json.Unmarshal(respBytes, &result); err != nil {
return nil, fmt.Errorf("failed to unmarshal applicare read response: %w", err)
}
return result.List, nil
}
func (r *repository) Create(ctx context.Context, kdPpk string, payload BedData) error {
endpoint := fmt.Sprintf("rest/bed/create/%s", kdPpk)
_, err := r.client.DoRequest(ctx, "POST", endpoint, payload)
// Aplicares biasanya mengembalikan sukses di metadata yang sudah dihandle oleh client.go
return err
}
func (r *repository) Update(ctx context.Context, kdPpk string, payload BedData) error {
// Endpoint Update Aplicares menggunakan method POST, bukan PUT
endpoint := fmt.Sprintf("rest/bed/update/%s", kdPpk)
_, err := r.client.DoRequest(ctx, "POST", endpoint, payload)
return err
}
func (r *repository) Delete(ctx context.Context, kdPpk string, payload BedDeletePayload) error {
// Endpoint Delete Aplicares juga menggunakan method POST
endpoint := fmt.Sprintf("rest/bed/delete/%s", kdPpk)
_, err := r.client.DoRequest(ctx, "POST", endpoint, payload)
return err
}
+57
View File
@@ -0,0 +1,57 @@
package bed
import (
"context"
"service/pkg/errors"
)
type Service interface {
GetBedList(ctx context.Context, kdPpk string, start, limit int) ([]BedData, error)
CreateBed(ctx context.Context, kdPpk string, req BedData) error
UpdateBed(ctx context.Context, kdPpk string, req BedData) error
DeleteBed(ctx context.Context, kdPpk string, req BedDeletePayload) error
}
type service struct {
repo Repository
}
func NewService(repo Repository) Service {
return &service{repo: repo}
}
func (s *service) GetBedList(ctx context.Context, kdPpk string, start, limit int) ([]BedData, error) {
if kdPpk == "" {
return nil, errors.NewValidationError().Message("Kode PPK (Kode Faskes) wajib diisi").Build()
}
res, err := s.repo.Read(ctx, kdPpk, start, limit)
if err != nil {
return nil, errors.ExternalError().Message("Gagal mengambil data ketersediaan tempat tidur (Aplicares)").Cause(err).Build()
}
return res, nil
}
func (s *service) CreateBed(ctx context.Context, kdPpk string, req BedData) error {
err := s.repo.Create(ctx, kdPpk, req)
if err != nil {
return errors.ExternalError().Message("Gagal membuat data tempat tidur baru (Aplicares)").Cause(err).Build()
}
return nil
}
func (s *service) UpdateBed(ctx context.Context, kdPpk string, req BedData) error {
err := s.repo.Update(ctx, kdPpk, req)
if err != nil {
return errors.ExternalError().Message("Gagal memperbarui data tempat tidur (Aplicares)").Cause(err).Build()
}
return nil
}
func (s *service) DeleteBed(ctx context.Context, kdPpk string, req BedDeletePayload) error {
err := s.repo.Delete(ctx, kdPpk, req)
if err != nil {
return errors.ExternalError().Message("Gagal menghapus data tempat tidur (Aplicares)").Cause(err).Build()
}
return nil
}
@@ -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
}
@@ -0,0 +1,7 @@
package poli
// PoliData merepresentasikan detail referensi Poli dari API Apotek
type PoliData struct {
KodePoli string `json:"kodepoli"`
NamaPoli string `json:"namapoli"`
}
@@ -0,0 +1,41 @@
package poli
import (
"context"
"encoding/json"
"fmt"
"service/internal/interfaces/bpjs"
)
type Repository interface {
GetPoli(ctx context.Context, param string) ([]PoliData, error)
}
type repository struct {
client bpjs.BpjsClient
}
func NewRepository(client bpjs.BpjsClient) Repository {
return &repository{client: client}
}
func (r *repository) GetPoli(ctx context.Context, param string) ([]PoliData, error) {
endpoint := fmt.Sprintf("referensi/poli/%s", param)
respBytes, err := r.client.DoRequest(ctx, "GET", endpoint, nil)
if err != nil {
return nil, err
}
var result struct {
List []PoliData `json:"list"`
}
if err := json.Unmarshal(respBytes, &result); err != nil {
var directList []PoliData
if err2 := json.Unmarshal(respBytes, &directList); err2 == nil {
return directList, nil
}
return nil, fmt.Errorf("failed to unmarshal apotek poli response: %w", err)
}
return result.List, nil
}
@@ -0,0 +1,29 @@
package poli
import (
"context"
"service/pkg/errors"
)
type Service interface {
GetPoli(ctx context.Context, param string) ([]PoliData, error)
}
type service struct {
repo Repository
}
func NewService(repo Repository) Service {
return &service{repo: repo}
}
func (s *service) GetPoli(ctx context.Context, param string) ([]PoliData, error) {
if param == "" {
return nil, errors.NewValidationError().Message("Parameter pencarian Poli wajib diisi").Build()
}
res, err := s.repo.GetPoli(ctx, param)
if err != nil {
return nil, errors.ExternalError().Message("Gagal mengambil referensi Poli Apotek BPJS").Cause(err).Build()
}
return res, nil
}
+53
View File
@@ -0,0 +1,53 @@
package peserta
// PesertaResponse merepresentasikan wrapper data dari API BPJS VClaim
type PesertaResponse struct {
Peserta PesertaData `json:"peserta"`
}
// PesertaData merepresentasikan entitas detail Peserta BPJS
type PesertaData struct {
NoKartu string `json:"noKartu"`
Nik string `json:"nik"`
Nama string `json:"nama"`
Pisa string `json:"pisa"`
Sex string `json:"sex"`
Umur Umur `json:"umur"`
TglLahir string `json:"tglLahir"`
StatusPeserta StatusPeserta `json:"statusPeserta"`
ProviderUmum ProviderUmum `json:"provUmum"`
JenisPeserta JenisPeserta `json:"jenisPeserta"`
HakKelas HakKelas `json:"hakKelas"`
Informasi Informasi `json:"informasi"`
}
type Umur struct {
UmurSaatPelayanan string `json:"umurSaatPelayanan"`
UmurSekarang string `json:"umurSekarang"`
}
type StatusPeserta struct {
Kode string `json:"kode"`
Keterangan string `json:"keterangan"`
}
type ProviderUmum struct {
KdProvider string `json:"kdProvider"`
NmProvider string `json:"nmProvider"`
}
type JenisPeserta struct {
Kode string `json:"kode"`
Keterangan string `json:"keterangan"`
}
type HakKelas struct {
Kode string `json:"kode"`
Keterangan string `json:"keterangan"`
}
type Informasi struct {
Dinsos string `json:"dinsos"`
ProlanisPRB string `json:"prolanisPRB"`
NoSKTM string `json:"noSKTM"`
}
@@ -0,0 +1,52 @@
package peserta
import (
"context"
"encoding/json"
"fmt"
"service/internal/interfaces/bpjs"
)
type Repository interface {
GetByNoKartu(ctx context.Context, noKartu, tglSEP string) (*PesertaData, error)
GetByNIK(ctx context.Context, nik, tglSEP string) (*PesertaData, error)
}
type repository struct {
client bpjs.BpjsClient
}
func NewRepository(client bpjs.BpjsClient) Repository {
return &repository{client: client}
}
func (r *repository) GetByNoKartu(ctx context.Context, noKartu, tglSEP string) (*PesertaData, error) {
endpoint := fmt.Sprintf("Peserta/nokartu/%s/tglSEP/%s", noKartu, tglSEP)
respBytes, err := r.client.DoRequest(ctx, "GET", endpoint, nil)
if err != nil {
return nil, err
}
var result PesertaResponse
if err := json.Unmarshal(respBytes, &result); err != nil {
return nil, fmt.Errorf("failed to unmarshal peserta response: %w", err)
}
return &result.Peserta, nil
}
func (r *repository) GetByNIK(ctx context.Context, nik, tglSEP string) (*PesertaData, error) {
endpoint := fmt.Sprintf("Peserta/nik/%s/tglSEP/%s", nik, tglSEP)
respBytes, err := r.client.DoRequest(ctx, "GET", endpoint, nil)
if err != nil {
return nil, err
}
var result PesertaResponse
if err := json.Unmarshal(respBytes, &result); err != nil {
return nil, fmt.Errorf("failed to unmarshal peserta response: %w", err)
}
return &result.Peserta, nil
}
+43
View File
@@ -0,0 +1,43 @@
package peserta
import (
"context"
"service/pkg/errors"
)
type Service interface {
GetPesertaByNoKartu(ctx context.Context, noKartu, tglSEP string) (*PesertaData, error)
GetPesertaByNIK(ctx context.Context, nik, tglSEP string) (*PesertaData, error)
}
type service struct {
repo Repository
}
func NewService(repo Repository) Service {
return &service{repo: repo}
}
func (s *service) GetPesertaByNoKartu(ctx context.Context, noKartu, tglSEP string) (*PesertaData, error) {
if noKartu == "" || tglSEP == "" {
return nil, errors.NewValidationError().Message("Nomor Kartu dan Tanggal SEP wajib diisi").Build()
}
res, err := s.repo.GetByNoKartu(ctx, noKartu, tglSEP)
if err != nil {
return nil, errors.ExternalError().Message("Gagal mengambil data peserta BPJS berdasarkan No Kartu").Cause(err).Build()
}
return res, nil
}
func (s *service) GetPesertaByNIK(ctx context.Context, nik, tglSEP string) (*PesertaData, error) {
if nik == "" || tglSEP == "" {
return nil, errors.NewValidationError().Message("NIK dan Tanggal SEP wajib diisi").Build()
}
res, err := s.repo.GetByNIK(ctx, nik, tglSEP)
if err != nil {
return nil, errors.ExternalError().Message("Gagal mengambil data peserta BPJS berdasarkan NIK").Cause(err).Build()
}
return res, nil
}
+136
View File
@@ -0,0 +1,136 @@
package sep
// CreateSEPRequest adalah data payload untuk insert pembuatan SEP.
// Strukturnya mengikuti format yang dibutuhkan oleh API VClaim 2.0.
type CreateSEPRequest struct {
Request struct {
Sep `json:"t_sep"`
} `json:"request"`
}
// Sep adalah detail data untuk pembuatan SEP.
type Sep struct {
NoKartu string `json:"noKartu"`
TglSep string `json:"tglSep"`
PpkPelayanan string `json:"ppkPelayanan"`
JnsPelayanan string `json:"jnsPelayanan"`
KlsRawat KlsRawat `json:"klsRawat"`
NoMR string `json:"noMR"`
Rujukan Rujukan `json:"rujukan"`
Catatan string `json:"catatan"`
DiagAwal string `json:"diagAwal"`
Poli Poli `json:"poli"`
Cob string `json:"cob"`
Katarak string `json:"katarak"`
Jaminan Jaminan `json:"jaminan"`
Tujuan string `json:"tujuan"`
FlagProcedure string `json:"flagProcedure"`
KdPenunjang string `json:"kdPenunjang"`
AssesmentPel string `json:"assesmentPel"`
NoSurat string `json:"noSurat"`
KodeDPJP string `json:"kodeDPJP"`
DpjpLayan string `json:"dpjpLayan"`
NoTelp string `json:"noTelp"`
User string `json:"user"`
}
type KlsRawat struct {
KlsRawatHak string `json:"klsRawatHak"`
KlsRawatNaik string `json:"klsRawatNaik,omitempty"`
Pembiayaan string `json:"pembiayaan,omitempty"`
PenanggungJawab string `json:"penanggungJawab,omitempty"`
}
type Rujukan struct {
AsalRujukan string `json:"asalRujukan"`
TglRujukan string `json:"tglRujukan"`
NoRujukan string `json:"noRujukan"`
PpkRujukan string `json:"ppkRujukan"`
}
type Poli struct {
Tujuan string `json:"tujuan"`
Eksekutif string `json:"eksekutif"`
}
type Jaminan struct {
LakaLantas string `json:"lakaLantas"`
NoLP string `json:"noLP,omitempty"`
Penjamin Penjamin `json:"penjamin,omitempty"`
}
type Penjamin struct {
TglKejadian string `json:"tglKejadian,omitempty"`
Keterangan string `json:"keterangan,omitempty"`
Suplesi struct {
Suplesi string `json:"suplesi"`
NoSepSuplesi string `json:"noSepSuplesi,omitempty"`
LokasiLaka struct {
KdPropinsi string `json:"kdPropinsi"`
KdKabupaten string `json:"kdKabupaten"`
KdKecamatan string `json:"kdKecamatan"`
} `json:"lokasiLaka,omitempty"`
} `json:"suplesi,omitempty"`
}
// CreateSEPResponse adalah data balikan setelah SEP berhasil dicreate.
type CreateSEPResponse struct {
Sep struct {
NoSep string `json:"noSep"`
TglSep string `json:"tglSep"`
Poli string `json:"poli"`
Diagnosa string `json:"diagnosa"`
Catatan string `json:"catatan"`
JnsRawat string `json:"jnsRawat"`
KlsRawat string `json:"klsRawat"`
Penjamin string `json:"penjamin"`
} `json:"sep"`
}
// UpdateSEPRequest adalah data payload untuk update SEP.
type UpdateSEPRequest struct {
Request struct {
Sep struct {
NoSep string `json:"noSep"`
KlsRawat KlsRawat `json:"klsRawat"`
NoMR string `json:"noMR"`
Catatan string `json:"catatan"`
DiagAwal string `json:"diagAwal"`
Poli Poli `json:"poli"`
Eksekutif string `json:"eksekutif"`
Cob string `json:"cob"`
Katarak string `json:"katarak"`
Jaminan Jaminan `json:"jaminan"`
NoTelp string `json:"noTelp"`
User string `json:"user"`
} `json:"t_sep"`
} `json:"request"`
}
// DeleteSEPRequest adalah data payload untuk menghapus SEP.
type DeleteSEPRequest struct {
Request struct {
Sep struct {
NoSep string `json:"noSep"`
User string `json:"user"`
} `json:"t_sep"`
} `json:"request"`
}
// SEPDetailResponse adalah data balikan untuk detail SEP.
type SEPDetailResponse struct {
Catatan string `json:"catatan"`
Diagnosa string `json:"diagnosa"`
JnsPelayanan string `json:"jnsPelayanan"`
KelasRawat string `json:"kelasRawat"`
NoRujukan string `json:"noRujukan"`
NoSep string `json:"noSep"`
Penjamin string `json:"penjamin"`
Peserta struct {
Nama string `json:"nama"`
NoKartu string `json:"noKartu"`
NoMr string `json:"noMr"`
} `json:"peserta"`
Poli string `json:"poli"`
TglSep string `json:"tglSep"`
}
+67
View File
@@ -0,0 +1,67 @@
package sep
import (
"context"
"encoding/json"
"fmt"
"service/internal/interfaces/bpjs"
)
type Repository interface {
CreateSEP(ctx context.Context, req CreateSEPRequest) (*CreateSEPResponse, error)
UpdateSEP(ctx context.Context, req UpdateSEPRequest) (string, error)
DeleteSEP(ctx context.Context, req DeleteSEPRequest) (string, error)
GetSEP(ctx context.Context, noSEP string) (*SEPDetailResponse, error)
}
type repository struct {
client bpjs.BpjsClient
}
func NewRepository(client bpjs.BpjsClient) Repository {
return &repository{client: client}
}
func (r *repository) CreateSEP(ctx context.Context, req CreateSEPRequest) (*CreateSEPResponse, error) {
endpoint := "SEP/2.0/insert"
decryptedBytes, err := r.client.DoRequest(ctx, "POST", endpoint, req)
if err != nil {
return nil, err
}
var result CreateSEPResponse
return &result, json.Unmarshal(decryptedBytes, &result)
}
func (r *repository) UpdateSEP(ctx context.Context, req UpdateSEPRequest) (string, error) {
endpoint := "SEP/2.0/update"
decryptedBytes, err := r.client.DoRequest(ctx, "PUT", endpoint, req)
if err != nil {
return "", err
}
// Response dari update SEP biasanya hanya string nomor SEP itu sendiri
return string(decryptedBytes), nil
}
func (r *repository) DeleteSEP(ctx context.Context, req DeleteSEPRequest) (string, error) {
endpoint := "SEP/2.0/delete"
// BPJS API untuk delete menggunakan POST method dengan payload spesifik
decryptedBytes, err := r.client.DoRequest(ctx, "POST", endpoint, req)
if err != nil {
return "", err
}
// Response dari delete SEP biasanya hanya string "OK" atau pesan konfirmasi
return string(decryptedBytes), nil
}
func (r *repository) GetSEP(ctx context.Context, noSEP string) (*SEPDetailResponse, error) {
endpoint := fmt.Sprintf("SEP/%s", noSEP)
decryptedBytes, err := r.client.DoRequest(ctx, "GET", endpoint, nil)
if err != nil {
return nil, err
}
var result SEPDetailResponse
if err := json.Unmarshal(decryptedBytes, &result); err != nil {
return nil, fmt.Errorf("failed to unmarshal SEP detail response: %w", err)
}
return &result, nil
}
+41
View File
@@ -0,0 +1,41 @@
package sep
import (
"context"
)
type Service interface {
Create(ctx context.Context, req CreateSEPRequest) (*CreateSEPResponse, error)
Update(ctx context.Context, req UpdateSEPRequest) (string, error)
Delete(ctx context.Context, req DeleteSEPRequest) (string, error)
GetDetail(ctx context.Context, noSEP string) (*SEPDetailResponse, error)
}
type service struct {
repo Repository
}
func NewService(repo Repository) Service {
return &service{repo: repo}
}
func (s *service) Create(ctx context.Context, req CreateSEPRequest) (*CreateSEPResponse, error) {
// Anda bisa menambahkan validasi atau logika bisnis di sini sebelum memanggil repository.
return s.repo.CreateSEP(ctx, req)
}
func (s *service) Update(ctx context.Context, req UpdateSEPRequest) (string, error) {
// TODO: Tambahkan validasi untuk request update di sini.
// Contoh: if req.Request.Sep.NoSep == "" { return "", errors.New("nomor SEP wajib diisi") }
return s.repo.UpdateSEP(ctx, req)
}
func (s *service) Delete(ctx context.Context, req DeleteSEPRequest) (string, error) {
// TODO: Tambahkan validasi untuk request delete di sini.
return s.repo.DeleteSEP(ctx, req)
}
func (s *service) GetDetail(ctx context.Context, noSEP string) (*SEPDetailResponse, error) {
// TODO: Tambahkan validasi untuk noSEP di sini.
return s.repo.GetSEP(ctx, noSEP)
}