func GeneratePatient() []interface{} { ctx := NewContext() pt := GenerateDemographics() ctx.Height, ctx.Weight = initialHeightAndWeight(pt.Gender) ctx.BirthDate = pt.BirthDate.Time pt.Id = strconv.FormatInt(rand.Int63(), 10) md := LoadConditions() mmd := LoadMedications() conditions := GenerateConditions(ctx, md) var m []interface{} m = append(m, &pt) for i := range conditions { c := conditions[i] c.Patient = &models.Reference{Reference: "cid:" + pt.Id} m = append(m, &c) conditionMetadata := conditionByName(c.Code.Text, md) med := GenerateMedication(conditionMetadata.MedicationID, c.OnsetDateTime, c.AbatementDateTime, mmd) if med != nil { med.Patient = &models.Reference{Reference: "cid:" + pt.Id} m = append(m, med) } } for i := 0; i < 3; i++ { t := time.Now() encounterDate := &models.FHIRDateTime{Time: t.AddDate(-i, rand.Intn(2), rand.Intn(5)), Precision: models.Date} encounter := models.Encounter{} encounter.Id = strconv.FormatInt(rand.Int63(), 10) encounter.Type = []models.CodeableConcept{{Coding: []models.Coding{{Code: "99213", System: "http://www.ama-assn.org/go/cpt"}}, Text: "Office Visit"}} encounter.Period = &models.Period{Start: encounterDate} encounter.Patient = &models.Reference{Reference: "cid:" + pt.Id} m = append(m, &encounter) obs := GenerateBP(ctx) obs = append(obs, GenerateBloodSugars(ctx)...) obs = append(obs, GenerateWeightAndHeight(ctx)...) for j := range obs { o := obs[j] o.EffectiveDateTime = encounterDate o.Subject = &models.Reference{Reference: "cid:" + pt.Id} o.Encounter = &models.Reference{Reference: "cid:" + encounter.Id} m = append(m, &o) } } return m }
func encounterEvent(id, name, snomedCode string, start time.Time) plugin.Event { encounter := new(models.Encounter) encounter.Id = id encounter.Type = []models.CodeableConcept{ { Coding: []models.Coding{ models.Coding{System: "http://snomed.info/sct", Code: snomedCode, Display: name}, }, Text: name, }, } encounter.Period = &models.Period{ Start: &models.FHIRDateTime{Time: start, Precision: models.Timestamp}, } encounter.Status = "finished" return plugin.Event{ Date: start, Type: "Encounter", End: false, Value: encounter, } }