func (p *PieSuite) TestEventStreamClone(c *C) {
	patient := new(models.Patient)
	patient.Id = "123"

	es := NewEventStream(patient)
	es.Events = []Event{
		{
			Date:  time.Now(),
			Type:  "Foo",
			End:   false,
			Value: 123,
		},
		{
			Date:  time.Now(),
			Type:  "Bar",
			End:   false,
			Value: 456,
		},
	}

	// Test initial clone
	clone := es.Clone()
	c.Assert(clone.Patient, DeepEquals, es.Patient)
	c.Assert(&clone.Events, Not(Equals), &es.Events)
	c.Assert(clone.Events, DeepEquals, es.Events)

	// Modify clone and make sure it doesn't affect original
	clone.Events[1].End = true
	c.Assert(es.Events[1].End, Equals, false)
}
func (p *EventsSuite) TestNewEventStream(c *C) {
	patient := new(models.Patient)
	patient.Id = "123"

	es := NewEventStream(patient)
	c.Assert(es.Patient, DeepEquals, patient)
	c.Assert(es.Events, HasLen, 0)
}
예제 #3
0
func GenerateDemographics() models.Patient {
	patient := models.Patient{}
	patient.Gender = strings.ToLower(fake.Gender())
	name := models.HumanName{}
	var firstName string
	if patient.Gender == "male" {
		firstName = fake.MaleFirstName()
	} else {
		firstName = fake.FemaleFirstName()
	}
	name.Given = []string{firstName}
	name.Family = []string{fake.LastName() + fake.DigitsN(4)}
	patient.Name = []models.HumanName{name}
	patient.BirthDate = &models.FHIRDateTime{Time: RandomBirthDate(), Precision: models.Date}
	patient.Address = []models.Address{GenerateAddress()}
	return patient
}