Browse Source

2023-12-25 导入

zoie 1 year ago
parent
commit
a88e14c162
4 changed files with 79 additions and 54 deletions
  1. 2 2
      conf/app.conf
  2. 62 48
      controllers/Patient.go
  3. 2 2
      controllers/User.go
  4. 13 2
      models/Patient/Patient.go

+ 2 - 2
conf/app.conf

@@ -34,9 +34,9 @@ SUBMAIL_Sms_Appid = "95559"
 SUBMAIL_Sms_Signature = "f8e63844edd79d5bd2ab4a3d92c3b820"
 SUBMAIL_Voice_Appid = "22184"
 SUBMAIL_Voice_Signature = "c3e29e10daeea889cd72dd6375b4347e"
-SUBMAIL_Sms_Fee = 0.08
+SUBMAIL_Sms_Fee = 0.1
 SUBMAIL_Voice_Project = "vTHhS1"
-SUBMAIL_VoiceCall_Fee = 0.12
+SUBMAIL_VoiceCall_Fee = 0.15
 
 VoiceCall_BaseUrl = "https://rtccall.cn-north-1.myhuaweicloud.cn:443"
 VoiceCall_AppKey = "Zy8539Sa61Iv5fo5iGNWLcV24KI1"

+ 62 - 48
controllers/Patient.go

@@ -89,7 +89,8 @@ func (c *PatientController) Patient_Add() {
 
 	T_number := c.GetString("T_number")
 	T_name := c.GetString("T_name")
-	T_age, _ := c.GetInt("T_age")
+	//T_age, _ := c.GetInt("T_age")
+	T_age := c.GetString("T_age")
 	T_tag := c.GetString("T_tag")
 	T_illness, _ := c.GetInt("T_illness")
 	T_surgical, _ := c.GetInt("T_surgical")
@@ -140,7 +141,7 @@ func (c *PatientController) Patient_Add() {
 			var_.T_next_time = psr.T_date
 			var_.T_notice = psr.T_notice
 			if err = Patient.Update_Patient(var_, "T_next_time", "T_notice"); err != nil {
-				c.Data["json"] = lib.JSONS{Code: 208, Msg: "添加失败!"}
+				c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
 				c.ServeJSON()
 				return
 			}
@@ -161,7 +162,8 @@ func (c *PatientController) Patient_Edit() {
 	T_uuid := c.GetString("T_uuid")
 	T_number := c.GetString("T_number")
 	T_name := c.GetString("T_name")
-	T_age, _ := c.GetInt("T_age")
+	//T_age, _ := c.GetInt("T_age")
+	T_age := c.GetString("T_age")
 	T_tag := c.GetString("T_tag")
 	T_illness, _ := c.GetInt("T_illness")
 	T_surgical, _ := c.GetInt("T_surgical")
@@ -189,12 +191,24 @@ func (c *PatientController) Patient_Edit() {
 	if len(T_number) > 0 {
 		patient.T_number = T_number
 		cols = append(cols, "T_number")
+		patient2, err := Patient.Read_Patient_ByT_number(T_number, c.User.Id)
+		if err != nil && err.Error() != orm.ErrNoRows.Error() {
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
+			c.ServeJSON()
+			return
+		}
+		if patient2.Id > 0 && patient2.Id != patient.Id {
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "病例号已存在!"}
+			c.ServeJSON()
+			return
+		}
+
 	}
 	if len(T_name) > 0 {
 		patient.T_name = T_name
 		cols = append(cols, "T_name")
 	}
-	if T_age > 0 {
+	if len(T_age) > 0 {
 		patient.T_age = T_age
 		cols = append(cols, "T_age")
 	}
@@ -246,7 +260,7 @@ func (c *PatientController) Patient_Edit() {
 	}
 
 	if err = Patient.Update_Patient(patient, cols...); err != nil {
-		c.Data["json"] = lib.JSONS{Code: 208, Msg: "修改失败!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -455,7 +469,7 @@ func (c *PatientController) PatientRevisitRecord_Del() {
 		patient.T_next_time = ""
 		patient.T_notice = 0
 		if err = Patient.Update_Patient(patient, "T_next_time", "T_notice"); err != nil {
-			c.Data["json"] = lib.JSONS{Code: 208, Msg: "修改失败!"}
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
 			c.ServeJSON()
 			return
 		}
@@ -466,7 +480,7 @@ func (c *PatientController) PatientRevisitRecord_Del() {
 		patient.T_next_time = psr.T_date
 		patient.T_notice = psr.T_notice
 		if err = Patient.Update_Patient(patient, "T_next_time", "T_notice"); err != nil {
-			c.Data["json"] = lib.JSONS{Code: 208, Msg: "修改失败!"}
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
 			c.ServeJSON()
 			return
 		}
@@ -485,7 +499,7 @@ func (c *PatientController) PatientRevisitRecord_Del() {
 			//	patient.T_follow_up = 2
 			//}
 			if err = Patient.Update_Patient(patient, "T_next_time", "T_notice"); err != nil {
-				c.Data["json"] = lib.JSONS{Code: 208, Msg: "修改失败!"}
+				c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
 				c.ServeJSON()
 				return
 			}
@@ -672,37 +686,39 @@ func (c *PatientController) Patient_Import() {
 
 	T_number := c.GetString("T_number")
 	T_name := c.GetString("T_name")
-	T_age, _ := c.GetInt("T_age")
+	T_age := c.GetString("T_age")
+	//T_age, _ := c.GetInt("T_age")
 
 	T_tag := c.GetString("T_tag")
 
-	T_tag_list := strings.Split(strings.Trim(T_tag, " "), "、")
 	tagIdList := []string{}
-	for _, t := range T_tag_list {
-		id, err := Tag.ReadOrCreate_Tag(Tag.Tag{
-			T_uid:   c.User.Id,
-			T_name:  t,
-			T_State: 1,
-		})
-
-		if err != nil {
-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加标签失败!"}
-			c.ServeJSON()
-			return
+	if len(T_tag) > 0 {
+		T_tag_list := strings.Split(strings.TrimSpace(T_tag), "、")
+		for _, t := range T_tag_list {
+			id, err := Tag.ReadOrCreate_Tag(Tag.Tag{
+				T_uid:   c.User.Id,
+				T_name:  t,
+				T_State: 1,
+			})
+			if err != nil {
+				c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加标签失败!"}
+				c.ServeJSON()
+				return
+			}
+			tagIdList = append(tagIdList, strconv.Itoa(int(id)))
 		}
-		tagIdList = append(tagIdList, strconv.Itoa(int(id)))
 	}
 
 	T_illness := c.GetString("T_illness")
 	illnesslId, err := Illness.ReadOrCreate_Illness(Illness.Illness{
 		T_uid:   c.User.Id,
-		T_name:  T_illness,
+		T_name:  strings.TrimSpace(T_illness),
 		T_State: 1,
 	})
 	T_surgical := c.GetString("T_surgical")
 	surgicalId, err := Surgical.ReadOrCreate_Surgical(Surgical.Surgical{
 		T_uid:   c.User.Id,
-		T_name:  T_surgical,
+		T_name:  strings.TrimSpace(T_surgical),
 		T_State: 1,
 	})
 	if err != nil {
@@ -722,15 +738,11 @@ func (c *PatientController) Patient_Import() {
 	if strings.Contains(T_notice_message, "是") {
 		message = 1
 	}
-	// 下次复诊间隔天数
-	//T_next_interval := c.GetString("T_next_interval")
-	//T_record := time.Now().Format("2006-01-02") + "," + T_next_interval + "|"
 	var_ := Patient.Patient{
 		T_uid:             c.User.Id,
 		T_number:          T_number,
 		T_name:            T_name,
 		T_age:             T_age,
-		T_tag:             "|" + strings.Join(tagIdList, "|") + "|",
 		T_illness:         int(illnesslId),
 		T_surgical:        int(surgicalId),
 		T_phone:           T_phone,
@@ -740,26 +752,28 @@ func (c *PatientController) Patient_Import() {
 		//T_record:          T_record,
 		T_State: 1,
 	}
-	//T_record_list := strings.Split(strings.Trim(T_record, "|"), "|")
-	//var T_time string  // 复诊时间
-	//var T_interval int // 复诊间隔
-	//if len(T_record_list) > 0 {
-	//	temp := T_record_list[len(T_record_list)-1]
-	//	T_time = strings.Split(temp, ",")[0]
-	//	T_interval, _ = strconv.Atoi(strings.Split(temp, ",")[1])
-	//	t, _ := lib.DateStrToTime(T_time)
-	//	nextTime := t.AddDate(0, 0, T_interval)
-	//	// 复诊状态 1正常 2超时 3结束
-	//	var_.T_follow_up = 1
-	//	if nextTime.Before(time.Now()) {
-	//		var_.T_follow_up = 2
-	//	}
-	//	if T_interval == 0 {
-	//		var_.T_follow_up = 3
-	//	}
-	//	var_.T_next_time = nextTime.Format("2006-01-02")
-	//	var_.T_notice = 1
-	//}
+	if len(tagIdList) > 0 {
+		var_.T_tag = "|" + strings.Join(tagIdList, "|") + "|"
+	}
+
+	patient, err := Patient.Read_Patient_ByT_number(T_number, c.User.Id)
+	if err != nil && err.Error() != orm.ErrNoRows.Error() {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "添加失败!"}
+		c.ServeJSON()
+		return
+	}
+	if patient.Id > 0 {
+		var_.Id = patient.Id
+		cols := []string{"T_name", "T_age", "T_illness", "T_surgical", "T_phone", "T_notice_phone", "T_notice_message", "T_notice_interval", "T_tag"}
+		if err = Patient.Update_Patient(var_, cols...); err != nil {
+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
+			c.ServeJSON()
+			return
+		}
+		c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
+		c.ServeJSON()
+		return
+	}
 
 	_, err = Patient.Add_Patient(var_)
 	if err != nil {

+ 2 - 2
controllers/User.go

@@ -165,7 +165,7 @@ func (c *UserController) Add() {
 		return
 	}
 	if len(T_pass) < 6 {
-		c.Data["json"] = lib.JSONS{Code: 208, Msg: "密码异常!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "密码异常!"}
 		c.ServeJSON()
 		return
 	}
@@ -269,7 +269,7 @@ func (c *UserController) Edit() {
 	}
 
 	if err = Account.Update_User(user, cols...); err != nil {
-		c.Data["json"] = lib.JSONS{Code: 208, Msg: "修改失败!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
 		c.ServeJSON()
 		return
 	}

+ 13 - 2
models/Patient/Patient.go

@@ -22,7 +22,7 @@ type Patient struct {
 	T_uid             int    `orm:"size(200);null"` // 关联的用户id
 	T_number          string `orm:"size(256);null"` // 病历号
 	T_name            string `orm:"size(256);null"` // 姓名
-	T_age             int    `orm:"size(200);null"` // 年轻
+	T_age             string `orm:"size(200);null"` // 年轻
 	T_tag             string `orm:"size(200);null"` // 标签
 	T_illness         int    `orm:"size(200);null"` // 诊断
 	T_surgical        int    `orm:"size(200);null"` // 术式
@@ -44,7 +44,7 @@ type Patient_R struct {
 	T_uid             int      // 关联的用户id
 	T_number          string   // 病历号
 	T_name            string   // 姓名
-	T_age             int      // 年轻
+	T_age             string   // 年轻
 	T_tag_str         string   // 标签
 	T_tag             []int    // 标签
 	T_tag_List        []string // 标签
@@ -167,6 +167,17 @@ func Read_Patient_ById(Id int) (r Patient, err error) {
 	return
 }
 
+// 获取 ByT_number
+func Read_Patient_ByT_number(T_number string, T_uid int) (r Patient, err error) {
+	o := orm.NewOrm()
+	qs := o.QueryTable(new(Patient))
+	err = qs.Filter("T_number", T_number).Filter("T_uid", T_uid).Filter("T_State", 1).One(&r)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+	}
+	return
+}
+
 // 修改
 func Update_Patient(m Patient, cols ...string) error {
 	o := orm.NewOrm()