-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
64 lines (56 loc) · 1.49 KB
/
main.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
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"encoding/json"
"fmt"
d "github.com/monarko/fhirgo/STU3/datatypes"
r "github.com/monarko/fhirgo/STU3/resources"
)
func main() {
var name []d.HumanName
use := d.Code("official")
family := d.String("Doe")
given := []d.String{"John", "Michael"}
nm := d.HumanName{Use: &use, Family: &family, Given: given}
name = make([]d.HumanName, 0)
name = append(name, nm)
var gender *d.Code
gender = new(d.Code)
*gender = "male"
var birthDate *d.Date
birthDate = new(d.Date)
*birthDate = "1977-09-14"
// var identifier []d.Identifier
// var active *d.Boolean
// var telecom []d.ContactPoint
// var deceasedBoolean *d.Boolean
// var deceasedDateTime *d.DateTime
// var address []d.Address
// var maritalStatus *d.CodeableConcept
// var multipleBirthBoolean *d.Boolean
// var multipleBirthInteger *d.Integer
// var photo []d.Attachment
// var contact []d.PatientContact
// var communication []d.PatientCommunication
// var generalPractitioner []d.Reference
// var managingOrganization *d.Reference
// var link []d.PatientLink
pat := r.Patient{}
pat.ResourceType = "Patient"
pat.Name = name
pat.Gender = gender
pat.BirthDate = birthDate
valid, errs := pat.Validate()
if !valid {
fmt.Println("The document is not valid. see errors:")
for _, e := range errs {
fmt.Printf("- %s\n", e)
}
} else {
fmt.Println("The document is valid")
out, err := json.MarshalIndent(pat, "", " ")
if err != nil {
fmt.Println("Error: ", err)
}
fmt.Println(string(out))
}
}