update All feture and service
This commit is contained in:
@@ -17,24 +17,29 @@ type Service interface {
|
||||
}
|
||||
|
||||
type service struct {
|
||||
repo Repository
|
||||
repo Repository
|
||||
orgID string
|
||||
}
|
||||
|
||||
// NewService membuat service ServiceRequest baru.
|
||||
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 ServiceRequestRequest) (*satusehat.FHIRResponse, error) {
|
||||
fhirPayload := MapRequestToFHIR(req)
|
||||
return s.repo.Create(ctx, fhirPayload)
|
||||
if req.OrganizationID == "" {
|
||||
req.OrganizationID = s.orgID
|
||||
}
|
||||
return s.repo.Create(ctx, MapRequestToFHIR(req))
|
||||
}
|
||||
|
||||
func (s *service) Update(ctx context.Context, id string, req ServiceRequestRequest) (*satusehat.FHIRResponse, error) {
|
||||
if id == "" {
|
||||
return nil, errors.NewValidationError().Message("ServiceRequest ID is required").Build()
|
||||
}
|
||||
|
||||
if req.OrganizationID == "" {
|
||||
req.OrganizationID = s.orgID
|
||||
}
|
||||
fhirPayload := MapRequestToFHIR(req)
|
||||
fhirPayload.Set("id", id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user