-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathepisode_of_care.go
44 lines (33 loc) · 1.26 KB
/
episode_of_care.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package hapifhirgo
import (
"context"
"fmt"
"github.com/savannahghi/hapi-fhir-go/models"
)
func (c *Client) CreateFHIREpisodeOfCare(ctx context.Context, input *models.FHIREpisodeOfCare) (*models.FHIREpisodeOfCare, error) {
payload, err := structToMap(input)
if err != nil {
return nil, fmt.Errorf("unable to turn %s input into a map: %w", episodeOfCareResourceType, err)
}
resource := &models.FHIREpisodeOfCare{}
err = c.CreateFHIRResource(ctx, episodeOfCareResourceType, payload, resource)
if err != nil {
return nil, fmt.Errorf("unable to create %s resource: %w", episodeOfCareResourceType, err)
}
return resource, nil
}
func (c *Client) GetFHIREpisodeOfCare(ctx context.Context, id string) (*models.FHIREpisodeOfCare, error) {
resource := &models.FHIREpisodeOfCare{}
err := c.GetFHIRResource(ctx, episodeOfCareResourceType, id, resource)
if err != nil {
return nil, fmt.Errorf("unable to get %s with ID %s, err: %w", episodeOfCareResourceType, id, err)
}
return resource, nil
}
func (c *Client) SearchFHIREpisodeOfCare(ctx context.Context, searchParams map[string]interface{}) (*models.Bundle, error) {
response, err := c.SearchFHIRResource(ctx, episodeOfCareResourceType, searchParams)
if err != nil {
return nil, err
}
return response, nil
}