-
Notifications
You must be signed in to change notification settings - Fork 2
/
immunization_test.go
62 lines (53 loc) · 2.54 KB
/
immunization_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
package hdsfhir
import (
"encoding/json"
"io/ioutil"
fhir "github.com/intervention-engine/fhir/models"
"github.com/pebbe/util"
. "gopkg.in/check.v1"
)
type ImmunizationSuite struct {
Patient *Patient
Immunizations map[string]*Immunization
}
var _ = Suite(&ImmunizationSuite{})
func (s *ImmunizationSuite) SetUpSuite(c *C) {
data, err := ioutil.ReadFile("./fixtures/immunizations.json")
util.CheckErr(err)
s.Immunizations = make(map[string]*Immunization)
err = json.Unmarshal(data, &s.Immunizations)
util.CheckErr(err)
s.Patient = &Patient{}
for _, immunization := range s.Immunizations {
immunization.Patient = s.Patient
}
}
func (s *ImmunizationSuite) TestImmunizationAdministered(c *C) {
immunization := s.Immunizations["immunizationAdministered"].FHIRModels()[0].(*fhir.Immunization)
c.Assert(immunization.Status, Equals, "completed")
c.Assert(immunization.Date, DeepEquals, NewUnixTime(1263168508).FHIRDateTime())
c.Assert(immunization.VaccineCode.Text, Equals, "MMR")
c.Assert(immunization.VaccineCode.Coding, HasLen, 1)
c.Assert(immunization.VaccineCode.MatchesCode("http://www2a.cdc.gov/vaccines/iis/iisstandards/vaccines.asp?rpt=cvx", "03"), Equals, true)
c.Assert(immunization.Patient, DeepEquals, s.Patient.FHIRReference())
c.Assert(immunization.VaccinationProtocol, HasLen, 1)
c.Assert(*immunization.VaccinationProtocol[0].DoseSequence, Equals, uint32(2))
c.Assert(immunization.WasNotGiven, IsNil)
c.Assert(immunization.Explanation, IsNil)
}
func (s *ImmunizationSuite) TestImmunizationNotAdministered(c *C) {
immunization := s.Immunizations["immunizationNotAdministered"].FHIRModels()[0].(*fhir.Immunization)
c.Assert(immunization.Status, Equals, "completed")
c.Assert(immunization.Date, DeepEquals, NewUnixTime(1263168508).FHIRDateTime())
c.Assert(immunization.VaccineCode.Text, Equals, "MMR")
c.Assert(immunization.VaccineCode.Coding, HasLen, 1)
c.Assert(immunization.VaccineCode.MatchesCode("http://www2a.cdc.gov/vaccines/iis/iisstandards/vaccines.asp?rpt=cvx", "03"), Equals, true)
c.Assert(immunization.Patient, DeepEquals, s.Patient.FHIRReference())
c.Assert(*immunization.WasNotGiven, Equals, true)
c.Assert(immunization.Explanation.Reason, IsNil)
c.Assert(immunization.Explanation.ReasonNotGiven, HasLen, 1)
c.Assert(immunization.Explanation.ReasonNotGiven[0].Text, Equals, "")
c.Assert(immunization.Explanation.ReasonNotGiven[0].Coding, HasLen, 1)
c.Assert(immunization.Explanation.ReasonNotGiven[0].MatchesCode("http://snomed.info/sct", "591000119102"), Equals, true)
c.Assert(immunization.VaccinationProtocol, IsNil)
}