Quellcode durchsuchen

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

28169 vor 2 Monaten
Ursprung
Commit
dc8a0794dc
2 geänderte Dateien mit 71 neuen und 63 gelöschten Zeilen
  1. 70 62
      controllers/his_api_controller.go
  2. 1 1
      service/his_service.go

+ 70 - 62
controllers/his_api_controller.go Datei anzeigen

@@ -72,9 +72,7 @@ func HisManagerApiRegistRouters() {
72 72
 	beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
73 73
 	//beego.Router("/api/editprojectinformation", &HisApiController{}, "post:EditProjectInformation")
74 74
 	beego.Router("/api/hisprescriptiontemplate/create", &HisApiController{}, "post:CreateHisPrescriptionTemplate")
75
-
76 75
 	beego.Router("/api/privateexpenses/get", &HisApiController{}, "get:GetPrivateExpensesInfo")
77
-
78 76
 	beego.Router("/api/changemedtype/post", &HisApiController{}, "post:ChangeMedType")
79 77
 
80 78
 	beego.Router("/api/refunddetail/post", &HisApiController{}, "post:RefudDetail")
@@ -106,69 +104,79 @@ func HisManagerApiRegistRouters() {
106 104
 
107 105
 	beego.Router("/api/getfapiaonumber", &HisApiController{}, "get:GetFaPiaoNumber")
108 106
 
109
-	//beego.Router("/api/associationprescription", &HisApiController{}, "get:AssociationHisPrescription")
110
-	//beego.Router("/api/checkhispatient", &HisApiController{}, "get:CheckHisPatient")
107
+	beego.Router("/api/associationprescription", &HisApiController{}, "get:AssociationHisPrescription")
108
+	beego.Router("/api/checkhispatient", &HisApiController{}, "get:CheckHisPatient")
111 109
 
112 110
 }
113 111
 
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
-//}
112
+func (c *HisApiController) CheckHisPatient() {
113
+	record_date := c.GetString("record_date")
114
+	patient_id, _ := c.GetInt64("patient_id")
115
+
116
+	timeLayout := "2006-01-02"
117
+	loc, _ := time.LoadLocation("Local")
118
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
119
+	if err != nil {
120
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
121
+		return
122
+	}
123
+	recordDateTime := theTime.Unix()
124
+	adminInfo := c.GetAdminUserInfo()
125
+	patients, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient_id, recordDateTime)
126
+	if len(patients) > 1 {
127
+		ps, _ := service.GetHisPrescriptionByHisPatientID(recordDateTime, adminInfo.CurrentOrgId, patient_id)
128
+		if len(ps) > 0 && len(ps[0].VMHisPrescription) > 0 {
129
+			c.ServeSuccessJSON(map[string]interface{}{
130
+				"status":         1,
131
+				"msg":            "关联",
132
+				"ps":             ps,
133
+				"his_patient_id": patients[len(patients)-1].ID,
134
+				"patient_id":     patients[len(patients)-1].PatientId,
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.GetString("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
+	timeLayout := "2006-01-02"
157
+	loc, _ := time.LoadLocation("Local")
158
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
159
+	if err != nil {
160
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
161
+		return
162
+	}
163
+	recordDateTime := theTime.Unix()
164
+	his_patient, _ := service.GetHisPatientByIdThree(his_patient_id)
165
+	if his_patient_id == 0 || his_patient.ID == 0 {
166
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
167
+		return
168
+	}
169
+	err = service.UpdateHisPrescriptionHisIDByPID(his_patient_id, patient_id, recordDateTime, c.GetAdminUserInfo().CurrentOrgId, p_ids_arr)
170
+	if err == nil {
171
+		c.ServeSuccessJSON(map[string]interface{}{
172
+			"msg": "关联处方成功",
173
+		})
174
+		return
175
+	} else {
176
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
177
+		return
178
+	}
179
+}
172 180
 
173 181
 //func (c *HisApiController) AssociationHisPrescription() {
174 182
 //	record_date, _ := c.GetInt64("record_date")

+ 1 - 1
service/his_service.go Datei anzeigen

@@ -944,7 +944,7 @@ func FindPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int
944 944
 }
945 945
 
946 946
 func FindPatientPrescriptionInfoTen(org_id int64, patient_id int64, start_time int64, end_time int64, p_type int64) (info []models.HisPrescriptionInfo, err error) {
947
-	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date >= ? and record_date <= ? AND patient_id = ? AND p_type = ?", org_id, start_time, end_time, patient_id, p_type).First(&info).Error
947
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date >= ? and record_date <= ? AND patient_id = ? AND p_type = ?", org_id, start_time, end_time, patient_id, p_type).Find(&info).Error
948 948
 	return
949 949
 
950 950
 }