Example #1
0
func sendTreatmentCreated(t *models.Treatment) {
	topic, _ := common_io.BuildTopicFromCommonEvent(common_io.EVENT_CREATED, "treatment")

	/*
	*	marshal
	 */

	patient := models.Patient{}
	patient.ID = t.PatientId
	ps, err := patient.Retrieve(db)
	if err != nil {
		fmt.Println("[ERROR] ", err.Error())
		return
	}

	if len(ps) != 1 {
		fmt.Println("[FATAL] More then one patient with the same ID...")
		return
	}

	t.Email = ps[0].Email

	b, err := json.Marshal(&t)
	if err != nil {
		fmt.Println("[ERROR] ", err.Error())
		return
	}

	producer.Publish(topic, b)
}
Example #2
0
/*
*	Senders
 */
func sendBoxCreated(box models.Box) {
	topic, _ := common_io.BuildTopicFromCommonEvent(common_io.EVENT_CREATED, "box")
	/*
	 * json Marshal
	 */
	b, err := json.Marshal(&box)
	if err != nil {
		fmt.Println("[ERROR] ", err.Error())
		return
	}

	producer.Publish(topic, b)
}
Example #3
0
/*
*	Senders
 */
func sendUserCreated(usr *models.User) {
	topic, _ := common_io.BuildTopicFromCommonEvent(common_io.EVENT_CREATED, "user")
	b, err := json.Marshal(usr)
	if err != nil {
		fmt.Println("[ERROR] ", err.Error())
		return
	}

	m := mailer.Mail{
		To:      []string{usr.Email},
		Subject: "Bem Vindo!",
		Body:    mailer.TemplateWelcome,
	}

	mMsg, _ := json.Marshal(m)

	producer.Publish("send_mail", mMsg)
	producer.Publish(topic, b)
}
Example #4
0
/*
*	Senders
 */
func sendProductCreated(m *models.Medication) {
	topic, _ := common_io.BuildTopicFromCommonEvent(common_io.EVENT_CREATED, "product")
	p := warehouseModels.Product{}

	/*
	*	Bind
	 */
	p.ID = m.ID
	p.Name = m.Name

	/*
	*	json Marshal
	 */
	b, err := json.Marshal(&p)
	if err != nil {
		fmt.Println("[ERROR] ", err.Error())
		return
	}

	producer.Publish(topic, b)
}