first commit
This commit is contained in:
No files matched your search
@@ -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"`
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user