penambahan All case Satu sehat

This commit is contained in:
meninjar
2026-05-04 03:48:43 +00:00
parent 135c631021
commit af32d9cfdd
127 changed files with 617690 additions and 1160 deletions
@@ -7,6 +7,7 @@ import (
"net/url"
"service/internal/interfaces/satusehat"
"service/pkg/errors"
)
type Repository interface {
@@ -25,22 +26,26 @@ func NewRepository(client satusehat.SatuSehatClient) Repository {
return &repository{client: client}
}
func (r *repository) executeRequest(ctx context.Context, method, endpoint string, req interface{}) (*satusehat.FHIRResponse, error) {
resp, err := r.client.DoRequest(ctx, method, endpoint, req)
if err != nil {
return nil, err
}
type hiddenCtx struct {
context.Context
}
func (r *repository) executeRequest(ctx context.Context, method, endpoint string, req interface{}) (*satusehat.FHIRResponse, error) {
resp, err := r.client.DoRequest(hiddenCtx{ctx}, method, endpoint, req)
if err != nil {
return nil, errors.InternalError().Message("Failed to execute request to SatuSehat").Cause(err).Build()
}
var result map[string]interface{}
if err := json.Unmarshal(resp, &result); err != nil {
return nil, fmt.Errorf("failed to unmarshal response: %w", err)
return nil, errors.InternalError().Message("Failed to parse SatuSehat response").Cause(err).Metadata("raw_response", string(resp)).Build()
}
if resourceType, ok := result["resourceType"].(string); ok && resourceType == "OperationOutcome" {
return nil, errors.ParseSatuSehatError(result)
}
var resourceID string
if id, ok := result["id"].(string); ok {
resourceID = id
}
return &satusehat.FHIRResponse{
ID: resourceID,
FullResponse: result,