|
@@ -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 {
|