ソースを参照

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

XMLWAN 4 年 前
コミット
a99447fb27

+ 4 - 4
controllers/base_api_controller.go ファイルの表示

@@ -81,7 +81,7 @@ func (this *BaseAuthAPIController) Prepare() {
81 81
 		userAdmin.ModifyTime = 1530786071
82 82
 		var subscibe models.ServeSubscibe
83 83
 		subscibe.ID = 1
84
-		subscibe.OrgId = 3877
84
+		subscibe.OrgId = 4
85 85
 		subscibe.PeriodStart = 1538035409
86 86
 		subscibe.PeriodEnd = 1569571409
87 87
 		subscibe.State = 1
@@ -91,7 +91,7 @@ func (this *BaseAuthAPIController) Prepare() {
91 91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92 92
 		subscibes[4] = &subscibe
93 93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 3877
94
+		adminUserInfo.CurrentOrgId = 4
95 95
 		adminUserInfo.CurrentAppId = 18
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
@@ -326,7 +326,7 @@ func (this *BaseServeAPIController) Prepare() {
326 326
 		userAdmin.ModifyTime = 1530786071
327 327
 		var subscibe models.ServeSubscibe
328 328
 		subscibe.ID = 1
329
-		subscibe.OrgId = 3877
329
+		subscibe.OrgId = 4
330 330
 		subscibe.PeriodStart = 1538035409
331 331
 		subscibe.PeriodEnd = 1569571409
332 332
 		subscibe.State = 1
@@ -337,7 +337,7 @@ func (this *BaseServeAPIController) Prepare() {
337 337
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
338 338
 		subscibes[4] = &subscibe
339 339
 		var adminUserInfo service.AdminUserInfo
340
-		adminUserInfo.CurrentOrgId = 3877
340
+		adminUserInfo.CurrentOrgId = 4
341 341
 		adminUserInfo.CurrentAppId = 18
342 342
 		adminUserInfo.AdminUser = &userAdmin
343 343
 		adminUserInfo.Subscibes = subscibes

+ 680 - 0
controllers/his_api_controller.go ファイルの表示

@@ -0,0 +1,680 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
9
+	"github.com/astaxie/beego"
10
+	"reflect"
11
+	"strconv"
12
+	"strings"
13
+	"time"
14
+)
15
+
16
+type HisApiController struct {
17
+	BaseAuthAPIController
18
+}
19
+
20
+func HisManagerApiRegistRouters() {
21
+
22
+	beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
23
+	beego.Router("/api/hispatient/get", &HisApiController{}, "get:GetHisPatientInfo")
24
+	beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
25
+
26
+	beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
27
+	beego.Router("/api/hisdoctoradvice/create", &HisApiController{}, "post:CreateHisDoctorAdvice")
28
+	//beego.Router("/api/hisproject/create", &HisApiController{}, "post:CreateHisProject")
29
+	//beego.Router("/api/hisorder/create", &HisApiController{}, "post:CreateHisOrder")
30
+	//beego.Router("/api/hisadditional/create", &HisApiController{}, "post:CreateHisAdditionalCharge")
31
+
32
+	beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
33
+	beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
34
+	beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "post:CreateHisPatientCaseHistory")
35
+	beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "post:CreateCaseHistoryTemplate")
36
+	beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
37
+	beego.Router("/api/doctorworkstation/printcasehistory/get", &HisApiController{}, "get:GetPrintHisPatientCaseHistory")
38
+
39
+}
40
+
41
+func (c *HisApiController) GetHisPatientList() {
42
+	types, _ := c.GetInt64("type", 0)
43
+	record_date := c.GetString("record_date")
44
+	timeLayout := "2006-01-02"
45
+	loc, _ := time.LoadLocation("Local")
46
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
47
+	if err != nil {
48
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
49
+		return
50
+	}
51
+	recordDateTime := theTime.Unix()
52
+	adminInfo := c.GetAdminUserInfo()
53
+	patients, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
54
+	if types == 0 {
55
+		c.ServeSuccessJSON(map[string]interface{}{
56
+			"list": patients,
57
+		})
58
+
59
+	} else if types == 1 { //未就诊
60
+		var patientsOne []*service.Schedule
61
+		for _, item := range patients {
62
+			if item.HisPrescription == nil || len(item.HisPrescription) <= 0 {
63
+				patientsOne = append(patientsOne, item)
64
+			}
65
+		}
66
+		c.ServeSuccessJSON(map[string]interface{}{
67
+			"list": patientsOne,
68
+		})
69
+
70
+	} else if types == 2 { //已就诊
71
+		var patientsTwo []*service.Schedule
72
+		for _, item := range patients {
73
+			if item.HisPrescription != nil && len(item.HisPrescription) > 0 {
74
+				patientsTwo = append(patientsTwo, item)
75
+			}
76
+		}
77
+		c.ServeSuccessJSON(map[string]interface{}{
78
+			"list": patientsTwo,
79
+		})
80
+	}
81
+
82
+}
83
+func (c *HisApiController) GetHisPatientInfo() {
84
+	patient_id, _ := c.GetInt64("patient_id")
85
+	record_date := c.GetString("record_date")
86
+	timeLayout := "2006-01-02"
87
+	loc, _ := time.LoadLocation("Local")
88
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
89
+	if err != nil {
90
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
91
+		return
92
+	}
93
+	recordDateTime := theTime.Unix()
94
+
95
+	admin := c.GetAdminUserInfo()
96
+	his_patient_info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, recordDateTime)
97
+	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
98
+
99
+	prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
100
+
101
+	//prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
102
+	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
103
+
104
+	c.ServeSuccessJSON(map[string]interface{}{
105
+		"his_info":     his_patient_info,
106
+		"xt_info":      xt_patient_info,
107
+		"prescription": prescriptions,
108
+		"case_history": case_history,
109
+	})
110
+	return
111
+
112
+}
113
+func (c *HisApiController) GetHisPrescriptionConfig() {
114
+	adminInfo := c.GetAdminUserInfo()
115
+	//获取医嘱模版
116
+	advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
117
+	//获取所有基础药
118
+	drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
119
+	//获取所有项目
120
+	projects, _ := service.GetAllProjectList(adminInfo.CurrentOrgId)
121
+	//获取所有项目组套
122
+
123
+	c.ServeSuccessJSON(map[string]interface{}{
124
+		"drugs":            drugs,
125
+		"advices_template": advices,
126
+		"projects":         projects,
127
+	})
128
+}
129
+func (c *HisApiController) CreateHisPrescription() {
130
+	record_date := c.GetString("record_date")
131
+	patient_id, _ := c.GetInt64("patient_id")
132
+	his_patient_id, _ := c.GetInt64("his_patient_id")
133
+	types, _ := c.GetInt64("type")
134
+	doctor := c.GetAdminUserInfo().AdminUser.Id
135
+
136
+	timeLayout := "2006-01-02"
137
+	loc, _ := time.LoadLocation("Local")
138
+
139
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
140
+	if err != nil {
141
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
142
+		return
143
+	}
144
+	recordDateTime := theTime.Unix()
145
+
146
+	prescription := &models.HisPrescription{
147
+		UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
148
+		RecordDate:   recordDateTime,
149
+		PatientId:    patient_id,
150
+		HisPatientId: his_patient_id,
151
+		Status:       1,
152
+		Ctime:        time.Now().Unix(),
153
+		Mtime:        time.Now().Unix(),
154
+		Type:         types,
155
+		Doctor:       doctor,
156
+		Creator:      doctor,
157
+		Modifier:     doctor,
158
+	}
159
+
160
+	err = service.SaveHisPrescription(prescription)
161
+	if err == nil {
162
+		c.ServeSuccessJSON(map[string]interface{}{
163
+			"msg": "保存成功",
164
+		})
165
+		return
166
+
167
+	} else {
168
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
169
+		return
170
+	}
171
+}
172
+func (c *HisApiController) CreateHisDoctorAdvice() {
173
+	patient_id, _ := c.GetInt64("patient_id")
174
+	his_patient_id, _ := c.GetInt64("his_patient_id")
175
+	prescription_id, _ := c.GetInt64("prescription_id")
176
+
177
+	//patient, _ := c.GetInt64("id", 0)
178
+	//if patient <= 0 {
179
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
180
+	//	return
181
+	//}
182
+	adminUserInfo := c.GetAdminUserInfo()
183
+
184
+	//patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
185
+	//if patientInfo.ID == 0 {
186
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
187
+	//	return
188
+	//}
189
+
190
+	group_no, _ := c.GetInt64("group_no")
191
+	if group_no <= 0 {
192
+		group_no = 0
193
+	}
194
+
195
+	dataBody := make(map[string]interface{}, 0)
196
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
197
+	if err != nil {
198
+		utils.ErrorLog(err.Error())
199
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
200
+		return
201
+	}
202
+
203
+	timeLayout := "2006-01-02"
204
+	loc, _ := time.LoadLocation("Local")
205
+
206
+	if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
207
+		utils.ErrorLog("advice_type")
208
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
209
+		return
210
+	}
211
+	adviceType := int64(dataBody["advice_type"].(float64))
212
+	if adviceType != 1 && adviceType != 2 {
213
+		utils.ErrorLog("advice_type != 1&&2")
214
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
215
+		return
216
+	}
217
+
218
+	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
219
+		utils.ErrorLog("start_time")
220
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
221
+		return
222
+	}
223
+
224
+	startTime2, _ := dataBody["start_time"].(string)
225
+	time_arr := strings.Split(startTime2, " ")
226
+	if len(time_arr) > 0 {
227
+		startTime2 = time_arr[0]
228
+	}
229
+	if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
230
+		utils.ErrorLog("advice_date")
231
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
232
+		return
233
+	}
234
+	adviceDate := startTime2
235
+	if len(adviceDate) == 0 {
236
+		utils.ErrorLog("len(adviceDate) == 0")
237
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
238
+		return
239
+	}
240
+	theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
241
+	if err != nil {
242
+		utils.ErrorLog(err.Error())
243
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
244
+		return
245
+	}
246
+	AdviceDate := theTime.Unix()
247
+	RecordDate := theTime.Unix()
248
+
249
+	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
250
+		utils.ErrorLog("start_time")
251
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
252
+		return
253
+	}
254
+	startTime, _ := dataBody["start_time"].(string)
255
+	if len(startTime) == 0 {
256
+		utils.ErrorLog("len(start_time) == 0")
257
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
258
+		return
259
+	}
260
+	theTime, err = time.ParseInLocation(timeLayout+" 15:04:05", startTime, loc)
261
+	if err != nil {
262
+		utils.ErrorLog(err.Error())
263
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
264
+		return
265
+	}
266
+	StartTime := theTime.Unix()
267
+
268
+	Remark := ""
269
+	if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
270
+		remark, _ := dataBody["remark"].(string)
271
+		Remark = remark
272
+	}
273
+
274
+	var advices []*models.HisGroupAdvice
275
+	// utils.TraceLog("%+v", dataBody["adviceNames"])
276
+	if dataBody["adviceNames"] == nil || reflect.TypeOf(dataBody["adviceNames"]).String() != "[]interface {}" {
277
+		utils.ErrorLog("adviceNames")
278
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
279
+		return
280
+	}
281
+	adviceNames := dataBody["adviceNames"].([]interface{})
282
+	for _, adviceNameMap := range adviceNames {
283
+		adviceNameM := adviceNameMap.(map[string]interface{})
284
+		var advice models.HisGroupAdvice
285
+		advice.Remark = Remark
286
+		advice.AdviceType = adviceType
287
+		advice.StartTime = StartTime
288
+		advice.AdviceDate = AdviceDate
289
+		advice.RecordDate = RecordDate
290
+		advice.Status = 1
291
+		advice.CreatedTime = time.Now().Unix()
292
+		advice.UpdatedTime = time.Now().Unix()
293
+		advice.StopState = 2
294
+		advice.ExecutionState = 2
295
+		advice.UserOrgId = adminUserInfo.CurrentOrgId
296
+		advice.PatientId = patient_id
297
+		advice.HisPatientId = his_patient_id
298
+		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
299
+		advice.PrescriptionId = prescription_id
300
+
301
+		//入口
302
+		errcode := c.setAdviceWithJSON(&advice, adviceNameM)
303
+		if errcode > 0 {
304
+			c.ServeFailJSONWithSGJErrorCode(errcode)
305
+			return
306
+		}
307
+
308
+		if adviceNameM["subdrugs"] != nil && reflect.TypeOf(adviceNameM["subdrugs"]).String() == "[]interface {}" {
309
+			subdrugs := adviceNameM["subdrugs"].([]interface{})
310
+			if len(subdrugs) > 0 {
311
+				for _, subdrug := range subdrugs {
312
+					var s models.HisGroupAdvice
313
+					s.Remark = Remark
314
+					s.AdviceType = adviceType
315
+					s.StartTime = StartTime
316
+					s.AdviceDate = AdviceDate
317
+					s.RecordDate = RecordDate
318
+					s.Status = 1
319
+					s.CreatedTime = time.Now().Unix()
320
+					s.UpdatedTime = time.Now().Unix()
321
+					s.StopState = 2
322
+					s.ExecutionState = 2
323
+					s.HisPatientId = his_patient_id
324
+					s.UserOrgId = adminUserInfo.CurrentOrgId
325
+					s.PatientId = patient_id
326
+					s.AdviceDoctor = adminUserInfo.AdminUser.Id
327
+
328
+					errcode := c.setAdviceWithJSON(&s, subdrug.(map[string]interface{}))
329
+					if errcode > 0 {
330
+						c.ServeFailJSONWithSGJErrorCode(errcode)
331
+						return
332
+					}
333
+
334
+					advice.Children = append(advice.Children, &s)
335
+				}
336
+			}
337
+		}
338
+
339
+		advices = append(advices, &advice)
340
+	}
341
+
342
+	newAdvices, createErr := service.CreateHisGroupAdvice(adminUserInfo.CurrentOrgId, advices, group_no)
343
+	if createErr != nil {
344
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
345
+		return
346
+	}
347
+
348
+	c.ServeSuccessJSON(map[string]interface{}{
349
+		"msg":     "ok",
350
+		"advices": newAdvices,
351
+	})
352
+	return
353
+
354
+}
355
+
356
+func (c *HisApiController) CreateHisAdditionalCharge() {
357
+	his_patient_id, _ := c.GetInt64("his_patient_id")
358
+	patient_id, _ := c.GetInt64("patient_id")
359
+	record_date := c.GetString("record_date")
360
+	timeLayout := "2006-01-02"
361
+	loc, _ := time.LoadLocation("Local")
362
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
363
+	if err != nil {
364
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
365
+		return
366
+	}
367
+	adminInfo := c.GetAdminUserInfo()
368
+	recordDateTime := theTime.Unix()
369
+	dataBody := make(map[string]interface{}, 0)
370
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
371
+	if err != nil {
372
+		utils.ErrorLog(err.Error())
373
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
374
+		return
375
+	}
376
+
377
+	var additions []*models.HisAdditionalCharge
378
+	if dataBody["addition"] != nil && reflect.TypeOf(dataBody["addition"]).String() == "[]interface {}" {
379
+		additions, _ := dataBody["addition"].([]interface{})
380
+		if len(additions) > 0 {
381
+			for _, item := range additions {
382
+				items := item.(map[string]interface{})
383
+
384
+				if items["item_id"] == nil || reflect.TypeOf(items["item_id"]).String() != "float64" {
385
+					utils.ErrorLog("item_id")
386
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
387
+					return
388
+				}
389
+				item_id := int64(items["item_id"].(float64))
390
+
391
+				if items["item_name"] == nil || reflect.TypeOf(items["item_name"]).String() != "string" {
392
+					utils.ErrorLog("item_name")
393
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
394
+					return
395
+				}
396
+				item_name := items["item_name"].(string)
397
+
398
+				if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
399
+					utils.ErrorLog("price")
400
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
401
+					return
402
+				}
403
+				price, _ := strconv.ParseFloat(items["price"].(string), 64)
404
+
405
+				ctime := time.Now().Unix()
406
+				additional := &models.HisAdditionalCharge{
407
+					PatientId:    patient_id,
408
+					HisPatientId: his_patient_id,
409
+					UserOrgId:    adminInfo.CurrentOrgId,
410
+					RecordDate:   recordDateTime,
411
+					CreatedTime:  ctime,
412
+					UpdatedTime:  ctime,
413
+					Modifier:     adminInfo.AdminUser.Id,
414
+					Creator:      adminInfo.AdminUser.Id,
415
+					Price:        price,
416
+					ItemName:     item_name,
417
+					ItemId:       item_id,
418
+					Status:       1,
419
+				}
420
+				additions = append(additions, additional)
421
+			}
422
+		}
423
+	}
424
+	for _, item := range additions {
425
+		service.CreateAddtionalCharge(item)
426
+	}
427
+	c.ServeSuccessJSON(map[string]interface{}{
428
+		"msg": "创建成功",
429
+	})
430
+}
431
+
432
+func (c *HisApiController) CreateHisPatientCaseHistory() {
433
+	diagnostic := c.GetString("diagnostic")
434
+	temperature, _ := c.GetFloat("temperature")
435
+	blood_sugar, _ := c.GetFloat("blood_sugar")
436
+	pulse, _ := c.GetFloat("pulse")
437
+	sbp, _ := c.GetFloat("sbp")
438
+	dbp, _ := c.GetFloat("dbp")
439
+	blood_fat, _ := c.GetFloat("blood_fat")
440
+	height, _ := c.GetFloat("height")
441
+	sick_type, _ := c.GetInt64("sick_type")
442
+	symptom := c.GetString("symptom")
443
+	sick_date := c.GetString("sick_date")
444
+	is_infect, _ := c.GetInt64("is_infect")
445
+	chief_conplaint := c.GetString("chief_conplaint")
446
+	history_of_present_illness := c.GetString("history_of_present_illness")
447
+	past_history := c.GetString("past_history")
448
+	personal_history := c.GetString("personal_history")
449
+	family_history := c.GetString("family_history")
450
+	record_date := c.GetString("record_date")
451
+	patient_id, _ := c.GetInt64("patient_id")
452
+	timeLayout := "2006-01-02"
453
+	loc, _ := time.LoadLocation("Local")
454
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
455
+	if err != nil {
456
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
457
+		return
458
+	}
459
+	recordDateTime := theTime.Unix()
460
+	sickTime, err := time.ParseInLocation(timeLayout+" 15:04:05", sick_date+" 00:00:00", loc)
461
+	if err != nil {
462
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
463
+		return
464
+	}
465
+	sickTimes := sickTime.Unix()
466
+	ctime := time.Now().Unix()
467
+	caseHistory := models.HisPatientCaseHistory{
468
+		HisPatientId:            patient_id,
469
+		Temperature:             temperature,
470
+		BloodSugar:              blood_sugar,
471
+		Pulse:                   pulse,
472
+		Sbp:                     sbp,
473
+		Dbp:                     dbp,
474
+		Height:                  height,
475
+		BloodFat:                blood_fat,
476
+		SickType:                sick_type,
477
+		Symptom:                 symptom,
478
+		SickDate:                sickTimes,
479
+		IsInfect:                is_infect,
480
+		HistoryOfPresentIllness: history_of_present_illness,
481
+		PastHistory:             past_history,
482
+		Doctor:                  c.GetAdminUserInfo().AdminUser.Id,
483
+		ChiefConplaint:          chief_conplaint,
484
+		PersonalHistory:         personal_history,
485
+		FamilyHistory:           family_history,
486
+		Diagnostic:              diagnostic,
487
+		UserOrgId:               c.GetAdminUserInfo().CurrentOrgId,
488
+		Status:                  1,
489
+		Ctime:                   ctime,
490
+		Mtime:                   ctime,
491
+		RecordDate:              recordDateTime,
492
+	}
493
+	err = service.SaveHisPatientCaseHistory(caseHistory)
494
+	if err != nil {
495
+		c.ServeSuccessJSON(map[string]interface{}{
496
+			"msg": "保存成功",
497
+		})
498
+	}
499
+}
500
+func (c *HisApiController) GetHisPatientCaseHistoryList() {
501
+	patient_id, _ := c.GetInt64("patient_id", 0)
502
+	adminUser := c.GetAdminUserInfo()
503
+	caseHistorys, _ := service.GetHisPatientCaseHistoryList(adminUser.CurrentOrgId, patient_id)
504
+	c.ServeSuccessJSON(map[string]interface{}{
505
+		"list": caseHistorys,
506
+	})
507
+
508
+}
509
+func (c *HisApiController) GetHisPatientCaseHistory() {
510
+	record_date, _ := c.GetInt64("record_date", 0)
511
+	patient_id, _ := c.GetInt64("patient_id", 0)
512
+	admin := c.GetAdminUserInfo()
513
+	info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, record_date)
514
+	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, record_date)
515
+	c.ServeSuccessJSON(map[string]interface{}{
516
+		"info":         info,
517
+		"case_history": case_history,
518
+	})
519
+
520
+}
521
+func (c *HisApiController) CreateCaseHistoryTemplate() {
522
+	template_name := c.GetString("template_name")
523
+	template_remark := c.GetString("template_remark")
524
+	doctor := c.GetAdminUserInfo().AdminUser.Id
525
+	diagnostic := c.GetString("diagnostic")
526
+	chief_conplaint := c.GetString("chief_conplaint")
527
+	history_of_present_illness := c.GetString("history_of_present_illness")
528
+	past_history := c.GetString("past_history")
529
+	personal_history := c.GetString("personal_history")
530
+	family_history := c.GetString("family_history")
531
+	record_date := c.GetString("record_date")
532
+
533
+	timeLayout := "2006-01-02"
534
+	loc, _ := time.LoadLocation("Local")
535
+
536
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
537
+	if err != nil {
538
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
539
+		return
540
+	}
541
+	recordDateTime := theTime.Unix()
542
+
543
+	ctime := time.Now().Unix()
544
+
545
+	template := models.HisCaseHistoryTemplate{
546
+		HistoryOfPresentIllness: history_of_present_illness,
547
+		PastHistory:             past_history,
548
+		ChiefConplaint:          chief_conplaint,
549
+		PersonalHistory:         personal_history,
550
+		FamilyHistory:           family_history,
551
+		Diagnostic:              diagnostic,
552
+		UserOrgId:               c.GetAdminUserInfo().CurrentOrgId,
553
+		Status:                  1,
554
+		Ctime:                   ctime,
555
+		Mtime:                   ctime,
556
+		RecordDate:              recordDateTime,
557
+		TemplateName:            template_name,
558
+		TemplateRemark:          template_remark,
559
+		Creator:                 doctor,
560
+		Modifier:                doctor,
561
+	}
562
+
563
+	err = service.SaveHisPatientCaseHistoryTemplate(template)
564
+
565
+	if err == nil {
566
+		c.ServeSuccessJSON(map[string]interface{}{
567
+			"msg": "保存成功",
568
+		})
569
+
570
+	} else {
571
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
572
+		return
573
+	}
574
+
575
+}
576
+func (c *HisApiController) GetCaseHistoryTemplate() {
577
+	admin := c.GetAdminUserInfo()
578
+	template, _ := service.GetHisPatientCaseHistoryTemplate(admin.CurrentOrgId)
579
+	c.ServeSuccessJSON(map[string]interface{}{
580
+		"template": template,
581
+	})
582
+
583
+}
584
+func (c *HisApiController) GetPrintHisPatientCaseHistory() {
585
+
586
+}
587
+func (c *HisApiController) setAdviceWithJSON(advice *models.HisGroupAdvice, json map[string]interface{}) int {
588
+
589
+	if json["advice_name"] == nil || reflect.TypeOf(json["advice_name"]).String() != "string" {
590
+		utils.ErrorLog("advice_name")
591
+		return enums.ErrorCodeParamWrong
592
+	}
593
+	adviceName, _ := json["advice_name"].(string)
594
+	if len(adviceName) == 0 {
595
+		utils.ErrorLog("len(advice_name) == 0")
596
+		return enums.ErrorCodeParamWrong
597
+	}
598
+	advice.AdviceName = adviceName
599
+
600
+	adviceDesc, _ := json["advice_desc"].(string)
601
+	advice.AdviceDesc = adviceDesc
602
+
603
+	if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
604
+		drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
605
+		advice.DrugSpec = drugSpec
606
+	}
607
+
608
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
609
+		remark, _ := json["remark"].(string)
610
+		advice.Remark = remark
611
+	}
612
+
613
+	//if json["src_type"] != nil || reflect.TypeOf(json["src_type"]).String() == "float64" {
614
+	//	src_type, _ := strconv.ParseInt(json["src_type"].(string),10)
615
+	//	advice.Way = src_type
616
+	//}
617
+	if json["way"] == nil {
618
+		advice.Way = 0
619
+
620
+	} else {
621
+		if json["way"] != nil || reflect.TypeOf(json["way"]).String() == "float64" {
622
+			way := int64(json["way"].(float64))
623
+			advice.Way = way
624
+		}
625
+
626
+	}
627
+
628
+	if json["drug_id"] == nil {
629
+		advice.DrugId = 0
630
+	} else {
631
+		if json["drug_id"] != nil || reflect.TypeOf(json["drug_id"]).String() == "float64" {
632
+			drug_id := int64(json["drug_id"].(float64))
633
+			advice.DrugId = drug_id
634
+		}
635
+	}
636
+
637
+	if json["drug_name_id"] == nil {
638
+		advice.DrugNameId = 0
639
+	} else {
640
+		if json["drug_name_id"] != nil || reflect.TypeOf(json["drug_name_id"]).String() == "float64" {
641
+			drug_name_id := int64(json["drug_name_id"].(float64))
642
+			advice.DrugNameId = drug_name_id
643
+		}
644
+	}
645
+
646
+	if json["drug_spec_unit"] != nil && reflect.TypeOf(json["drug_spec_unit"]).String() == "string" {
647
+		drugSpecUnit, _ := json["drug_spec_unit"].(string)
648
+		advice.DrugSpecUnit = drugSpecUnit
649
+	}
650
+
651
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
652
+		singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
653
+		advice.SingleDose = singleDose
654
+	}
655
+
656
+	if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
657
+		singleDoseUnit, _ := json["single_dose_unit"].(string)
658
+		advice.SingleDoseUnit = singleDoseUnit
659
+	}
660
+
661
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
662
+		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
663
+		advice.PrescribingNumber = prescribingNumber
664
+	}
665
+
666
+	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
667
+		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
668
+		advice.PrescribingNumberUnit = prescribingNumberUnit
669
+	}
670
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
671
+		deliveryWay, _ := json["delivery_way"].(string)
672
+		advice.DeliveryWay = deliveryWay
673
+	}
674
+
675
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
676
+		executionFrequency, _ := json["execution_frequency"].(string)
677
+		advice.ExecutionFrequency = executionFrequency
678
+	}
679
+	return 0
680
+}

+ 1 - 1
controllers/manager_center_api_controller.go ファイルの表示

@@ -1389,7 +1389,7 @@ func (c *ManagerCenterApiController) CreateGoodInfo() {
1389 1389
 
1390 1390
 	adminUserInfo := c.GetAdminUserInfo()
1391 1391
 
1392
-	totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId)
1392
+	totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId, good_id)
1393 1393
 	if totals > 0 {
1394 1394
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
1395 1395
 		return

+ 103 - 109
controllers/mobile_api_controllers/check_weight_api_controller.go ファイルの表示

@@ -4,15 +4,15 @@ import (
4 4
 	"XT_New/enums"
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7
-	"github.com/astaxie/beego"
8
-	"net/http"
9
-	"net/url"
10
-	"strconv"
11 7
 	_ "XT_New/utils"
12 8
 	_ "encoding/json"
13 9
 	"fmt"
10
+	"github.com/astaxie/beego"
14 11
 	_ "github.com/astaxie/beego"
15 12
 	"github.com/jinzhu/gorm"
13
+	"net/http"
14
+	"net/url"
15
+	"strconv"
16 16
 	_ "strings"
17 17
 
18 18
 	// "fmt"
@@ -67,106 +67,106 @@ func (c *CheckWeightApiController) SaveBloodPressure() {
67 67
 	if dialysistype == 1 {
68 68
 		// 保存透前相关数据
69 69
 		// 获取透析处方
70
-		dialysisPrescribe, getDialysisPrescribeErr := service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
71
-		if getDialysisPrescribeErr != nil {
72
-			c.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
73
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
74
-			return
75
-		}
76
-
77
-		// 获取透析模版
78
-		dialysisSolution, getDialysisSolutionErr := service.MobileGetDialysisSolution(adminUserInfo.Org.Id, id)
79
-		if getDialysisSolutionErr != nil {
80
-			c.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
81
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
82
-			return
83
-		}
70
+		//dialysisPrescribe, getDialysisPrescribeErr := service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
71
+		//if getDialysisPrescribeErr != nil {
72
+		//	c.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
73
+		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
74
+		//	return
75
+		//}
76
+		//
77
+		//// 获取透析模版
78
+		//dialysisSolution, getDialysisSolutionErr := service.MobileGetDialysisSolution(adminUserInfo.Org.Id, id)
79
+		//if getDialysisSolutionErr != nil {
80
+		//	c.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
81
+		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
82
+		//	return
83
+		//}
84 84
 
85 85
 		// 插入透析处方
86
-		if dialysisPrescribe == nil && dialysisSolution != nil {
87
-			var newprescribe models.DialysisPrescription
88
-			newprescribe.UserOrgId = dialysisSolution.UserOrgId
89
-			newprescribe.PatientId = dialysisSolution.PatientId
90
-			newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
91
-			newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
92
-			newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
93
-			newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
94
-			newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
95
-			newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
96
-			newprescribe.ModeId = dialysisSolution.ModeId
97
-			newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
98
-			newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
99
-			newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
100
-			newprescribe.BloodFilter = dialysisSolution.BloodFilter
101
-			newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
102
-			newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
103
-			newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
104
-			newprescribe.Glucose = dialysisSolution.Glucose
105
-			newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
106
-			newprescribe.Kalium = dialysisSolution.Kalium
107
-			newprescribe.Sodium = dialysisSolution.Sodium
108
-			newprescribe.Calcium = dialysisSolution.Calcium
109
-			newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
110
-			newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
111
-			newprescribe.Conductivity = dialysisSolution.Conductivity
112
-			newprescribe.BodyFluid = dialysisSolution.BodyFluid
113
-			newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
114
-			newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
115
-			newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
116
-			newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
117
-			newprescribe.BloodAccess = dialysisSolution.BloodAccess
118
-			newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
119
-			newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
120
-			newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
121
-			newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
122
-			newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
123
-			newprescribe.Dialyzer = dialysisSolution.Dialyzer
124
-			newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
125
-			newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
126
-			newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
127
-			newprescribe.TargetKtv = dialysisSolution.TargetKtv
128
-
129
-			newprescribe.CreatedTime = time.Now().Unix()
130
-			newprescribe.UpdatedTime = time.Now().Unix()
131
-			newprescribe.RecordDate = theAssessmentDateTime
132
-			// newprescribe.DewaterAmount = dewater_amount
133
-			// newprescribe.TargetUltrafiltration = dewater_amount
134
-			newprescribe.Status = 1
135
-
136
-			err := service.AddSigleRecord(&newprescribe)
137
-			if err != nil {
138
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
139
-			}
140
-		}
141
-
142
-		if dialysisPrescribe == nil && dialysisSolution == nil {
143
-			var newprescribe models.DialysisPrescription
144
-			newprescribe.UserOrgId = adminUserInfo.Org.Id
145
-			newprescribe.PatientId = id
146
-			newprescribe.CreatedTime = time.Now().Unix()
147
-			newprescribe.UpdatedTime = time.Now().Unix()
148
-			newprescribe.RecordDate = theAssessmentDateTime
149
-			// newprescribe.DewaterAmount = dewater_amount
150
-			// newprescribe.TargetUltrafiltration = dewater_amount
151
-			newprescribe.Status = 1
152
-
153
-			err := service.AddSigleRecord(&newprescribe)
154
-			if err != nil {
155
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
156
-			}
157
-		}
158
-
159
-		if dialysisPrescribe != nil {
160
-			dialysisPrescribe.UpdatedTime = time.Now().Unix()
161
-			dialysisPrescribe.RecordDate = theAssessmentDateTime
162
-			// dialysisPrescribe.DewaterAmount = dewater_amount
163
-			// dialysisPrescribe.TargetUltrafiltration = dewater_amount
164
-			dialysisPrescribe.Status = 1
165
-			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
166
-			if updateErr != nil {
167
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
168
-			}
169
-		}
86
+		//if dialysisPrescribe == nil && dialysisSolution != nil {
87
+		//	var newprescribe models.DialysisPrescription
88
+		//	newprescribe.UserOrgId = dialysisSolution.UserOrgId
89
+		//	newprescribe.PatientId = dialysisSolution.PatientId
90
+		//	newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
91
+		//	newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
92
+		//	newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
93
+		//	newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
94
+		//	newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
95
+		//	newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
96
+		//	newprescribe.ModeId = dialysisSolution.ModeId
97
+		//	newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
98
+		//	newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
99
+		//	newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
100
+		//	newprescribe.BloodFilter = dialysisSolution.BloodFilter
101
+		//	newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
102
+		//	newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
103
+		//	newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
104
+		//	newprescribe.Glucose = dialysisSolution.Glucose
105
+		//	newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
106
+		//	newprescribe.Kalium = dialysisSolution.Kalium
107
+		//	newprescribe.Sodium = dialysisSolution.Sodium
108
+		//	newprescribe.Calcium = dialysisSolution.Calcium
109
+		//	newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
110
+		//	newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
111
+		//	newprescribe.Conductivity = dialysisSolution.Conductivity
112
+		//	newprescribe.BodyFluid = dialysisSolution.BodyFluid
113
+		//	newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
114
+		//	newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
115
+		//	newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
116
+		//	newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
117
+		//	newprescribe.BloodAccess = dialysisSolution.BloodAccess
118
+		//	newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
119
+		//	newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
120
+		//	newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
121
+		//	newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
122
+		//	newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
123
+		//	newprescribe.Dialyzer = dialysisSolution.Dialyzer
124
+		//	newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
125
+		//	newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
126
+		//	newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
127
+		//	newprescribe.TargetKtv = dialysisSolution.TargetKtv
128
+		//
129
+		//	newprescribe.CreatedTime = time.Now().Unix()
130
+		//	newprescribe.UpdatedTime = time.Now().Unix()
131
+		//	newprescribe.RecordDate = theAssessmentDateTime
132
+		//	// newprescribe.DewaterAmount = dewater_amount
133
+		//	// newprescribe.TargetUltrafiltration = dewater_amount
134
+		//	newprescribe.Status = 1
135
+		//
136
+		//	err := service.AddSigleRecord(&newprescribe)
137
+		//	if err != nil {
138
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
139
+		//	}
140
+		//}
141
+
142
+		//if dialysisPrescribe == nil && dialysisSolution == nil {
143
+		//	var newprescribe models.DialysisPrescription
144
+		//	newprescribe.UserOrgId = adminUserInfo.Org.Id
145
+		//	newprescribe.PatientId = id
146
+		//	newprescribe.CreatedTime = time.Now().Unix()
147
+		//	newprescribe.UpdatedTime = time.Now().Unix()
148
+		//	newprescribe.RecordDate = theAssessmentDateTime
149
+		//	// newprescribe.DewaterAmount = dewater_amount
150
+		//	// newprescribe.TargetUltrafiltration = dewater_amount
151
+		//	newprescribe.Status = 1
152
+		//
153
+		//	err := service.AddSigleRecord(&newprescribe)
154
+		//	if err != nil {
155
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
156
+		//	}
157
+		//}
158
+
159
+		//if dialysisPrescribe != nil {
160
+		//	dialysisPrescribe.UpdatedTime = time.Now().Unix()
161
+		//	dialysisPrescribe.RecordDate = theAssessmentDateTime
162
+		//	// dialysisPrescribe.DewaterAmount = dewater_amount
163
+		//	// dialysisPrescribe.TargetUltrafiltration = dewater_amount
164
+		//	dialysisPrescribe.Status = 1
165
+		//	updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
166
+		//	if updateErr != nil {
167
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
168
+		//	}
169
+		//}
170 170
 
171 171
 		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
172 172
 		if getPEErr != nil {
@@ -692,7 +692,6 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
692 692
 		}
693 693
 	}
694 694
 }
695
-
696 695
 func (c *CheckWeightApiController) GetPatientList() {
697 696
 	syncTime, _ := c.GetInt64("synctime", 0)
698 697
 	force, _ := c.GetInt64("force", 0)
@@ -710,7 +709,6 @@ func (c *CheckWeightApiController) GetPatientList() {
710 709
 		"servicetime": serviceTime,
711 710
 	})
712 711
 }
713
-
714 712
 func (c *CheckWeightApiController) GetPatientListById() {
715 713
 	patientId, _ := c.GetInt64("patient_id", 0)
716 714
 	if patientId <= 0 {
@@ -729,7 +727,6 @@ func (c *CheckWeightApiController) GetPatientListById() {
729 727
 		"patientinfo": patient,
730 728
 	})
731 729
 }
732
-
733 730
 func (c *CheckWeightApiController) GetPatientInfoDialysis() {
734 731
 	id, _ := c.GetInt64("patient", 0)
735 732
 	if id <= 0 {
@@ -797,7 +794,7 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
797 794
 
798 795
 		// 排队叫号的签到
799 796
 		ssoDomain := beego.AppConfig.String("call_domain")
800
-		api := ssoDomain + "/index/patientsign/"+strconv.FormatInt(adminUserInfo.Org.Id, 10)+"/"+strconv.FormatInt(id, 10)
797
+		api := ssoDomain + "/index/patientsign/" + strconv.FormatInt(adminUserInfo.Org.Id, 10) + "/" + strconv.FormatInt(id, 10)
801 798
 		values := make(url.Values)
802 799
 
803 800
 		http.PostForm(api, values)
@@ -964,8 +961,6 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
964 961
 		}
965 962
 	}
966 963
 
967
-
968
-
969 964
 	c.ServeSuccessJSON(map[string]interface{}{
970 965
 		"dialysistype":     dialysistype,
971 966
 		"patient":          dialysisinfo,
@@ -975,7 +970,6 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
975 970
 	})
976 971
 	return
977 972
 }
978
-
979 973
 func (c *CheckWeightApiController) GetPatientInfoBeforeDialysis() {
980 974
 	id, _ := c.GetInt64("patient", 0)
981 975
 	if id <= 0 {

+ 22 - 10
controllers/mobile_api_controllers/dialysis_api_controller.go ファイルの表示

@@ -2350,25 +2350,25 @@ func (c *DialysisAPIController) GetLongAdvice() {
2350 2350
 			if advice.FrequencyType == 3 {
2351 2351
 				t := time.Now()
2352 2352
 				week := int(t.Weekday())
2353
+				fmt.Println(t.Weekday())
2354
+
2355
+				fmt.Println(week)
2353 2356
 
2354 2357
 				switch week {
2355 2358
 				case 1:
2356 2359
 					if strings.Index(advice.WeekDay, "周一") == -1 {
2357 2360
 						advice_three = append(advice_three, advice)
2358 2361
 					}
2359
-
2360 2362
 					break
2361 2363
 				case 2:
2362 2364
 					if strings.Index(advice.WeekDay, "周二") == -1 {
2363 2365
 						advice_three = append(advice_three, advice)
2364 2366
 					}
2365
-
2366 2367
 					break
2367 2368
 				case 3:
2368 2369
 					if strings.Index(advice.WeekDay, "周三") == -1 {
2369 2370
 						advice_three = append(advice_three, advice)
2370 2371
 					}
2371
-
2372 2372
 					break
2373 2373
 				case 4:
2374 2374
 					if strings.Index(advice.WeekDay, "周四") == -1 {
@@ -2384,7 +2384,6 @@ func (c *DialysisAPIController) GetLongAdvice() {
2384 2384
 					if strings.Index(advice.WeekDay, "周六") == -1 {
2385 2385
 						advice_three = append(advice_three, advice)
2386 2386
 					}
2387
-
2388 2387
 					break
2389 2388
 				case 0:
2390 2389
 					if strings.Index(advice.WeekDay, "周日") == -1 {
@@ -3581,17 +3580,13 @@ func (c *DialysisAPIController) EditConsumables() {
3581 3580
 					for _, before := range beforePrepares {
3582 3581
 
3583 3582
 						if consumable.GoodId == before.GoodId {
3584
-							fmt.Println(consumable.Count)
3585
-							fmt.Println(before.Count)
3586 3583
 
3587 3584
 							if consumable.Count != before.Count {
3588
-								fmt.Println("111111111")
3589 3585
 								_, out := service.FindStockOutOrderNumberByTime(record_time, adminInfo.Org.Id)
3590 3586
 								//_, out := service.FindOldOrderInfoByGoodId(record_time, adminInfo.Org.Id)
3591 3587
 								//判断前端更改后的商品id的出库记录在数据库中是否存在
3592 3588
 								err, newOut := service.FindOrderInfoByGoodId(consumable.GoodTypeId, consumable.GoodId, out.WarehouseOutOrderNumber, adminInfo.Org.Id)
3593 3589
 								if err == gorm.ErrRecordNotFound { //不存在,则新增出库记录,并更改使用人商品信息
3594
-									fmt.Println("222222222")
3595 3590
 
3596 3591
 									warehouseOutInfo := &models.WarehouseOutInfo{
3597 3592
 										WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
@@ -3614,7 +3609,7 @@ func (c *DialysisAPIController) EditConsumables() {
3614 3609
 									err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
3615 3610
 									if err == nil {
3616 3611
 										//可能存在商品使用人不存在的情况,需要先判断商品使用人是否存在
3617
-										user, err := service.FindGoodUserById(before.GoodTypeId, before.GoodId, patient_id, adminInfo.Org.Id, out.WarehouseOutOrderNumber)
3612
+										user, err := service.FindGoodUserById(before.GoodTypeId, before.GoodId, patient_id, adminInfo.Org.Id, record_time)
3618 3613
 										if err == gorm.ErrRecordNotFound {
3619 3614
 											details := &models.AutomaticReduceDetail{
3620 3615
 												WarehouseOutId:          warehouseOutInfo.ID,
@@ -3655,7 +3650,7 @@ func (c *DialysisAPIController) EditConsumables() {
3655 3650
 										} else if consumable.Count < before.Count { //增加
3656 3651
 											service.UpdateOrderCountAdd(consumable.GoodTypeId, consumable.GoodId, out.WarehouseOutOrderNumber, adminInfo.Org.Id, before.Count-consumable.Count)
3657 3652
 										}
3658
-										user, err := service.FindGoodUserById(consumable.GoodTypeId, consumable.GoodId, patient_id, adminInfo.Org.Id, out.WarehouseOutOrderNumber)
3653
+										user, err := service.FindGoodUserById(consumable.GoodTypeId, consumable.GoodId, patient_id, adminInfo.Org.Id, record_time)
3659 3654
 										if err == gorm.ErrRecordNotFound {
3660 3655
 											details := &models.AutomaticReduceDetail{
3661 3656
 												WarehouseOutId:          newOut.ID,
@@ -4267,3 +4262,20 @@ func (c *DialysisAPIController) GetAllDrug() {
4267 4262
 	})
4268 4263
 
4269 4264
 }
4265
+
4266
+func RemoveRepeatedGoodTwo(arr []*models.DialysisBeforePrepare) (newArr []*models.DialysisBeforePrepare) {
4267
+	newArr = make([]*models.DialysisBeforePrepare, 0)
4268
+	for i := 0; i < len(arr); i++ {
4269
+		repeat := false
4270
+		for j := i + 1; j < len(arr); j++ {
4271
+			if arr[i].GoodId == arr[j].GoodId {
4272
+				repeat = true
4273
+				break
4274
+			}
4275
+		}
4276
+		if !repeat {
4277
+			newArr = append(newArr, arr[i])
4278
+		}
4279
+	}
4280
+	return
4281
+}

+ 0 - 1
controllers/mobile_api_controllers/patient_api_controller.go ファイルの表示

@@ -2790,7 +2790,6 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
2790 2790
 
2791 2791
 func (c *PatientApiController) CreateGroupAdvice() {
2792 2792
 	is_child, _ := c.GetInt64("is_child", 0)
2793
-	fmt.Println("is_child------------------------------", is_child)
2794 2793
 	if is_child == 1 {
2795 2794
 		patient, _ := c.GetInt64("id", 0)
2796 2795
 		if patient <= 0 {

+ 5 - 2
controllers/schedule_api_controller.go ファイルの表示

@@ -689,8 +689,10 @@ func (this *ScheduleApiController) SearchSchedulePatients() {
689 689
 		for index := weekStart1; index <= weekEnd1; index++ {
690 690
 			theDay := thisTime1.AddDate(0, 0, index)
691 691
 			days = append(days, theDay.Format("2006-01-02"))
692
-			if index == 0 {
692
+
693
+			if index == -1 {
693 694
 				start_time = theDay.Format("2006-01-02")
695
+				fmt.Println(start_time)
694 696
 			}
695 697
 
696 698
 			end_time = theDay.Format("2006-01-02")
@@ -729,7 +731,7 @@ func (this *ScheduleApiController) SearchSchedulePatients() {
729 731
 		for index := weekStart2; index <= weekEnd2; index++ {
730 732
 			theDay := thisTime2.AddDate(0, 0, index)
731 733
 			days = append(days, theDay.Format("2006-01-02"))
732
-			if index == 0 {
734
+			if index == -1 {
733 735
 				start_time = theDay.Format("2006-01-02")
734 736
 			}
735 737
 
@@ -1277,6 +1279,7 @@ func (this *ScheduleApiController) ExportSchedule() {
1277 1279
 				date, _ := utils.ParseTimeStringToTime("2006-01-02", schedule_date)
1278 1280
 				sch.ScheduleDate = date.Unix()
1279 1281
 			}
1282
+
1280 1283
 			sch.CreatedTime = time.Now().Unix()
1281 1284
 			sch.UpdatedTime = time.Now().Unix()
1282 1285
 			sch.ModeId = 1

+ 1 - 0
routers/router.go ファイルの表示

@@ -53,6 +53,7 @@ func init() {
53 53
 	controllers.PCIndexEvaluationApiControllersRegisterRouters()
54 54
 	controllers.ManagerCenterRegistRouters()
55 55
 	controllers.DrugStockManagerApiRegistRouters()
56
+	controllers.HisManagerApiRegistRouters()
56 57
 
57 58
 	m_api.MobileAPIControllersRegisterRouters()
58 59
 	new_m_api.NewMobileAPIControllersRegisterRouters()

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

@@ -171,7 +171,6 @@ func FindQueueCallInfo(orgID int64) (queueConfig models.QueueCallConfig, err err
171 171
 	return
172 172
 }
173 173
 
174
-
175 174
 //修改机构叫号配置
176 175
 func UpDateQueueCallInfo(queueConfig models.QueueCallConfig) error {
177 176
 	err := writeDb.Save(&queueConfig).Error
@@ -981,8 +980,8 @@ func FindOrderInfoByGoodId(good_type_id int64, good_id int64, number string, org
981 980
 	return
982 981
 }
983 982
 
984
-func FindGoodUserById(good_type_id int64, good_id int64, id int64, org_id int64, number string) (user models.AutomaticReduceDetail, err error) {
985
-	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND patient_id = ? AND org_id = ? AND warehouse_out_order_number = ? ", good_id, good_type_id, id, org_id, number).First(&user).Error
983
+func FindGoodUserById(good_type_id int64, good_id int64, id int64, org_id int64, record_time int64) (user models.AutomaticReduceDetail, err error) {
984
+	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND patient_id = ? AND org_id = ? AND record_time = ? ", good_id, good_type_id, id, org_id, record_time).First(&user).Error
986 985
 	return
987 986
 }
988 987
 

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

@@ -1369,3 +1369,39 @@ func FindDoctorAdviceByIdsTwo(orgID int64, ids []string) (advice []models.Doctor
1369 1369
 	err = readDb.Model(&models.DoctorAdvice{}).Where("user_org_id = ? AND status = 1 AND execution_state = 2 AND (id IN (?) OR parent_id IN (?))", orgID, ids, ids).Find(&advice).Error
1370 1370
 	return
1371 1371
 }
1372
+
1373
+func CreateHisGroupAdvice(orgId int64, advices []*models.HisGroupAdvice, groupNo int64) (list []*models.HisGroupAdvice, err error) {
1374
+	if groupNo <= 0 {
1375
+		group := GetMaxAdviceGroupID(orgId)
1376
+		groupNo = group + 1
1377
+	}
1378
+	tx := writeDb.Begin()
1379
+	defer func() {
1380
+		if r := recover(); r != nil {
1381
+			tx.Rollback()
1382
+		}
1383
+	}()
1384
+	for _, advice := range advices {
1385
+		advice.Groupno = groupNo
1386
+		if err = tx.Create(advice).Error; err != nil {
1387
+			tx.Rollback()
1388
+			return
1389
+		}
1390
+		list = append(list, advice)
1391
+		if len(advice.Children) > 0 {
1392
+			for _, child := range advice.Children {
1393
+				child.Groupno = groupNo
1394
+				child.ParentId = advice.ID
1395
+				fmt.Println(child)
1396
+				if err = tx.Create(&child).Error; err != nil {
1397
+					tx.Rollback()
1398
+					return
1399
+				}
1400
+				list = append(list, child)
1401
+			}
1402
+		}
1403
+
1404
+	}
1405
+	tx.Commit()
1406
+	return
1407
+}

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

@@ -13,7 +13,7 @@ import (
13 13
 //GetSchedulePartitionPanel 取出排班面板,分区-机号
14 14
 func GetSchedulePartitionPanel(orgID int64) (partitions []*models.Partition, err error) {
15 15
 
16
-	err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1", orgID).Where("org_id=? and status=1", orgID).Find(&partitions).Error
16
+	err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1", orgID).Where("org_id=? and status=1", orgID).Order("").Find(&partitions).Error
17 17
 
18 18
 	return
19 19
 }

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

@@ -1874,8 +1874,8 @@ func FindGoodTypeByName(name string, org_id int64) (total int64) {
1874 1874
 	readDb.Model(&models.GoodsType{}).Where("org_id = ? AND status = 1 AND type_name = ? ", org_id, name).Count(&total)
1875 1875
 	return
1876 1876
 }
1877
-func FindGoodInfoByName(name string, org_id int64) (total int64) {
1878
-	readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 AND specification_name = ? ", org_id, name).Count(&total)
1877
+func FindGoodInfoByName(name string, org_id int64, good_type_id int64) (total int64) {
1878
+	readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 AND specification_name = ? AND good_type_id = ? ", org_id, name, good_type_id).Count(&total)
1879 1879
 	return
1880 1880
 }
1881 1881