his_config_service.go 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package service
  2. import (
  3. "Xcx_New/models"
  4. "time"
  5. )
  6. func GetHisPrescriptionTemplatesList(patient_id int64, org_id int64, page int64, limit int64) (templates []*models.HisPrescriptionTemplate, total int64, err error) {
  7. offset := (page - 1) * limit
  8. db := readDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND patient_id= ? AND status = 1", org_id, patient_id)
  9. err = db.Count(&total).Offset(offset).Limit(limit).Find(&templates).Error
  10. return
  11. }
  12. func GetHisPrescriptionTemplateByID(template_id int64) (prescription models.HisPrescriptionTemplate, err error) {
  13. err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("id = ? AND status = 1 ", template_id).First(&prescription).Error
  14. return
  15. }
  16. func SaveHisPrescriptionTemplate(template *models.HisPrescriptionTemplate) (err error) {
  17. err = writeDb.Save(&template).Error
  18. return
  19. }
  20. func DelelteHisPrescriptionInfoTemplate(id int64, user_org_id int64) (err error) {
  21. err = writeDb.Model(&models.HisPrescriptionInfoTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  22. err = writeDb.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? AND prescription_id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  23. err = writeDb.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? AND prescription_id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  24. return
  25. }
  26. func DelelteHisPrescriptionTemplate(id int64, user_org_id int64) (err error) {
  27. err = writeDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
  28. err = writeDb.Model(&models.HisPrescriptionInfoTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  29. return
  30. }
  31. func DelelteHisPrescriptionAdviceTemplate(id int64, user_org_id int64) (err error) {
  32. err = writeDb.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  33. return
  34. }
  35. func DelelteHisPrescriptionProjectTemplate(id int64, user_org_id int64) (err error) {
  36. err = writeDb.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
  37. return
  38. }