update All feture and service

This commit is contained in:
meninjar
2026-06-03 02:54:26 +00:00
parent af32d9cfdd
commit ce0fa1a291
98 changed files with 272469 additions and 1606 deletions

No files matched your search

@@ -17,24 +17,33 @@ type Service interface {
}
type service struct {
repo Repository
repo Repository
orgID string
}
func NewService(repo Repository) Service {
return &service{repo: repo}
func NewService(repo Repository, orgID string) Service {
return &service{repo: repo, orgID: orgID}
}
func (s *service) Create(ctx context.Context, req QuestionnaireResponseRequest) (*satusehat.FHIRResponse, error) {
if req.OrganizationID == "" {
req.OrganizationID = s.orgID
}
return s.repo.Create(ctx, MapRequestToFHIR(req))
}
func (s *service) Update(ctx context.Context, id string, req QuestionnaireResponseRequest) (*satusehat.FHIRResponse, error) {
if id == "" {
return nil, errors.NewValidationError().Message("QuestionnaireResponse ID is required").Build()
}
if req.OrganizationID == "" {
req.OrganizationID = s.orgID
}
payload := MapRequestToFHIR(req)
payload.Set("id", id)
return s.repo.Update(ctx, id, payload)
}
func (s *service) Patch(ctx context.Context, id string, req QuestionnaireResponsePatchRequest) (*satusehat.FHIRResponse, error) {
if id == "" {
return nil, errors.NewValidationError().Message("QuestionnaireResponse ID is required").Build()
@@ -44,12 +53,14 @@ func (s *service) Patch(ctx context.Context, id string, req QuestionnaireRespons
}
return s.repo.Patch(ctx, id, req)
}
func (s *service) GetByID(ctx context.Context, id string) (*satusehat.FHIRResponse, error) {
if id == "" {
return nil, errors.NewValidationError().Message("QuestionnaireResponse ID is required").Build()
}
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)
}