-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathencounter.go
53 lines (40 loc) · 1.45 KB
/
encounter.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
45
46
47
48
49
50
51
52
53
package hapifhirgo
import (
"context"
"fmt"
"github.com/savannahghi/hapi-fhir-go/models"
)
func (c *Client) CreateFHIREncounter(ctx context.Context, input *models.FHIREncounter) (*models.FHIREncounter, error) {
payload, err := structToMap(input)
if err != nil {
return nil, fmt.Errorf("unable to turn %s input into a map: %w", encounterResourceType, err)
}
resource := &models.FHIREncounter{}
err = c.CreateFHIRResource(ctx, encounterResourceType, payload, resource)
if err != nil {
return nil, fmt.Errorf("unable to create %s resource: %w", encounterResourceType, err)
}
return resource, nil
}
func (c *Client) GetFHIREncounter(ctx context.Context, id string) (*models.FHIREncounter, error) {
resource := &models.FHIREncounter{}
err := c.GetFHIRResource(ctx, encounterResourceType, id, resource)
if err != nil {
return nil, fmt.Errorf("unable to get %s with ID %s, err: %w", encounterResourceType, id, err)
}
return resource, nil
}
func (c *Client) GetFHIREncounterAllData(ctx context.Context, id string, params map[string]interface{}) (*models.Bundle, error) {
response, err := c.GetEncounterEverything(ctx, id, params)
if err != nil {
return nil, err
}
return response, nil
}
func (c *Client) SearchFHIREncounter(ctx context.Context, searchParams map[string]interface{}) (*models.Bundle, error) {
response, err := c.SearchFHIRResource(ctx, encounterResourceType, searchParams)
if err != nil {
return nil, err
}
return response, nil
}