示例#1
0
func handlePatientUpdate(w http.ResponseWriter, r *http.Request) errors.Http {
	p := models.Patient{}

	if err := BuildStructFromReqBody(&p, r.Body); err != nil {
		return errors.BadRequest(err.Error())
	}

	if err := FillPatientIdWIthUrlValue(&p, r.URL.Query()); err != nil {
		return errors.BadRequest(err.Error())
	}

	if err := p.Update(db); err != nil {
		return errors.InternalServerError(err.Error())
	}

	sendPatientUpdated(&p)

	rend.JSON(w, http.StatusOK, p)
	return nil
}