package medicationrequest import ( "context" "net/url" "service/internal/interfaces/satusehat" "service/pkg/errors" ) type Service interface { Create(ctx context.Context, req MedicationRequestRequest) (*satusehat.FHIRResponse, error) Update(ctx context.Context, id string, req MedicationRequestRequest) (*satusehat.FHIRResponse, error) Patch(ctx context.Context, id string, req MedicationRequestPatchRequest) (*satusehat.FHIRResponse, error) GetByID(ctx context.Context, id string) (*satusehat.FHIRResponse, error) Search(ctx context.Context, queryParams url.Values) (*satusehat.FHIRResponse, error) } type service struct { repo Repository } func NewService(repo Repository) Service { return &service{repo: repo} } func (s *service) Create(ctx context.Context, req MedicationRequestRequest) (*satusehat.FHIRResponse, error) { return s.repo.Create(ctx, MapRequestToFHIR(req)) } func (s *service) Update(ctx context.Context, id string, req MedicationRequestRequest) (*satusehat.FHIRResponse, error) { if id == "" { return nil, errors.NewValidationError().Message("MedicationRequest ID is required").Build() } payload := MapRequestToFHIR(req) payload.Set("id", id) return s.repo.Update(ctx, id, payload) } func (s *service) Patch(ctx context.Context, id string, req MedicationRequestPatchRequest) (*satusehat.FHIRResponse, error) { return s.repo.Patch(ctx, id, req) } func (s *service) GetByID(ctx context.Context, id string) (*satusehat.FHIRResponse, error) { return s.repo.GetByID(ctx, id) } func (s *service) Search(ctx context.Context, queryParams url.Values) (*satusehat.FHIRResponse, error) { return s.repo.Search(ctx, queryParams) }