func retreiveTreatments(w http.ResponseWriter, r *http.Request) errors.Http { t := models.Treatment{} if err := BuildStructFromQueryString(&t, r.URL.Query()); err != nil { return errors.BadRequest(err.Error()) } t.Base.Query = r.URL.Query() treatments, err := t.Retrieve(db) if err != nil { return errors.BadRequest(err.Error()) } if len(treatments) == 0 { return errors.NotFound("record not found") } rend.JSON(w, http.StatusOK, treatments) return nil }
func handleTreatmentApproved(msg []byte) { t := models.Treatment{} if err := json.Unmarshal(msg, &t); err != nil { fmt.Println("[ERROR] ", err.Error()) return } ts, err := t.Retrieve(db) if err != nil { fmt.Println("[ERROR] ", err.Error()) return } if len(ts) != 1 { fmt.Println("[ERROR] Not able to handle treatment approved msg... query for given id returned len != 1") return } createFeedEvent(ts[0]) }