ソースを参照

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

28169 3 ヶ月 前
コミット
8d2c079a43
共有4 個のファイルを変更した101 個の追加63 個の削除を含む
  1. 70 60
      controllers/his_api_controller.go
  2. 28 0
      models/his_models.go
  3. 2 2
      service/his_service.go
  4. 1 1
      service/patient_service.go

+ 70 - 60
controllers/his_api_controller.go ファイルの表示

@@ -106,69 +106,79 @@ func HisManagerApiRegistRouters() {
106 106
 
107 107
 	beego.Router("/api/getfapiaonumber", &HisApiController{}, "get:GetFaPiaoNumber")
108 108
 
109
-	//beego.Router("/api/associationprescription", &HisApiController{}, "get:AssociationHisPrescription")
110
-	//beego.Router("/api/checkhispatient", &HisApiController{}, "get:CheckHisPatient")
109
+	beego.Router("/api/associationprescription", &HisApiController{}, "get:AssociationHisPrescription")
110
+	beego.Router("/api/checkhispatient", &HisApiController{}, "get:CheckHisPatient")
111 111
 
112 112
 }
113 113
 
114
-//func (c *HisApiController) CheckHisPatient() {
115
-//	record_date := c.GetString("record_date")
116
-//	patient_id, _ := c.GetInt64("patient_id")
117
-//
118
-//	timeLayout := "2006-01-02"
119
-//	loc, _ := time.LoadLocation("Local")
120
-//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
121
-//	if err != nil {
122
-//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
123
-//		return
124
-//	}
125
-//	recordDateTime := theTime.Unix()
126
-//	adminInfo := c.GetAdminUserInfo()
127
-//	patients, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient_id, recordDateTime)
128
-//	if len(patients) > 1 {
129
-//		ps, _ := service.GetHisPrescriptionByHisPatientID(recordDateTime, adminInfo.CurrentOrgId, patient_id)
130
-//		if len(ps) > 0 {
131
-//			c.ServeSuccessJSON(map[string]interface{}{
132
-//				"status": 1,
133
-//				"msg":    "关联",
134
-//				"ps":     ps,
135
-//			})
136
-//		} else {
137
-//			c.ServeSuccessJSON(map[string]interface{}{
138
-//				"status": 0,
139
-//				"msg":    "无需关联",
140
-//			})
141
-//		}
142
-//	} else {
143
-//		c.ServeSuccessJSON(map[string]interface{}{
144
-//			"status": 0,
145
-//			"msg":    "无需关联",
146
-//		})
147
-//		return
148
-//	}
149
-//}
150
-//func (c *HisApiController) AssociationHisPrescription() {
151
-//	record_date, _ := c.GetInt64("record_date")
152
-//	his_patient_id, _ := c.GetInt64("his_patient_id")
153
-//	patient_id, _ := c.GetInt64("patient_id")
154
-//	p_ids := c.GetString("p_ids")
155
-//	p_ids_arr := strings.Split(p_ids, ",")
156
-//	his_patient, _ := service.GetHisPatientByIdThree(his_patient_id)
157
-//	if his_patient_id == 0 || his_patient.ID == 0 {
158
-//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
159
-//		return
160
-//	}
161
-//	err := service.UpdateHisPrescriptionHisIDByPID(his_patient_id, patient_id, record_date, c.GetAdminUserInfo().CurrentOrgId, p_ids_arr)
162
-//	if err == nil {
163
-//		c.ServeSuccessJSON(map[string]interface{}{
164
-//			"msg": "关联处方成功",
165
-//		})
166
-//		return
167
-//	} else {
168
-//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
169
-//		return
170
-//	}
171
-//}
114
+func (c *HisApiController) CheckHisPatient() {
115
+	record_date := c.GetString("record_date")
116
+	patient_id, _ := c.GetInt64("patient_id")
117
+
118
+	timeLayout := "2006-01-02"
119
+	loc, _ := time.LoadLocation("Local")
120
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
121
+	if err != nil {
122
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
123
+		return
124
+	}
125
+	recordDateTime := theTime.Unix()
126
+	adminInfo := c.GetAdminUserInfo()
127
+	patients, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient_id, recordDateTime)
128
+	if len(patients) > 1 {
129
+		ps, _ := service.GetHisPrescriptionByHisPatientID(recordDateTime, adminInfo.CurrentOrgId, patient_id)
130
+		if len(ps) > 0 {
131
+			c.ServeSuccessJSON(map[string]interface{}{
132
+				"status":         1,
133
+				"msg":            "关联",
134
+				"ps":             ps,
135
+				"his_patient_id": patients[len(patients)-1].ID,
136
+				"patient_id":     patients[len(patients)-1].PatientId,
137
+			})
138
+		} else {
139
+			c.ServeSuccessJSON(map[string]interface{}{
140
+				"status": 0,
141
+				"msg":    "无需关联",
142
+			})
143
+		}
144
+	} else {
145
+		c.ServeSuccessJSON(map[string]interface{}{
146
+			"status": 0,
147
+			"msg":    "无需关联",
148
+		})
149
+		return
150
+	}
151
+}
152
+func (c *HisApiController) AssociationHisPrescription() {
153
+	record_date := c.GetString("record_date")
154
+	his_patient_id, _ := c.GetInt64("his_patient_id")
155
+	patient_id, _ := c.GetInt64("patient_id")
156
+	p_ids := c.GetString("p_ids")
157
+	p_ids_arr := strings.Split(p_ids, ",")
158
+	timeLayout := "2006-01-02"
159
+	loc, _ := time.LoadLocation("Local")
160
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
161
+	if err != nil {
162
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
163
+		return
164
+	}
165
+	recordDateTime := theTime.Unix()
166
+	his_patient, _ := service.GetHisPatientByIdThree(his_patient_id)
167
+	if his_patient_id == 0 || his_patient.ID == 0 {
168
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
169
+		return
170
+	}
171
+	err = service.UpdateHisPrescriptionHisIDByPID(his_patient_id, patient_id, recordDateTime, c.GetAdminUserInfo().CurrentOrgId, p_ids_arr)
172
+	if err == nil {
173
+		c.ServeSuccessJSON(map[string]interface{}{
174
+			"msg": "关联处方成功",
175
+		})
176
+		return
177
+	} else {
178
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
179
+		return
180
+	}
181
+}
172 182
 
173 183
 //func (c *HisApiController) AssociationHisPrescription() {
174 184
 //	record_date, _ := c.GetInt64("record_date")

+ 28 - 0
models/his_models.go ファイルの表示

@@ -2676,3 +2676,31 @@ type PatientTwos struct {
2676 2676
 func (PatientTwos) TableName() string {
2677 2677
 	return "xt_patients"
2678 2678
 }
2679
+
2680
+type HisPrescriptionTen struct {
2681
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
2682
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2683
+	RecordDate         int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
2684
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2685
+	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
2686
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
2687
+	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2688
+	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2689
+	Number             string `gorm:"column:number" json:"number" form:"number"`
2690
+	Type               int64  `gorm:"column:type" json:"type" form:"type"`
2691
+	Doctor             string `gorm:"column:doctor" json:"doctor" form:"doctor"`
2692
+	Creator            int64  `gorm:"column:creator" json:"creator" form:"creator"`
2693
+	Modifier           int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
2694
+	OrderStatus        int64  `gorm:"column:order_status" json:"order_status" form:"order_status"`
2695
+	PreTime            int64  `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
2696
+	BatchNumber        string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
2697
+	PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
2698
+	Total              string `gorm:"-" json:"total" form:"total"`
2699
+	PType              int64  `gorm:"column:p_type" json:"p_type" form:"p_type"`
2700
+	MedType            string `gorm:"column:med_type" json:"med_type" form:"med_type"`
2701
+	IsMedicine         int64  `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
2702
+}
2703
+
2704
+func (HisPrescriptionTen) TableName() string {
2705
+	return "his_prescription"
2706
+}

+ 2 - 2
service/his_service.go ファイルの表示

@@ -2920,7 +2920,7 @@ func GetLastHisOrderTwo(org_id int64) (his models.HisOrder, err error) {
2920 2920
 //}
2921 2921
 
2922 2922
 func GetHisPrescriptionByHisPatientID(record_date int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
2923
-	err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date >= ? AND record_date <= ? AND p_type = ? and order_status = 1", patient_id, org_id, record_date, record_date, 1).
2923
+	err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date >= ? AND record_date <= ? AND p_type = ?", patient_id, org_id, record_date, record_date, 2).
2924 2924
 		Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
2925 2925
 			return db.Where("status = 1 AND user_org_id = ?", org_id).
2926 2926
 				Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
@@ -2928,7 +2928,7 @@ func GetHisPrescriptionByHisPatientID(record_date int64, org_id int64, patient_i
2928 2928
 				}).
2929 2929
 				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2930 2930
 					return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status = 1")
2931
-				})
2931
+				}).Where("status = 1 and order_status = 1")
2932 2932
 		}).Order("record_date desc").Find(&advice).Error
2933 2933
 
2934 2934
 	return

+ 1 - 1
service/patient_service.go ファイルの表示

@@ -1664,7 +1664,7 @@ func MobileGetMonitorsWithPatient(orgID int64, keyword string, page int) ([]*mod
1664 1664
 }
1665 1665
 
1666 1666
 func GetPatientByKeyWord(orgID int64, keywords string) (patient []*models.Patients, err error) {
1667
-	db := readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1", orgID)
1667
+	db := readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and  lapseto = 1", orgID)
1668 1668
 
1669 1669
 	if len(keywords) > 0 {
1670 1670
 		likekey := "%" + keywords + "%"