forked from dshills/gofhir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice.go
38 lines (35 loc) · 845 Bytes
/
device.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
package fhir
import (
"encoding/json"
"fmt"
"time"
)
// GetDevice will return a device for a patient with id pid
func (c *Connection) GetDevice(pid string) (*Device, error) {
b, err := c.Query(fmt.Sprintf("Device?patient=%v", pid))
if err != nil {
return nil, err
}
data := Device{}
if err := json.Unmarshal(b, &data); err != nil {
return nil, err
}
return &data, nil
}
// Device is a FHIR device
type Device struct {
ResourceType string `json:"resourceType"`
Type string `json:"type"`
Total int `json:"total"`
Link []Link `json:"link"`
Entry []struct {
EntryPartial
Resource struct {
ResourcePartial
UDI string `json:"udi"`
Model string `json:"model"`
Expiry time.Time `json:"expiry"`
Type Concept `json:"coding"`
} `json:"resource"`
} `json:"entry"`
}