forked from dshills/golevel7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_test.go
105 lines (100 loc) · 1.88 KB
/
build_test.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package golevel7
import "testing"
func TestBuildMessage(t *testing.T) {
mi := MsgInfo{
SendingApp: "BettrLife",
SendingFacility: "UnivIa",
ReceivingApp: "Epic",
ReceivingFacility: "UnivIa",
MessageType: "ORM^001",
}
msg, err := StartMessage(mi)
if err != nil {
t.Fatal(err)
}
v, err := msg.Find("MSH.3")
if err != nil {
t.Error(err)
}
if v != "BettrLife" {
t.Errorf("Expected BettrLife got %s\n", v)
}
v, err = msg.Find("MSH.4")
if err != nil {
t.Error(err)
}
if v != "UnivIa" {
t.Errorf("Expected UnivIa got %s\n", v)
}
v, err = msg.Find("MSH.5")
if err != nil {
t.Error(err)
}
if v != "Epic" {
t.Errorf("Expected Epic got %s\n", v)
}
v, err = msg.Find("MSH.6")
if err != nil {
t.Error(err)
}
if v != "UnivIa" {
t.Errorf("Expected UnivIa got %s\n", v)
}
v, err = msg.Find("MSH.9")
if err != nil {
t.Error(err)
}
if v != "ORM^001" {
t.Errorf("Expected ORM^001 got %s\n", v)
}
v, err = msg.Find("MSH.7")
if err != nil {
t.Error(err)
}
if v == "" {
t.Error("Expected value got none")
}
v, err = msg.Find("MSH.10")
if err != nil {
t.Error(err)
}
if v == "" {
t.Error("Expected value got none")
}
v, err = msg.Find("MSH.11")
if err != nil {
t.Error(err)
}
if v != "P" {
t.Errorf("Expected P got %s\n", v)
}
v, err = msg.Find("MSH.12")
if err != nil {
t.Error(err)
}
if v != "2.4" {
t.Errorf("Expected 2.4 got %s\n", v)
}
}
type aMsg struct {
FirstName string `hl7:"PID.5.1"`
LastName string `hl7:"PID.5.0"`
}
func TestMessageBuilding(t *testing.T) {
mi := MsgInfo{
SendingApp: "BettrLife",
SendingFacility: "UnivIa",
ReceivingApp: "Epic",
ReceivingFacility: "UnivIa",
MessageType: "ORM^001",
}
msg, err := StartMessage(mi)
if err != nil {
t.Fatal(err)
}
am := aMsg{FirstName: "Davin", LastName: "Hills"}
_, err = Marshal(msg, &am)
if err != nil {
t.Error(err)
}
}