瀏覽代碼

Merge remote-tracking branch 'origin/20220812' into 20220812

XMLWAN 2 年之前
父節點
當前提交
07a4415f2b
共有 48 個文件被更改,包括 4625 次插入470 次删除
  1. 2 1
      .idea/vcs.xml
  2. 2 2
      conf/app.conf
  3. 484 13
      controllers/coordinate_controller.go
  4. 6 4
      controllers/data_api_controller.go
  5. 71 2
      controllers/dialysis_api_controller.go
  6. 75 67
      controllers/dialysis_record_api_controller.go
  7. 3 0
      controllers/drug_pharmacy_management_controller.go
  8. 158 0
      controllers/err_msg.json
  9. 8 2
      controllers/his_api_controller.go
  10. 936 1
      controllers/his_config_api_controller.go
  11. 0 4
      controllers/mobile_api_controllers/check_weight_api_controller.go
  12. 118 3
      controllers/mobile_api_controllers/dialysis_api_controller.go
  13. 4 2
      controllers/mobile_api_controllers/dialysis_api_controller_extend.go
  14. 3 0
      controllers/mobile_api_controllers/mobile_api_router_register.go
  15. 7 2
      controllers/mobile_api_controllers/patient_api_controller.go
  16. 24 4
      controllers/patient_api_controller.go
  17. 205 31
      controllers/pharmacy_controller.go
  18. 4 2
      controllers/sign_weigh_api_controller.go
  19. 0 1
      controllers/stock_in_api_controller.go
  20. 3 0
      controllers/supply_order_api_contorller.go
  21. 4 0
      enums/error_code.go
  22. 1 1
      models/common_models.go
  23. 1 0
      models/data_models.go
  24. 2 2
      models/device_models.go
  25. 8 3
      models/dialysis.go
  26. 1 0
      models/drug_pharmacy_management_models.go
  27. 14 12
      models/his_charge_models.go
  28. 88 32
      models/his_models.go
  29. 35 33
      models/his_summary_models.go
  30. 1 1
      models/patient_models.go
  31. 431 142
      models/pharmacy_models.go
  32. 36 34
      models/stock_models.go
  33. 13 0
      service/admin_service.go
  34. 1 1
      service/auto_create_week_schedules_service.go
  35. 161 0
      service/coordinate_service.go
  36. 7 2
      service/data.go
  37. 14 2
      service/dialysis_service.go
  38. 822 0
      service/his_config_service.go
  39. 25 4
      service/his_service.go
  40. 30 10
      service/mobile_dialysis_service.go
  41. 3 3
      service/patient_service.go
  42. 590 1
      service/pharmacy_service.go
  43. 4 4
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go
  44. 57 2
      service/statistics_service/index_evaluation_service.go
  45. 1 1
      service/statistics_service/index_models.go
  46. 153 37
      service/stock_service.go
  47. 8 2
      service/warhouse_service.go
  48. 1 0
      src/golang.org/x/sync

+ 2 - 1
.idea/vcs.xml 查看文件

@@ -7,5 +7,6 @@
7 7
   </component>
8 8
   <component name="VcsDirectoryMappings">
9 9
     <mapping directory="$PROJECT_DIR$" vcs="Git" />
10
+    <mapping directory="$PROJECT_DIR$/src/golang.org/x/sync" vcs="Git" />
10 11
   </component>
11
-</project>
12
+</project>

+ 2 - 2
conf/app.conf 查看文件

@@ -1,6 +1,6 @@
1 1
 appname = 血透
2
-httpport = 9529
3
-runmode = dev
2
+httpport = 9531
3
+runmode =dev
4 4
 #dev/prod
5 5
 
6 6
 #

+ 484 - 13
controllers/coordinate_controller.go 查看文件

@@ -68,6 +68,36 @@ type RefundDetail struct {
68 68
 	Code string `json:"code"`
69 69
 }
70 70
 
71
+type ResultQuery struct {
72
+	Msg    string `json:"msg"`
73
+	Result []struct {
74
+		Type      string `json:"type"`
75
+		Name      string `json:"name"`
76
+		Vaa01     int    `json:"vaa01"`
77
+		Vaa07     int    `json:"vaa07"`
78
+		Visittime string `json:"visittime"`
79
+	} `json:"result"`
80
+	Code string `json:"code"`
81
+}
82
+
83
+type ResultUpload struct {
84
+	Code   string `json:"code"`
85
+	Msg    string `json:"msg"`
86
+	Result []struct {
87
+		List            []interface{} `json:"list"`
88
+		Page            int64         `json:"page"`
89
+		Pagenumber      int64         `json:"pagenumber"`
90
+		Records         int64         `json:"records"`
91
+		RecordsFiltered int64         `json:"recordsFiltered"`
92
+		RecordsTotal    int64         `json:"recordsTotal"`
93
+		Result          string        `json:"result"`
94
+		ResultMsg       string        `json:"resultMsg"`
95
+		Total           int64         `json:"total"`
96
+		TotalPage       int64         `json:"totalPage"`
97
+		Userdata        string        `json:"userdata"`
98
+	} `json:"result"`
99
+}
100
+
71 101
 func CoordinateRcegistRouters() {
72 102
 	beego.Router("/coordinate/check", &CoordinateController{}, "get:SavePatientMessageInfo")
73 103
 	//坐标挂号
@@ -80,6 +110,439 @@ func CoordinateRcegistRouters() {
80 110
 	beego.Router("/coordinate/settle", &CoordinateController{}, "post:Settle")
81 111
 	//坐标退费回调
82 112
 	beego.Router("/coordinate/refund", &CoordinateController{}, "post:Refund")
113
+	//坐标患者查询~上传医嘱~结算功能
114
+	beego.Router("/coordinate/settleAccount", &CoordinateController{}, "get:SettleAccount")
115
+
116
+}
117
+
118
+func (c *CoordinateController) SettleAccount() {
119
+	patient_id, _ := c.GetInt64("patient_id")
120
+	record_date := c.GetString("record_date")
121
+	admin_user_id, _ := c.GetInt64("admin_user_id")
122
+	diagnosis_id := c.GetString("diagnosis")
123
+	sick_type, _ := c.GetInt64("sick_type")
124
+	reg_type, _ := c.GetInt64("p_type")
125
+	org_id, _ := c.GetInt64("org_id")
126
+	org_id = 3877
127
+	org, _ := service.GetOrgById(org_id)
128
+	patient, _ := service.GetPatientByID(org.Id, patient_id)
129
+	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
130
+
131
+	result, request := service.GetHisPatientForCoordinate(patient.IdCardNo)
132
+	saveLog(result, request, "查询", "查询", org.OrgName)
133
+	var res ResultQuery
134
+	if err := json.Unmarshal([]byte(result), &res); err != nil {
135
+		utils.ErrorLog("解析失败:%v", err)
136
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
137
+		return
138
+	}
139
+	if res.Code == "10000" {
140
+		if len(res.Result) == 0 {
141
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientNoRegException)
142
+			return
143
+		}
144
+		timeLayout := "2006-01-02"
145
+		loc, _ := time.LoadLocation("Local")
146
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
147
+		if err != nil {
148
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
149
+			return
150
+		}
151
+		org_id := org.Id
152
+		recordDateTime := theTime.Unix()
153
+		patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
154
+		if patientPrescription.ID == 0 {
155
+			patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
156
+		}
157
+		departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments)
158
+		doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
159
+		//admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
160
+
161
+		var prescriptions []*models.HisPrescription
162
+
163
+		if settle_accounts_type == 1 { //日结
164
+			prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, patient_id, recordDateTime, 2)
165
+		} else { //月结
166
+
167
+			start_time_str := c.GetString("start_time")
168
+			end_time_str := c.GetString("end_time")
169
+			timeLayout := "2006-01-02"
170
+			loc, _ := time.LoadLocation("Local")
171
+			theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
172
+			if err != nil {
173
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
174
+				return
175
+			}
176
+			recordStartTime := theStartTime.Unix()
177
+			theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
178
+			if err != nil {
179
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
180
+				return
181
+			}
182
+			recordEndTime := theEndTime.Unix()
183
+			prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, patient_id, recordStartTime, recordEndTime)
184
+		}
185
+		var total float64
186
+
187
+		for _, item := range prescriptions {
188
+			fmt.Println(item)
189
+			if item.Type == 1 { //药品
190
+				for _, subItem := range item.HisDoctorAdviceInfo {
191
+					total = total + (subItem.Price * subItem.PrescribingNumber)
192
+				}
193
+			}
194
+			if item.Type == 2 { //项目
195
+				for _, subItem := range item.HisPrescriptionProject {
196
+					cnt, _ := strconv.ParseFloat(subItem.Count, 64)
197
+					total = total + (subItem.Price * cnt)
198
+				}
199
+			}
200
+
201
+		}
202
+
203
+		var ids []int64
204
+
205
+		for _, item := range prescriptions {
206
+			ids = append(ids, item.ID)
207
+		}
208
+
209
+		var customs []*models.NewCustomTwo
210
+		for _, item := range prescriptions {
211
+			if item.Type == 1 { //药品
212
+				for _, subItem := range item.HisDoctorAdviceInfo {
213
+					cus := &models.NewCustomTwo{
214
+						AdviceId:         subItem.ID,
215
+						ProjectId:        0,
216
+						DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
217
+						Cut:              fmt.Sprintf("%.4f", subItem.PrescribingNumber),
218
+						FeedetlSn:        subItem.FeedetlSn,
219
+						Price:            fmt.Sprintf("%.2f", subItem.Price),
220
+						MedListCodg:      subItem.Drug.MedicalInsuranceNumber,
221
+						Type:             1,
222
+					}
223
+					customs = append(customs, cus)
224
+				}
225
+			}
226
+			if item.Type == 2 { //项目
227
+				for _, subItem := range item.HisPrescriptionProject {
228
+					if subItem.Type == 2 {
229
+						cnt, _ := strconv.ParseFloat(subItem.Count, 64)
230
+						cus := &models.NewCustomTwo{
231
+							AdviceId:         0,
232
+							ProjectId:        subItem.ID,
233
+							DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
234
+							Cut:              fmt.Sprintf("%.4f", cnt),
235
+							FeedetlSn:        subItem.FeedetlSn,
236
+							Price:            fmt.Sprintf("%.4f", float64(subItem.Price)),
237
+							MedListCodg:      subItem.HisProject.MedicalCode,
238
+							Type:             2,
239
+						}
240
+						customs = append(customs, cus)
241
+
242
+					} else {
243
+						cnt, _ := strconv.ParseFloat(subItem.Count, 64)
244
+						cus := &models.NewCustomTwo{
245
+							AdviceId:         0,
246
+							ProjectId:        subItem.ID,
247
+							DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
248
+							Cut:              fmt.Sprintf("%.4f", cnt),
249
+							FeedetlSn:        subItem.FeedetlSn,
250
+							Price:            fmt.Sprintf("%.4f", float64(subItem.Price)),
251
+							MedListCodg:      subItem.GoodInfo.MedicalInsuranceNumber,
252
+							Type:             3,
253
+						}
254
+						customs = append(customs, cus)
255
+					}
256
+
257
+				}
258
+			}
259
+		}
260
+
261
+		var info models.UploadInfo
262
+		info.Vaa01 = res.Result[0].Vaa01
263
+		info.Fasong = "1"
264
+		info.Vaa07 = res.Result[0].Vaa07
265
+		info.Bck01c = departmwnt.Number
266
+		info.Bce02a = doctor_info.DoctorNumber
267
+
268
+		diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
269
+		var config []*models.HisXtDiagnoseConfig
270
+		for _, item := range diagnosis_ids {
271
+			id, _ := strconv.ParseInt(item, 10, 64)
272
+			diagnosisConfig, _ := service.FindDiagnoseById(id)
273
+			config = append(config, diagnosisConfig)
274
+		}
275
+		for index, item := range config {
276
+			var diag models.Diag
277
+			diag.Vao06 = strconv.FormatInt(int64(index+1), 10)
278
+			diag.Bak02 = item.CountryCode
279
+			info.Diag = append(info.Diag, &diag)
280
+		}
281
+		var presInfos []*models.PresInfo
282
+		var presDetails []*models.PresDetail
283
+		for index, item := range prescriptions {
284
+			var presDetail models.PresDetail
285
+			var presInfo models.PresInfo
286
+			presInfo.Cbmid = strconv.FormatInt(item.ID, 10)
287
+			if item.Type == 1 {
288
+				presInfo.Cbm06 = "0"
289
+			} else {
290
+				presInfo.Cbm06 = "5"
291
+			}
292
+
293
+			if item.Type == 1 {
294
+				presInfo.Cbm07 = item.MedType
295
+			} else {
296
+				presInfo.Cbm07 = item.MedType
297
+			}
298
+
299
+			presDetail.Vaf59 = strconv.FormatInt(int64(index+1), 10)
300
+			var infoItems []*models.Item
301
+			for _, subItem := range item.HisDoctorAdviceInfo {
302
+				ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
303
+
304
+				var infoItem models.Item
305
+				infoItem.Rownr = "0"
306
+				infoItem.Vaf11 = "1"
307
+				infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
308
+				infoItem.Bbx01 = subItem.Drug.MedicalInsuranceNumber
309
+				infoItem.Bda01 = "1"
310
+				infoItem.Bby01 = ""
311
+				if subItem.Drug.MinUnit != subItem.Drug.DoseUnit {
312
+					infoItem.Vaf22 = subItem.Drug.DrugName + " " + subItem.Drug.Dose + subItem.Drug.DoseUnit + "*" + strconv.FormatInt(subItem.Drug.MinNumber, 10) + subItem.Drug.MinUnit + "/" + subItem.Drug.MaxUnit
313
+				}
314
+				infoItem.Vaf14 = subItem.Drug.DrugName
315
+				infoItem.Bdi01 = ef.Code
316
+				infoItem.Vaf17 = strconv.FormatInt(subItem.Day, 10)
317
+				infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
318
+				infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
319
+				infoItem.Vaf35 = "0"
320
+				infoItem.Vaf32 = "0"
321
+				infoItem.Bck01b = departmwnt.Number
322
+				infoItem.Bck01d = departmwnt.Number
323
+				infoItem.Vaf58 = "0"
324
+				infoItem.Vaf61 = "1"
325
+				infoItems = append(infoItems, &infoItem)
326
+			}
327
+			for _, subItem := range item.HisPrescriptionProject {
328
+				ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
329
+
330
+				if subItem.Type == 2 {
331
+					var infoItem models.Item
332
+					infoItem.Rownr = "0"
333
+					infoItem.Vaf11 = "1"
334
+					infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
335
+					infoItem.Bbx01 = subItem.HisProject.MedicalCode
336
+
337
+					if subItem.HisProject.CostClassify == 2 {
338
+						infoItem.Bda01 = "T"
339
+					} else if subItem.HisProject.CostClassify == 3 {
340
+						infoItem.Bda01 = "L"
341
+					} else {
342
+						infoItem.Bda01 = "T"
343
+					}
344
+					infoItem.Bby01 = ""
345
+					infoItem.Vaf22 = subItem.HisProject.ProjectName
346
+					infoItem.Bdi01 = ef.Code
347
+					infoItem.Vaf17 = subItem.Day
348
+					infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
349
+					infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.Count)
350
+					infoItem.Vaf35 = "0"
351
+					infoItem.Vaf18 = 0
352
+					infoItem.Vaf32 = "0"
353
+					infoItem.Bck01b = departmwnt.Number
354
+					infoItem.Bck01d = departmwnt.Number
355
+					infoItem.Vaf58 = "0"
356
+					infoItem.Vaf61 = "1"
357
+					infoItems = append(infoItems, &infoItem)
358
+
359
+				} else {
360
+					var infoItem models.Item
361
+					infoItem.Rownr = "0"
362
+					infoItem.Vaf11 = "1"
363
+					infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
364
+					infoItem.Bbx01 = subItem.GoodInfo.MedicalInsuranceNumber
365
+					infoItem.Bda01 = "M"
366
+					infoItem.Bby01 = ""
367
+					infoItem.Vaf22 = subItem.GoodInfo.GoodName + " " + subItem.GoodInfo.SpecificationName
368
+					infoItem.Bdi01 = ef.Code
369
+					infoItem.Vaf17 = subItem.Day
370
+					infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
371
+					infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.Count)
372
+					infoItem.Vaf35 = "0"
373
+					infoItem.Vaf32 = "0"
374
+					infoItem.Bck01b = departmwnt.Number
375
+					infoItem.Bck01d = departmwnt.Number
376
+					infoItem.Vaf58 = "0"
377
+					infoItem.Vaf61 = "1"
378
+					infoItems = append(infoItems, &infoItem)
379
+
380
+				}
381
+
382
+			}
383
+			presDetail.Item = infoItems
384
+			presDetails = append(presDetails, &presDetail)
385
+			presInfo.PresDetail = presDetails
386
+			presInfos = append(presInfos, &presInfo)
387
+		}
388
+		info.PresInfo = presInfos
389
+
390
+		result2, request2 := service.UploadPrescriptionForCoordinate(info)
391
+		saveLog(result2, request2, "上传明细", "上传明细", org.OrgName)
392
+
393
+		var res2 ResultUpload
394
+		if err := json.Unmarshal([]byte(result2), &res2); err != nil {
395
+			utils.ErrorLog("解析失败:%v", err)
396
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
397
+			return
398
+		}
399
+		if res2.Code == "10000" {
400
+
401
+			timestamp := time.Now().Unix()
402
+			tempTime := time.Unix(timestamp, 0)
403
+			timeFormat := tempTime.Format("20060102150405")
404
+			chrgBchno := rand.Intn(100000) + 10000
405
+			ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
406
+			his := models.VMHisPatient{
407
+				Name:                   patient.Name,
408
+				Gender:                 patient.Gender,
409
+				Birthday:               patient.Birthday,
410
+				MedicalTreatmentType:   0,
411
+				IdType:                 1,
412
+				IdCardNo:               patient.IdCardNo,
413
+				BalanceAccountsType:    1,
414
+				MedicalInsuranceNumber: "",
415
+				RegisterType:           0,
416
+				RegisterCost:           0,
417
+				TreatmentCost:          0,
418
+				Status:                 1,
419
+				Ctime:                  time.Now().Unix(),
420
+				Mtime:                  time.Now().Unix(),
421
+				PsnNo:                  strconv.FormatInt(int64(res.Result[0].Vaa01), 10),
422
+				PsnCertType:            "",
423
+				Certno:                 patient.IdCardNo,
424
+				PsnName:                patient.Name,
425
+				Gend:                   "",
426
+				Naty:                   "",
427
+				Brdy:                   "",
428
+				Age:                    0,
429
+				Iinfo:                  "",
430
+				Idetinfo:               "",
431
+				PatientId:              patient.ID,
432
+				RecordDate:             theTime.Unix(),
433
+				UserOrgId:              org_id,
434
+				AdminUserId:            admin_user_id,
435
+				IsReturn:               1,
436
+				Doctor:                 patientPrescription.DoctorId,
437
+				Departments:            patientPrescription.Departments,
438
+				IptOtpNo:               ipt_otp_no,
439
+				Number:                 strconv.FormatInt(int64(res.Result[0].Vaa07), 10),
440
+				PhoneNumber:            patient.Phone,
441
+			}
442
+			service.UpdateHisPatientStatus(&his)
443
+			service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
444
+			tm := time.Unix(time.Now().Unix(), 0)
445
+
446
+			order := &models.HisOrder{
447
+				PsnNo:              his.PsnNo,
448
+				UserOrgId:          org_id,
449
+				HisPatientId:       his.ID,
450
+				PatientId:          patient_id,
451
+				SettleAccountsDate: recordDateTime,
452
+				Ctime:              time.Now().Unix(),
453
+				Mtime:              time.Now().Unix(),
454
+				Status:             1,
455
+				OrderStatus:        1,
456
+				MdtrtId:            his.Number,
457
+				Number:             ipt_otp_no,
458
+				SetlId:             "",
459
+				MedfeeSumamt:       total,
460
+				MedType:            strconv.Itoa(int(reg_type)),
461
+				SettleEndTime:      0,
462
+				SettleStartTime:    0,
463
+				SettleType:         settle_accounts_type,
464
+				Diagnosis:          diagnosis_id,
465
+				PType:              2,
466
+				SetlTime:           tm.Format("2006-01-02 15:04:05"),
467
+			}
468
+			err = service.CreateOrder(order)
469
+			if err != nil {
470
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
471
+				return
472
+			}
473
+
474
+			for _, item := range customs {
475
+				var advice_id int64 = 0
476
+				var project_id int64 = 0
477
+				var item_id int64 = 0
478
+
479
+				var types int64 = 0
480
+
481
+				if item.Type == 1 {
482
+					advice_id = item.AdviceId
483
+					project_id = 0
484
+					item_id = 0
485
+				} else if item.Type == 2 {
486
+					advice_id = 0
487
+					item_id = 0
488
+
489
+					project_id = item.ProjectId
490
+				} else if item.Type == 3 {
491
+					advice_id = 0
492
+					item_id = item.ItemId
493
+					project_id = 0
494
+				}
495
+				detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
496
+				cut, _ := strconv.ParseFloat(item.Cut, 32)
497
+				pric, _ := strconv.ParseFloat(item.Price, 32)
498
+				info := &models.HisOrderInfo{
499
+					OrderNumber:      order.Number,
500
+					UploadDate:       time.Now().Unix(),
501
+					AdviceId:         advice_id,
502
+					DetItemFeeSumamt: detItemFeeSumamt,
503
+					Cnt:              cut,
504
+					Pric:             pric,
505
+					PatientId:        patient_id,
506
+					Status:           1,
507
+					Mtime:            time.Now().Unix(),
508
+					Ctime:            time.Now().Unix(),
509
+					UserOrgId:        org_id,
510
+					HisPatientId:     his.ID,
511
+					OrderId:          order.ID,
512
+					ProjectId:        project_id,
513
+					Type:             types,
514
+					ItemId:           item_id,
515
+				}
516
+				service.CreateOrderInfo(info)
517
+			}
518
+			his.Diagnosis = diagnosis_id
519
+			his.SickType = sick_type
520
+			his.RegisterType = reg_type
521
+			his.MedicalTreatmentType = reg_type
522
+			service.UpdataHisPateintTwo(&his)
523
+			err = service.UpDatePrescriptionNumber(org_id, ids, strconv.FormatInt(int64(chrgBchno), 10))
524
+			err = service.UpDateHisPrescriptionInfoNumber(org_id, patient_id, strconv.FormatInt(int64(chrgBchno), 10), recordDateTime, his.ID)
525
+			err = service.UpdataOrderStatusThree(strconv.FormatInt(int64(chrgBchno), 10), org_id)
526
+
527
+			c.ServeSuccessJSON(map[string]interface{}{
528
+				"msg": "医嘱保存成功",
529
+			})
530
+
531
+		} else {
532
+			c.ServeSuccessJSON(map[string]interface{}{
533
+				"failed_code": -10,
534
+				"msg":         res.Msg,
535
+			})
536
+
537
+		}
538
+
539
+	} else {
540
+		c.ServeSuccessJSON(map[string]interface{}{
541
+			"failed_code": -10,
542
+			"msg":         res.Msg,
543
+		})
544
+
545
+	}
83 546
 
84 547
 }
85 548
 
@@ -97,15 +560,17 @@ func (c *CoordinateController) Settle() {
97 560
 		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
98 561
 		return
99 562
 	}
100
-	patien_id := respJSON["patientid"].(string)
101
-	infoSeq := respJSON["infoseq"].(string)
102
-	docId := respJSON["docid"].(string)
103
-	fmt.Println(patien_id)
104
-	fmt.Println(infoSeq)
105
-	fmt.Println(docId)
106
-
107
-	order, _ := service.GetHisOrderFour(patien_id, infoSeq, "")
108
-	order.SetlId = docId
563
+	patien_id := respJSON["vaa01"].(float64)
564
+	infoSeq := respJSON["vaa07"].(float64)
565
+
566
+	//strconv.For(patien_id, 10)
567
+
568
+	vaa001 := fmt.Sprintf("%f", patien_id)
569
+	vaa007 := fmt.Sprintf("%f", infoSeq)
570
+
571
+	setl_id := respJSON["setl_id"].(string)
572
+	order, _ := service.GetHisOrderFour(vaa001, vaa007, "")
573
+	order.SetlId = setl_id
109 574
 	if order.ID == 0 {
110 575
 		json := make(map[string]interface{})
111 576
 		json["msg"] = "结算记录不存在,请检查参数是否正确"
@@ -134,10 +599,16 @@ func (c *CoordinateController) Refund() {
134 599
 		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
135 600
 		return
136 601
 	}
137
-	patien_id := respJSON["patientid"].(string)
138
-	infoSeq := respJSON["infoseq"].(string)
139
-	docId := respJSON["docid"].(string)
140
-	order, _ := service.GetHisOrderFour(patien_id, infoSeq, docId)
602
+	patien_id := respJSON["vaa01"].(float64)
603
+	infoSeq := respJSON["vaa07"].(float64)
604
+
605
+	//strconv.For(patien_id, 10)
606
+
607
+	vaa001 := fmt.Sprintf("%f", patien_id)
608
+	vaa007 := fmt.Sprintf("%f", infoSeq)
609
+
610
+	docId := respJSON["setl_id"].(string)
611
+	order, _ := service.GetHisOrderFour(vaa001, vaa007, docId)
141 612
 	if order.ID == 0 {
142 613
 		json := make(map[string]interface{})
143 614
 		json["msg"] = "结算记录不存在,请检查参数是否正确"

+ 6 - 4
controllers/data_api_controller.go 查看文件

@@ -825,7 +825,6 @@ func (c *DataApiController) CreateExecutionFrequency() {
825 825
 		return
826 826
 	}
827 827
 	timeNow := time.Now().Unix()
828
-	ef.Code = ""
829 828
 	ef.Status = 1
830 829
 	ef.CreatedTime = timeNow
831 830
 	ef.UpdatedTime = timeNow
@@ -881,6 +880,7 @@ func (c *DataApiController) UpdateExecutionFrequency() {
881 880
 	timeNow := time.Now().Unix()
882 881
 	ef.UpdatedTime = timeNow
883 882
 	ef.Name = efdata.Name
883
+	ef.Code = efdata.Code
884 884
 
885 885
 	err = service.UpdateExecutionFrequency(ef)
886 886
 	if err != nil {
@@ -1411,16 +1411,18 @@ func (this *DataApiController) ModifyTemplateName() {
1411 1411
 func (this *DataApiController) ModifyFiledIsShow() {
1412 1412
 	id, _ := this.GetInt64("id", 0)
1413 1413
 	is_show, _ := this.GetInt("is_show", 0)
1414
+	is_write, _ := this.GetInt("is_write", 0)
1414 1415
 	adminUserInfo := this.GetAdminUserInfo()
1415
-	err := service.ShowFiledConfig(adminUserInfo.CurrentOrgId, is_show, id)
1416
+	err := service.ShowFiledConfig(adminUserInfo.CurrentOrgId, is_show, is_write, id)
1416 1417
 	if err != nil {
1417 1418
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
1418 1419
 		return
1419 1420
 	} else {
1420 1421
 
1421 1422
 		this.ServeSuccessJSON(map[string]interface{}{
1422
-			"id":      id,
1423
-			"is_show": is_show,
1423
+			"id":       id,
1424
+			"is_show":  is_show,
1425
+			"is_write": is_write,
1424 1426
 		})
1425 1427
 	}
1426 1428
 }

+ 71 - 2
controllers/dialysis_api_controller.go 查看文件

@@ -71,6 +71,8 @@ func DialysisApiRegistRouters() {
71 71
 
72 72
 	beego.Router("/api/schedule/getorderdoctoradvice", &DialysisApiController{}, "Get:GetOrderDoctorAdvice")
73 73
 
74
+	beego.Router("/api/getinitprintdateone", &DialysisApiController{}, "Get:GetInitPrintDataOne")
75
+
74 76
 }
75 77
 
76 78
 func (c *DialysisApiController) GetQueueCall() {
@@ -391,6 +393,17 @@ func (c *DialysisApiController) PostPrescription() {
391 393
 		}
392 394
 
393 395
 		prescription.Creater = adminUserInfo.AdminUser.Id
396
+
397
+		//针对河间咸得
398
+		if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
399
+
400
+			if prescription.ModeId != 2 && prescription.ModeId != 5 && prescription.ModeId != 12 {
401
+
402
+				prescription.DisplaceLiquiPart = 0
403
+				prescription.DisplaceLiquiValue = 0
404
+			}
405
+		}
406
+
394 407
 		err := service.AddSigleRecord(&prescription)
395 408
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
396 409
 		redis := service.RedisClient()
@@ -873,6 +886,26 @@ func (c *DialysisApiController) PostSoulution() {
873 886
 		OxygenTime:                 oxygen_time,
874 887
 		PreImpulse:                 preImpules,
875 888
 	}
889
+
890
+	//针对河间咸得
891
+	if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
892
+
893
+		if prescription.ModeId != 2 && prescription.ModeId != 5 && prescription.ModeId != 12 {
894
+
895
+			prescription.DisplaceLiquiPart = 0
896
+			prescription.DisplaceLiquiValue = 0
897
+		}
898
+	}
899
+
900
+	if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
901
+
902
+		if solution.ModeId != 2 && solution.ModeId != 5 && solution.ModeId != 12 {
903
+
904
+			solution.DisplaceLiquiPart = 0
905
+			solution.DisplaceLiquiValue = 0
906
+		}
907
+	}
908
+
876 909
 	err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
877 910
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
878 911
 	redis := service.RedisClient()
@@ -1287,6 +1320,7 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1287 1320
 	assessment.MachineRun = data.MachineRun
1288 1321
 	assessment.AfterUrea = data.AfterUrea
1289 1322
 	assessment.PipCoagulation = data.PipCoagulation
1323
+	assessment.AccumulatedBloodVolume = data.AccumulatedBloodVolume
1290 1324
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1291 1325
 
1292 1326
 	if assessment.ID > 0 {
@@ -1411,7 +1445,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1411 1445
 	internal_fistula_other := c.GetString("internal_fistula_other")
1412 1446
 	blood_access_internal_fistula := c.GetString("blood_access_internal_fistula")
1413 1447
 
1414
-	breathing_rate, _ := c.GetFloat("breathing_rate", 0)
1448
+	//breathing_rate, _ := c.GetFloat("breathing_rate", 0)
1449
+	breathing_rate := c.GetString("breathing_rate")
1415 1450
 
1416 1451
 	is_infect, _ := c.GetInt64("is_infect", 0)
1417 1452
 	exposed, _ := c.GetFloat("exposed", 0)
@@ -1444,6 +1479,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1444 1479
 	blood_pressure_during_dialysis := c.GetString("blood_pressure_during_dialysis")
1445 1480
 	urea_befor := c.GetString("urea_befor")
1446 1481
 	suction := c.GetString("suction")
1482
+	weight_befor_remake := c.GetString("weight_befor_remake")
1483
+
1447 1484
 	assessmentBeforeDislysis := models.PredialysisEvaluation{
1448 1485
 		DialysisCount:                  dialysis_count,
1449 1486
 		EmergencyTreatment:             emergency_treatment,
@@ -1512,6 +1549,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1512 1549
 		BloodPressureDuringDialysis:    blood_pressure_during_dialysis,
1513 1550
 		UreaBefor:                      urea_befor,
1514 1551
 		Suction:                        suction,
1552
+		WeightBeforRemake:              weight_befor_remake,
1515 1553
 	}
1516 1554
 
1517 1555
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
@@ -2387,7 +2425,8 @@ func (c *DialysisApiController) CreateMonitor() {
2387 2425
 	operate_time, _ := c.GetInt64("operate_time", 0)
2388 2426
 	// monitoring_time := c.GetString("monitoring_time")
2389 2427
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
2390
-	breathing_rated, _ := c.GetFloat("breathing_rated", 0)
2428
+	//breathing_rated, _ := c.GetFloat("breathing_rated", 0)
2429
+	breathing_rated := c.GetString("breathing_rated")
2391 2430
 	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
2392 2431
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
2393 2432
 	blood_pressure_type, _ := c.GetInt64("blood_pressure_type", 0)
@@ -4141,3 +4180,33 @@ func (c *DialysisApiController) GetInitPrintData() {
4141 4180
 		return
4142 4181
 	}
4143 4182
 }
4183
+
4184
+func (c *DialysisApiController) GetInitPrintDataOne() {
4185
+
4186
+	patient_id, _ := c.GetInt64("patient_id")
4187
+	start_time := c.GetString("record_date")
4188
+	timeLayout := "2006-01-02"
4189
+	loc, _ := time.LoadLocation("Local")
4190
+	var theStartTime int64
4191
+	if len(start_time) > 0 {
4192
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4193
+		if err != nil {
4194
+			utils.ErrorLog(err.Error())
4195
+		}
4196
+		theStartTime = theTime.Unix()
4197
+	}
4198
+	orgId := c.GetAdminUserInfo().CurrentOrgId
4199
+	list, err := service.GetInitPrintData(patient_id, theStartTime, orgId)
4200
+	assessmentAfterDislysis, _ := service.GetLastWeightAfter(patient_id, theStartTime, orgId)
4201
+	if err == nil {
4202
+		c.ServeSuccessJSON(map[string]interface{}{
4203
+			"list":                    list,
4204
+			"assessmentAfterDislysis": assessmentAfterDislysis,
4205
+		})
4206
+		return
4207
+
4208
+	} else {
4209
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4210
+		return
4211
+	}
4212
+}

+ 75 - 67
controllers/dialysis_record_api_controller.go 查看文件

@@ -497,7 +497,7 @@ type EditMonitorParamObject struct {
497 497
 	SystolicBP                  float64 `json:"systolic_bp"`
498 498
 	DiastolicBP                 float64 `json:"diastolic_bp"`
499 499
 	PulseFrequency              float64 `json:"pulse_frequency"`
500
-	BreathingRated              float64 `json:"breathing_rated"`
500
+	BreathingRated              string  `json:"breathing_rated"`
501 501
 	BloodFlowVolume             float64 `json:"blood_flow_volume"`
502 502
 	VenousPressure              float64 `json:"venous_pressure"`
503 503
 	VenousPressureType          int64   `json:"venous_pressure_type"`
@@ -1085,6 +1085,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1085 1085
 				record.SystolicBloodPressure = befor.SystolicBloodPressure
1086 1086
 				record.DiastolicBloodPressure = befor.DiastolicBloodPressure
1087 1087
 				record.BreathingRate = befor.BreathingRate
1088
+
1088 1089
 				record.PulseFrequency = befor.PulseFrequency
1089 1090
 				record.Temperature = befor.Temperature
1090 1091
 			}
@@ -1258,6 +1259,13 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1258 1259
 		tempassessmentAfterDislysis.BreathingRate = endmonitorRecords.BreathingRate
1259 1260
 		tempassessmentAfterDislysis.SystolicBloodPressure = endmonitorRecords.SystolicBloodPressure
1260 1261
 		tempassessmentAfterDislysis.DiastolicBloodPressure = endmonitorRecords.DiastolicBloodPressure
1262
+		//长沙南雅
1263
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10340 {
1264
+			//获取最后一条透析处方数据
1265
+			prescription, _ := service.GetLastDialysisPrescriptionByPatientIdTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1266
+			evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1267
+			tempassessmentAfterDislysis.WeightAfter = evaluation.WeightBefore - prescription.TargetUltrafiltration
1268
+		}
1261 1269
 		if adminUserInfo.CurrentOrgId == 10101 {
1262 1270
 			tempassessmentAfterDislysis.ActualUltrafiltration = endmonitorRecords.UltrafiltrationVolume / 1000
1263 1271
 		} else {
@@ -1347,72 +1355,72 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1347 1355
 
1348 1356
 	err := service.UpdateAssessmentAfterDislysisRecord(&tempassessmentAfterDislysis)
1349 1357
 
1350
-	//evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1351
-	//if evaluation.SystolicBloodPressure == 0 {
1352
-	//	evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
1353
-	//
1354
-	//	pre := models.PredialysisEvaluation{
1355
-	//		SystolicBloodPressure: evaluation.SystolicBloodPressure,
1356
-	//	}
1357
-	//	fmt.Println("prew", pre)
1358
-	//	getNurseErr := service.UpdatePredialysisEvaluation(&pre, evaluation.ID)
1359
-	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1360
-	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1361
-	//
1362
-	//	redis := service.RedisClient()
1363
-	//	redis.Set(key, "", time.Second)
1364
-	//	redis.Set(keyOne, "", time.Second)
1365
-	//	defer redis.Close()
1366
-	//	fmt.Println(getNurseErr)
1367
-	//}
1368
-	//if evaluation.DiastolicBloodPressure == 0 {
1369
-	//	evaluation.DiastolicBloodPressure = fmonitorRecords.DiastolicBloodPressure
1370
-	//	pres := models.PredialysisEvaluation{
1371
-	//		DiastolicBloodPressure: evaluation.DiastolicBloodPressure,
1372
-	//	}
1373
-	//	getNurseErr := service.UpdatePredialysisEvaluationTwo(&pres, evaluation.ID)
1374
-	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1375
-	//
1376
-	//	redis := service.RedisClient()
1377
-	//	redis.Set(key, "", time.Second)
1378
-	//
1379
-	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1380
-	//	redis.Set(keyOne, "", time.Second)
1381
-	//	defer redis.Close()
1382
-	//	fmt.Println(getNurseErr)
1383
-	//}
1384
-	//if evaluation.PulseFrequency == 0 {
1385
-	//	evaluation.PulseFrequency = fmonitorRecords.PulseFrequency
1386
-	//	press := models.PredialysisEvaluation{
1387
-	//		PulseFrequency: evaluation.PulseFrequency,
1388
-	//	}
1389
-	//	getNurseErr := service.UpdatePredialysisEvaluationThree(&press, evaluation.ID)
1390
-	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1391
-	//
1392
-	//	redis := service.RedisClient()
1393
-	//	redis.Set(key, "", time.Second)
1394
-	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1395
-	//	redis.Set(keyOne, "", time.Second)
1396
-	//	defer redis.Close()
1397
-	//	fmt.Println(getNurseErr)
1398
-	//}
1399
-	//
1400
-	//if evaluation.Temperature == 0 {
1401
-	//	evaluation.Temperature = fmonitorRecords.Temperature
1402
-	//	press := models.PredialysisEvaluation{
1403
-	//		Temperature: evaluation.Temperature,
1404
-	//	}
1405
-	//	getNurseErr := service.UpdatePredialysisEvaluationFour(&press, evaluation.ID)
1406
-	//	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1407
-	//
1408
-	//	redis := service.RedisClient()
1409
-	//	redis.Set(key, "", time.Second)
1410
-	//	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1411
-	//	redis.Set(keyOne, "", time.Second)
1412
-	//	defer redis.Close()
1413
-	//	fmt.Println(getNurseErr)
1414
-	//}
1415
-	//
1358
+	if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10340 {
1359
+		fmt.Println("进来2332233333333333333333333333333333333我的")
1360
+		evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1361
+		if evaluation.SystolicBloodPressure == 0 {
1362
+			pre := models.PredialysisEvaluation{
1363
+				SystolicBloodPressure: fmonitorRecords.SystolicBloodPressure,
1364
+			}
1365
+			fmt.Println("prew", pre)
1366
+			getNurseErr := service.UpdatePredialysisEvaluation(&pre, evaluation.ID)
1367
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1368
+			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1369
+
1370
+			redis := service.RedisClient()
1371
+			redis.Set(key, "", time.Second)
1372
+			redis.Set(keyOne, "", time.Second)
1373
+			defer redis.Close()
1374
+			fmt.Println(getNurseErr)
1375
+		}
1376
+		if evaluation.DiastolicBloodPressure == 0 {
1377
+			pres := models.PredialysisEvaluation{
1378
+				DiastolicBloodPressure: fmonitorRecords.DiastolicBloodPressure,
1379
+			}
1380
+			getNurseErr := service.UpdatePredialysisEvaluationTwo(&pres, evaluation.ID)
1381
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1382
+
1383
+			redis := service.RedisClient()
1384
+			redis.Set(key, "", time.Second)
1385
+
1386
+			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1387
+			redis.Set(keyOne, "", time.Second)
1388
+			defer redis.Close()
1389
+			fmt.Println(getNurseErr)
1390
+		}
1391
+		if evaluation.PulseFrequency == 0 {
1392
+			evaluation.PulseFrequency = fmonitorRecords.PulseFrequency
1393
+			press := models.PredialysisEvaluation{
1394
+				PulseFrequency: evaluation.PulseFrequency,
1395
+			}
1396
+			getNurseErr := service.UpdatePredialysisEvaluationThree(&press, evaluation.ID)
1397
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1398
+
1399
+			redis := service.RedisClient()
1400
+			redis.Set(key, "", time.Second)
1401
+			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1402
+			redis.Set(keyOne, "", time.Second)
1403
+			defer redis.Close()
1404
+			fmt.Println(getNurseErr)
1405
+		}
1406
+
1407
+		if evaluation.Temperature == 0 {
1408
+			evaluation.Temperature = fmonitorRecords.Temperature
1409
+			press := models.PredialysisEvaluation{
1410
+				Temperature: evaluation.Temperature,
1411
+			}
1412
+			getNurseErr := service.UpdatePredialysisEvaluationFour(&press, evaluation.ID)
1413
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1414
+
1415
+			redis := service.RedisClient()
1416
+			redis.Set(key, "", time.Second)
1417
+			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1418
+			redis.Set(keyOne, "", time.Second)
1419
+			defer redis.Close()
1420
+			fmt.Println(getNurseErr)
1421
+		}
1422
+	}
1423
+
1416 1424
 	if err != nil {
1417 1425
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1418 1426
 		return

+ 3 - 0
controllers/drug_pharmacy_management_controller.go 查看文件

@@ -469,6 +469,9 @@ func (this *PharmacyApiController) GetReturnPharmacyBaseDrug() {
469 469
 func (this *PharmacyApiController) SaveSetting() {
470 470
 	var err error
471 471
 	defer func() {
472
+		if rec := recover(); rec != nil {
473
+			err = fmt.Errorf("程序异常:%v", rec)
474
+		}
472 475
 		if err != nil {
473 476
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
474 477
 		}

+ 158 - 0
controllers/err_msg.json 查看文件

@@ -0,0 +1,158 @@
1
+{
2
+  "msg": [
3
+    {
4
+      "url": "/m/api/solution?mode=1,/api/dialysis/soulution?mode=1,/api/patients/dialysissolution/create?mode=1",
5
+      "err_msg": "没有权限新增长期处方"
6
+    },{
7
+      "url": ",,/api/patients/dialysissolution/edit?mode=2",
8
+      "err_msg": "没有权限修改长期处方"
9
+    },{
10
+      "url": ",,/api/patients/dialysissolution/edit?mode=3",
11
+      "err_msg": "没有权限修改别人的长期处方"
12
+    },{
13
+      "url": "/m/api/dialysis/dialysisPrescription?mode=1,/api/dialysis/prescription?mode=1,",
14
+      "err_msg": "没有权限新增临时处方"
15
+    },{
16
+      "url": "/m/api/dialysis/dialysisPrescription?mode=3,/api/dialysis/prescription?mode=3,",
17
+      "err_msg": "没有权限修改他人的临时处方"
18
+    },{
19
+      "url": "/m/api/dialysis/acceptsAssessment?mode=1,/api/dialysis/accepts?mode=1,",
20
+      "err_msg": "没有权限新增接诊评估"
21
+    },{
22
+      "url": "/m/api/dialysis/acceptsAssessment?mode=2,/api/dialysis/accepts?mode=2,",
23
+      "err_msg": "没有权限修改接诊评估"
24
+    },{
25
+      "url": "/m/api/dialysis/acceptsAssessment?mode=3,/api/dialysis/accepts?mode=3,",
26
+      "err_msg": "没有权限修改别人接诊评估"
27
+    },{
28
+      "url": "/m/api/assessmentbefore/commit?mode=1,/api/dialysis/assessmentbeforedislysis?mode=1,",
29
+      "err_msg": "没有权限新增透前评估"
30
+    },{
31
+      "url": "/m/api/assessmentbefore/commit?mode=2,/api/dialysis/assessmentbeforedislysis?mode=2,",
32
+      "err_msg": "没有权限修改透前评估"
33
+    },{
34
+      "url": "/m/api/assessmentbefore/commit?mode=3,/api/dialysis/assessmentbeforedislysis?mode=3,",
35
+      "err_msg": "没有权限修改别人透前评估"
36
+    },{
37
+      "url": "/m/api/dialysis/start?mode=1,/api/dialysis/start_record?mode=1,",
38
+      "err_msg": "没有权限执行上机"
39
+    },{
40
+      "url": "/m/api/startOrder/edit?mode=2,/api/start_dialysis/modify?mode=2,",
41
+      "err_msg": "没有权限修改执行上机"
42
+    },{
43
+      "url": "/m/api/startOrder/edit?mode=3,/api/start_dialysis/modify?mode=3,",
44
+      "err_msg": "没有权限修改他人执行上机"
45
+    },{
46
+      "url": "/m/api/monitor/add?mode=1,/api/dislysis/monitor/edit?mode=1,",
47
+      "err_msg": "没有权限新增透析监测"
48
+    },{
49
+      "url": "/m/api/monitor/edit?mode=2,/api/dislysis/monitor/edit?mode=2,",
50
+      "err_msg": "没有权限修改透析监测"
51
+    },{
52
+      "url": "/m/api/monitor/edit?mode=3,/api/dislysis/monitor/edit?mode=3,",
53
+      "err_msg": "没有权限修改他人透析监测"
54
+    },{
55
+      "url": "/m/api/monitor/delete?mode=4,/api/dialysis/monitor/del?mode=4,",
56
+      "err_msg": "没有权限删除透析监测"
57
+    },{
58
+      "url": "/m/api/monitor/delete?mode=5,/api/dialysis/monitor/del?mode=5,",
59
+      "err_msg": "没有权限删除他人透析监测"
60
+    },{
61
+      "url": "/m/api/dialysis/finish?mode=1,/api/dialysis/finish?mode=1,",
62
+      "err_msg": "没有权限执行下机"
63
+    },{
64
+      "url": "/m/api/finishOrder/edit?mode=2,/api/finish_dialysis/modify?mode=2,",
65
+      "err_msg": "没有权限修改执行下机"
66
+    },{
67
+      "url": "/m/api/finishOrder/edit?mode=3,/api/finish_dialysis/modify?mode=3,",
68
+      "err_msg": "没有权限修改他人执行下机"
69
+    },{
70
+      "url": "/m/api/dialysis/assessmentAfterDislysis?mode=1,/api/dialysis/assessmentafterdislysis?mode=1,",
71
+      "err_msg": "没有权限新增透后评估"
72
+    },{
73
+      "url": "/m/api/dialysis/assessmentAfterDislysis?mode=2,/api/dialysis/assessmentafterdislysis?mode=2,",
74
+      "err_msg": "没有权限修改透后评估"
75
+    },{
76
+      "url": "/m/api/dialysis/assessmentAfterDislysis?mode=3,/api/dialysis/assessmentafterdislysis?mode=3,",
77
+      "err_msg": "没有权限修改他人透后评估"
78
+    },{
79
+      "url": "/m/api/dialysis/treatmentSummary?mode=1,/api/dialysis/treatmentsummary?mode=1,",
80
+      "err_msg": "没有权限新增治疗小结"
81
+    },{
82
+      "url": "/m/api/dialysis/treatmentSummary?mode=2,/api/dialysis/treatmentsummary?mode=2,",
83
+      "err_msg": "没有权限修改治疗小结"
84
+    },{
85
+      "url": "/m/api/dialysis/treatmentSummary?mode=3,/api/dialysis/treatmentsummary?mode=3,",
86
+      "err_msg": "没有权限修改他人治疗小结"
87
+    },{
88
+      "url": "/m/api/dryweight/commit?mode=1,/api/dryweight/commit?mode=1,/api/patient/updatedryweightdata?mode=1",
89
+      "err_msg": "没有权限新增干体重"
90
+    },{
91
+      "url": ",/api/patients/advice/create?mode=1-1,/api/patients/advice/creategroup?mode=1-1",
92
+      "err_msg": "没有权限新增临时医嘱"
93
+    },{
94
+      "url": ",/api/patients/advice/edit?mode=2-1,",
95
+      "err_msg": "没有权限修改临时医嘱"
96
+    },{
97
+      "url": ",/api/patients/advice/edit?mode=3-1,",
98
+      "err_msg": "没有权限修改他人临时医嘱"
99
+    },{
100
+      "url": ",/api/patients/advice/delete?mode=4-1,/api/patients/advice/deletegroup?mode=4-1",
101
+      "err_msg": "没有权限删除临时医嘱"
102
+    },{
103
+      "url": ",/api/patients/advice/delete?mode=5-1,/api/patients/advice/deletegroup?mode=5-1",
104
+      "err_msg": "没有权限删除他人开的临时医嘱"
105
+    },{
106
+      "url": ",/api/patients/advice/create?mode=1-2,/api/patients/advice/creategroup?mode=1-2",
107
+      "err_msg": "没有权限新增长期医嘱"
108
+    },{
109
+      "url": ",/api/patients/advice/edit?mode=1-3,",
110
+      "err_msg": "没有权限修改长期医嘱"
111
+    },{
112
+      "url": ",/api/patients/advice/edit?mode=1-4,",
113
+      "err_msg": "没有权限修改他人长期医嘱"
114
+    },{
115
+      "url": ",/api/patients/advice/stop?mode=1-5,",
116
+      "err_msg": "没有权限停止长期医嘱"
117
+    },{
118
+      "url": ",/api/patients/advice/delete?mode=1-6,/api/patients/advice/deletegroup?mode=1-6",
119
+      "err_msg": "没有权限删除长期医嘱"
120
+    },{
121
+      "url": ",/api/patients/advice/delete?mode=1-7,/api/patients/advice/deletegroup?mode=1-7",
122
+      "err_msg": "没有权限删除他人长期医嘱"
123
+    },{
124
+      "url": "/m/api/advice/creategroup?mode=1,/api/patients/advice/creategroup?mode=1,/api/patients/advice/create?mode=1",
125
+      "err_msg": "没有权限新增透析临时医嘱"
126
+    },{
127
+      "url": "/m/api/advice/edit?mode=2,/api/patients/advice/edit?mode=2,",
128
+      "err_msg": "没有权限修改透析临时医嘱"
129
+    },{
130
+      "url": "/m/api/advice/edit?mode=3,/api/patients/advice/edit?mode=3,",
131
+      "err_msg": "没有权限修改他人透析临时医嘱"
132
+    },{
133
+      "url": "/m/api/newadvice/delete?mode=4,/api/patients/advice/delete?mode=4,/api/patients/advice/deletegroup?mode=4",
134
+      "err_msg": "没有权限删除透析临时医嘱"
135
+    },{
136
+      "url": "/m/api/newadvice/delete?mode=5,/api/patients/advice/delete?mode=5,/api/patients/advice/deletegroup?mode=5",
137
+      "err_msg": "没有权限删除他人透析临时医嘱"
138
+    },{
139
+      "url": "/m/api/advice/exec?mode=6,/api/patients/advice/exec?mode=6,",
140
+      "err_msg": "没有权限执行透析临时医嘱"
141
+    },{
142
+      "url": "/m/api/advice/exec/modify?mode=8,,",
143
+      "err_msg": "没有权限修改已执行医嘱"
144
+    },{
145
+      "url": "/m/api/advice/check?mode=7,/api/patients/advice/check?mode=7,",
146
+      "err_msg": "没有权限核对透析临时医嘱"
147
+    },{
148
+      "url": ",/api/patients/advice/stop?mode=1-8,",
149
+      "err_msg": "没有权限停止他人长期医嘱"
150
+    },{
151
+      "url": ",/api/patients/advice/execgroup?mode=6-1,",
152
+      "err_msg": "没有权限执行医嘱"
153
+    },{
154
+      "url": ",/api/patients/advice/checkgroup?mode=7-1,",
155
+      "err_msg": "没有权限核对医嘱"
156
+    }
157
+  ]
158
+}

+ 8 - 2
controllers/his_api_controller.go 查看文件

@@ -2091,7 +2091,11 @@ func (c *HisApiController) CreateHisPrescription() {
2091 2091
 					stockInfo, _ := service.GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2092 2092
 					var sum_count int64
2093 2093
 					for _, its := range stockInfo {
2094
-						sum_count += its.StockMaxNumber*drug.MinNumber + its.StockMinNumber
2094
+						baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
2095
+						if its.MaxUnit == baseDrug.MaxUnit {
2096
+							its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
2097
+						}
2098
+						sum_count += its.StockMaxNumber + its.StockMinNumber
2095 2099
 					}
2096 2100
 					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2097 2101
 				}
@@ -6170,6 +6174,8 @@ func (c *HisApiController) GetFaPiaoData() {
6170 6174
 
6171 6175
 	his_hospital_record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
6172 6176
 
6177
+	patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
6178
+
6173 6179
 	//prescriptions, _ := service.GetHisPrescriptionThree(adminUser.CurrentOrgId, patient_id, order.Number)
6174 6180
 
6175 6181
 	var bedCostTotal float64 = 0         //床位总费
@@ -6505,7 +6511,7 @@ func (c *HisApiController) GetFaPiaoData() {
6505 6511
 		"number":                              his.Number,               //门诊号
6506 6512
 		"date":                                order.SettleAccountsDate, //结算日期
6507 6513
 		"name":                                order.PsnName,            //姓名
6508
-		"gender":                              order.Gend,               //性别
6514
+		"gender":                              patient.Gender,           //性别
6509 6515
 		"psn_cash_money":                      order.PsnCashPay,         //个人支付
6510 6516
 		"pay_way":                             "门诊",                     //结算方式
6511 6517
 		"medfee_sumamt":                       order.MedfeeSumamt,       //总费用

+ 936 - 1
controllers/his_config_api_controller.go 查看文件

@@ -6,9 +6,13 @@ import (
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8 8
 	"encoding/json"
9
+	"fmt"
9 10
 	"github.com/astaxie/beego"
11
+	"github.com/astaxie/beego/config"
12
+	"golang.org/x/sync/errgroup"
10 13
 	"reflect"
11 14
 	"strconv"
15
+	"strings"
12 16
 	"time"
13 17
 )
14 18
 
@@ -16,11 +20,16 @@ type HisConfigApiController struct {
16 20
 	BaseAuthAPIController
17 21
 }
18 22
 
23
+const (
24
+	AddTypeDrug    = 1 //药品
25
+	AddTypeProject = 2 //项目
26
+)
27
+
19 28
 func HisConfigApiRegistRouters() {
20 29
 	beego.Router("/api/his/patient/list", &HisConfigApiController{}, "get:GetAllHisPatientsList")
21 30
 	beego.Router("/api/his/prescriptiontemplate/list", &HisConfigApiController{}, "get:GetPrescriptionTemplateList")
22 31
 	beego.Router("/api/his/prescriptiontemplate/info", &HisConfigApiController{}, "get:GetPrescriptionTemplateInfo")
23
-	beego.Router("/api/his/prescriptiontemplate/create", &HisConfigApiController{}, "post:CreatePrescriptionTemplate")
32
+	beego.Router("/api/his/prescriptiontemplate/create", &HisConfigApiController{}, "post:CreatePrescriptionTemplate") //批量添加
24 33
 	beego.Router("/api/his/prescriptiontemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionTemplate")
25 34
 	beego.Router("/api/his/prescriptioninfotemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionInfoTemplate")
26 35
 	beego.Router("/api/his/advicetemplate/delete", &HisConfigApiController{}, "post:DeleteAdviceTemplate")
@@ -35,6 +44,19 @@ func HisConfigApiRegistRouters() {
35 44
 	beego.Router("/api/his/projectmodetemplate/delete", &HisConfigApiController{}, "post:DeleteModeProjectTemplate")
36 45
 	beego.Router("/api/his/advicempdetemplate/delete", &HisConfigApiController{}, "post:DeleteModeAdviceTemplate")
37 46
 	beego.Router("/api/his/prescriptioninfomodetemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionInfoModeTemplate")
47
+	beego.Router("/api/his/getdialysismodename", &HisConfigApiController{}, "get:GetDialysisModeName") //根据透析模式获取患者姓名
48
+	beego.Router("/api/his/getdrugsname", &HisConfigApiController{}, "get:GetDrugsName")               //根据类型获取药品名称
49
+	beego.Router("/api/his/getmodeconfigs", &HisConfigApiController{}, "get:GetModeConfigs")
50
+	beego.Router("/api/his/getdrugsinformation", &HisConfigApiController{}, "get:GetDrugsInformation") //根据id获取药品耗材项目基本信息
51
+	beego.Router("/api/his/replacepeoplename", &HisConfigApiController{}, "get:ReplacePeopleName")     //替换——获取患者名字
52
+	beego.Router("/api/his/replaceconfig", &HisConfigApiController{}, "get:ReplaceConfig")
53
+	beego.Router("/api/his/replacesavedrug", &HisConfigApiController{}, "post:ReplaceSaveDrug")          //替换——药品保存
54
+	beego.Router("/api/his/replacesaveproject", &HisConfigApiController{}, "post:ReplaceSaveProject")    //替换——项目保存
55
+	beego.Router("/api/his/deletedrugsbatch", &HisConfigApiController{}, "get:DeleteDrugsBatch")         //批量删除——药品
56
+	beego.Router("/api/his/batchdeleteitems", &HisConfigApiController{}, "get:BatchDeleteItems")         //批量删除——项目
57
+	beego.Router("/api/his/addstemplate", &HisConfigApiController{}, "post:AddsTemplate")                //批量添加
58
+	beego.Router("/api/his/ptemplateinformation", &HisConfigApiController{}, "get:PTemplateInformation") //根据患者id、透析模式获取处方模板信息
59
+	beego.Router("/api/his/deleteone", &HisConfigApiController{}, "get:DeleteOne")                       //删除单条处方模板
38 60
 }
39 61
 
40 62
 func (c *HisConfigApiController) GetAllHisPatientsList() {
@@ -898,3 +920,916 @@ func (c *HisConfigApiController) DeletePrescriptionInfoModeTemplate() {
898 920
 		return
899 921
 	}
900 922
 }
923
+
924
+func (c *HisConfigApiController) GetDialysisModeName() {
925
+	var err error
926
+	defer func() {
927
+		if rec := recover(); rec != nil {
928
+			err = fmt.Errorf("程序异常:%v", rec)
929
+		}
930
+		if err != nil {
931
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
932
+		}
933
+	}()
934
+	orgid := c.GetAdminUserInfo().CurrentOrgId
935
+	mode, _ := c.GetInt64("mode")
936
+	var list []*models.DialysisPatient
937
+	list, err = service.GetDialysisModePatient(orgid, mode)
938
+	if err != nil {
939
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
940
+		return
941
+	}
942
+	c.ServeSuccessJSON(map[string]interface{}{
943
+		"list": list,
944
+	})
945
+	return
946
+
947
+}
948
+func (c *HisConfigApiController) GetDrugsName() {
949
+	var err error
950
+	defer func() {
951
+		if rec := recover(); rec != nil {
952
+			err = fmt.Errorf("程序异常:%v", rec)
953
+		}
954
+		if err != nil {
955
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
956
+		}
957
+	}()
958
+	orgid := c.GetAdminUserInfo().CurrentOrgId
959
+	addtype, _ := c.GetInt("addtype")
960
+	//special,_ := c.GetInt("special")
961
+	//tmpBool := false
962
+	//if special == IsSpecialDiseases{
963
+	//	tmpBool = true
964
+	//}
965
+
966
+	tmp := make(map[string]interface{}, 0)
967
+	if addtype == AddTypeDrug {
968
+		var list []*models.ReplacementDrugs
969
+		list, err = service.ReplacementDrugs(orgid, true)
970
+		if err != nil {
971
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
972
+			return
973
+		}
974
+		var list2 []*models.ReplacementDrugs
975
+		list2, err = service.ReplacementDrugs(orgid, false)
976
+		if err != nil {
977
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
978
+			return
979
+		}
980
+		tmp["list"] = list
981
+		tmp["list2"] = list2
982
+	} else if addtype == AddTypeProject {
983
+		var list3 []*models.DropDownList
984
+		list3, err = service.ProjectConsumables2(orgid, true)
985
+		if err != nil {
986
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
987
+			return
988
+		}
989
+		var list4 []*models.DropDownList
990
+		list4, err = service.ProjectConsumables2(orgid, false)
991
+		if err != nil {
992
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
993
+			return
994
+		}
995
+		tmp["list"] = list3
996
+		tmp["list2"] = list4
997
+	} else {
998
+		err = fmt.Errorf("类型解析错误")
999
+		if err != nil {
1000
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1001
+			return
1002
+		}
1003
+	}
1004
+	c.ServeSuccessJSON(tmp)
1005
+	return
1006
+
1007
+}
1008
+
1009
+//配置项
1010
+func (c *HisConfigApiController) GetModeConfigs() {
1011
+	var err error
1012
+	defer func() {
1013
+		if rec := recover(); rec != nil {
1014
+			err = fmt.Errorf("程序异常:%v", rec)
1015
+		}
1016
+		if err != nil {
1017
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1018
+		}
1019
+	}()
1020
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1021
+	var drugways []*models.DrugwayDic
1022
+	var efs []*models.ExecutionFrequencyDic
1023
+	var dataconfig []*models.DictDataconfig
1024
+	drugways, _, err = service.GetDrugWayDics(orgid)
1025
+	if err != nil {
1026
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1027
+		return
1028
+	}
1029
+	efs, _, err = service.GetExecutionFrequencyDics(orgid)
1030
+	if err != nil {
1031
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1032
+		return
1033
+	}
1034
+	dataconfig, err = service.GetDataConfig(orgid)
1035
+	c.ServeSuccessJSON(map[string]interface{}{
1036
+		"drugways":   drugways,
1037
+		"efs":        efs,
1038
+		"dataconfig": dataconfig, //组
1039
+	})
1040
+	return
1041
+}
1042
+func (c *HisConfigApiController) GetDrugsInformation() {
1043
+	var err error
1044
+	defer func() {
1045
+		if rec := recover(); rec != nil {
1046
+			err = fmt.Errorf("程序异常:%v", rec)
1047
+		}
1048
+		if err != nil {
1049
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1050
+		}
1051
+	}()
1052
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1053
+	id := c.GetString("id", "")
1054
+	if len(id) == 0 {
1055
+		err = fmt.Errorf("参数错误")
1056
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1057
+		return
1058
+	}
1059
+	var list interface{}
1060
+	list, err = service.QueryFourTables(id, orgid)
1061
+	if err != nil {
1062
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1063
+		return
1064
+	}
1065
+	c.ServeSuccessJSON(map[string]interface{}{
1066
+		"list": list,
1067
+	})
1068
+	return
1069
+}
1070
+
1071
+func (c *HisConfigApiController) ReplacePeopleName() {
1072
+	var g errgroup.Group
1073
+	var err error
1074
+	defer func() {
1075
+		if rec := recover(); rec != nil {
1076
+			err = fmt.Errorf("程序异常:%v", rec)
1077
+		}
1078
+		if err != nil {
1079
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1080
+		}
1081
+	}()
1082
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1083
+	mode, _ := c.GetInt64("mode") //透析模式
1084
+	id := c.GetString("id", "")   //药品/项目/耗材id
1085
+	if id == "" {
1086
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
1087
+		return
1088
+	}
1089
+	var list []*models.DialysisPatient
1090
+	finlist := make([]*models.DialysisPatient, 0) //筛选后的列表
1091
+	list, err = service.GetDialysisModePatient(orgid, mode)
1092
+	if err != nil {
1093
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1094
+		return
1095
+	}
1096
+	for _, v := range list {
1097
+		v := v
1098
+		g.Go(func() error {
1099
+			//判断该患者是否有使用该药品/项目/耗材
1100
+			tmpid := id[:1]
1101
+			bo := false
1102
+			if tmpid == "p" {
1103
+				pid := id[1:]
1104
+				tmpisid, _ := strconv.ParseInt(pid, 10, 64)
1105
+				tp := service.FindPatientXiang(orgid, v.ID, tmpisid, mode)
1106
+				if tp {
1107
+					bo = true
1108
+				}
1109
+
1110
+			} else if tmpid == "i" {
1111
+				pid := id[1:]
1112
+				tmpisid, _ := strconv.ParseInt(pid, 10, 64)
1113
+				tp := service.FindPatientXiang2(orgid, v.ID, tmpisid, mode)
1114
+				if tp {
1115
+					bo = true
1116
+				}
1117
+			} else {
1118
+				pid := id
1119
+				tmpisid, _ := strconv.ParseInt(pid, 10, 64)
1120
+				tp := service.FindPatientDrug(orgid, v.ID, tmpisid, mode)
1121
+				if tp {
1122
+					bo = true
1123
+				}
1124
+			}
1125
+			if bo {
1126
+				finlist = append(finlist, v)
1127
+			}
1128
+			return nil
1129
+		})
1130
+	}
1131
+	if err = g.Wait(); err != nil {
1132
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1133
+		return
1134
+	}
1135
+
1136
+	c.ServeSuccessJSON(map[string]interface{}{
1137
+		"list": finlist,
1138
+	})
1139
+	return
1140
+}
1141
+func (c *HisConfigApiController) ReplaceConfig() {
1142
+	var err error
1143
+	defer func() {
1144
+		if rec := recover(); rec != nil {
1145
+			err = fmt.Errorf("程序异常:%v", rec)
1146
+		}
1147
+		if err != nil {
1148
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1149
+		}
1150
+	}()
1151
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1152
+	tmp := make(map[string]interface{}, 0)
1153
+	var list []*models.ReplacementDrugs
1154
+	var list2 []*models.DropDownList
1155
+	list, err = service.ReplacementDrugsT(orgid)
1156
+	if err != nil {
1157
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1158
+		return
1159
+	}
1160
+	tmp["list"] = list
1161
+	list2, err = service.ProjectConsumables2T(orgid)
1162
+	if err != nil {
1163
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1164
+		return
1165
+	}
1166
+	tmp["list2"] = list2
1167
+	c.ServeSuccessJSON(tmp)
1168
+	return
1169
+
1170
+}
1171
+
1172
+//批量替换——药品
1173
+func (c *HisConfigApiController) ReplaceSaveDrug() {
1174
+	var g errgroup.Group
1175
+	var err error
1176
+	tx := service.XTWriteDB().Begin()
1177
+	defer func() {
1178
+		if rec := recover(); rec != nil {
1179
+			err = fmt.Errorf("程序异常:%v", rec)
1180
+		}
1181
+		if err != nil {
1182
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1183
+			tx.Rollback()
1184
+		} else {
1185
+			tx.Commit()
1186
+		}
1187
+	}()
1188
+	mode_id, _ := c.GetInt64("mode_id", 0)  //透析模式
1189
+	types, _ := c.GetInt64("type", 1)       //1.药品 2.项目
1190
+	patient_id := c.GetString("patient_id") //患者
1191
+	replaced := c.GetString("replaced", "") //被替换的药品、项目、耗材id
1192
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1193
+	dataBody := make(map[string]interface{}, 0)
1194
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1195
+	if err != nil {
1196
+		utils.ErrorLog(err.Error())
1197
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1198
+		return
1199
+	}
1200
+	t_ids := ""
1201
+	if patient_id[len(patient_id)-1] == 44 {
1202
+		t_ids = patient_id[:len(patient_id)-1]
1203
+	} else {
1204
+		t_ids = patient_id
1205
+	}
1206
+	tmp_id := strings.Split(t_ids, ",")
1207
+	ids := service.GetHisInfoTempalteId(mode_id, orgid, types) //获取所有药品模板id
1208
+	drugid, _ := strconv.ParseInt(replaced, 10, 64)
1209
+	for _, v := range tmp_id {
1210
+		v := v
1211
+		g.Go(func() error {
1212
+			pp, _ := strconv.ParseInt(v, 10, 64) //患者id
1213
+			var err error
1214
+			if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
1215
+				prescriptions, _ := dataBody["prescriptions"].([]interface{})
1216
+				if len(prescriptions) > 0 {
1217
+					for _, item := range prescriptions {
1218
+						items := item.(map[string]interface{})
1219
+						var s models.HisPrescriptionAdviceTemplate
1220
+						var tmpdrugid int64
1221
+						if items["drug_name"] != nil && reflect.TypeOf(items["drug_name"]).String() == "string" {
1222
+							tmpdrugid, _ = strconv.ParseInt(items["drug_name"].(string), 10, 64)
1223
+						}
1224
+						if items["drug_name"] != nil && reflect.TypeOf(items["drug_name"]).String() == "float64" {
1225
+							tmpdrugid = int64(items["drug_name"].(float64))
1226
+						}
1227
+						s.AdviceName = service.FindDrugsName(tmpdrugid) //药品名称
1228
+						if items["id"] == nil {
1229
+							err = fmt.Errorf("缺少参数")
1230
+							return err
1231
+						} else {
1232
+							if items["id"] != nil && reflect.TypeOf(items["id"]).String() == "string" {
1233
+								tmp_drugid := items["id"].(string)
1234
+								drug_id, _ := strconv.ParseInt(tmp_drugid, 10, 64)
1235
+								s.DrugId = drug_id //药品id
1236
+							}
1237
+							if items["id"] != nil && reflect.TypeOf(items["id"]).String() == "float64" {
1238
+								drug_id := int64(items["id"].(float64))
1239
+								s.DrugId = drug_id
1240
+							}
1241
+						}
1242
+						if items["remark"] != nil && reflect.TypeOf(items["remark"]).String() == "string" {
1243
+							remark, _ := items["remark"].(string)
1244
+							s.Remark = remark //备注
1245
+						}
1246
+						if items["single_dose"] != nil && reflect.TypeOf(items["single_dose"]).String() == "string" {
1247
+							singleDose, _ := strconv.ParseFloat(items["single_dose"].(string), 64)
1248
+							s.SingleDose = singleDose
1249
+						}
1250
+						if items["single_dose"] != nil && reflect.TypeOf(items["single_dose"]).String() == "float64" {
1251
+							singleDose := items["single_dose"].(float64)
1252
+							s.SingleDose = singleDose
1253
+						}
1254
+						if items["single_dose_unit"] != nil && reflect.TypeOf(items["single_dose_unit"]).String() == "string" {
1255
+							singleDoseUnit, _ := items["single_dose_unit"].(string)
1256
+							s.SingleDoseUnit = singleDoseUnit
1257
+						}
1258
+						if items["prescribing_number"] != nil && reflect.TypeOf(items["prescribing_number"]).String() == "string" {
1259
+							prescribingNumber, _ := strconv.ParseFloat(items["prescribing_number"].(string), 64)
1260
+							s.PrescribingNumber = prescribingNumber
1261
+						}
1262
+						if items["prescribing_number"] != nil && reflect.TypeOf(items["prescribing_number"]).String() == "float64" {
1263
+							prescribingNumber := items["prescribing_number"].(float64)
1264
+							s.PrescribingNumber = prescribingNumber
1265
+						}
1266
+						if items["prescribing_number_unit"] != nil && reflect.TypeOf(items["prescribing_number_unit"]).String() == "string" {
1267
+							prescribingNumberUnit, _ := items["prescribing_number_unit"].(string)
1268
+							s.PrescribingNumberUnit = prescribingNumberUnit
1269
+						}
1270
+						if items["delivery_way"] != nil && reflect.TypeOf(items["delivery_way"]).String() == "string" {
1271
+							deliveryWay, _ := items["delivery_way"].(string)
1272
+							s.DeliveryWay = deliveryWay
1273
+						}
1274
+						if items["execution_frequency"] != nil && reflect.TypeOf(items["execution_frequency"]).String() == "string" {
1275
+							executionFrequency, _ := items["execution_frequency"].(string)
1276
+							s.ExecutionFrequency = executionFrequency
1277
+						}
1278
+						if items["price"] != nil && reflect.TypeOf(items["price"]).String() == "string" {
1279
+							price, _ := strconv.ParseFloat(items["price"].(string), 64)
1280
+							s.Price = price
1281
+						}
1282
+						if items["price"] != nil && reflect.TypeOf(items["price"]).String() == "float64" {
1283
+							price := items["price"].(float64)
1284
+							s.Price = price
1285
+						}
1286
+						if items["day"] != nil && reflect.TypeOf(items["day"]).String() == "string" {
1287
+							day, _ := strconv.ParseInt(items["day"].(string), 10, 64)
1288
+							s.Day = day
1289
+						}
1290
+						if items["day"] != nil && reflect.TypeOf(items["day"]).String() == "float64" {
1291
+							day := int64(items["day"].(float64))
1292
+							s.Day = day
1293
+						}
1294
+						s.FrequencyType = 1
1295
+						err = service.ReplaceDrugPrescriptionTemplate(orgid, pp, drugid, ids, s, tx)
1296
+						if err != nil {
1297
+							return err
1298
+						}
1299
+
1300
+					}
1301
+					return nil
1302
+				}
1303
+			}
1304
+			return err
1305
+		})
1306
+	}
1307
+	if errs := g.Wait(); errs != nil {
1308
+		err = errs
1309
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
1310
+		return
1311
+	}
1312
+	c.ServeSuccessJSON(map[string]interface{}{
1313
+		"list": "替换成功",
1314
+	})
1315
+	return
1316
+}
1317
+
1318
+//批量替换项目
1319
+func (c *HisConfigApiController) ReplaceSaveProject() {
1320
+	var g errgroup.Group
1321
+	var err error
1322
+	tx := service.XTWriteDB().Begin()
1323
+	defer func() {
1324
+		if rec := recover(); rec != nil {
1325
+			err = fmt.Errorf("程序异常:%v", rec)
1326
+		}
1327
+		if err != nil {
1328
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1329
+			tx.Rollback()
1330
+		} else {
1331
+			tx.Commit()
1332
+		}
1333
+	}()
1334
+	mode_id, _ := c.GetInt64("mode_id", 0)  //透析模式
1335
+	types, _ := c.GetInt64("type", 2)       //1.药品 2.项目
1336
+	patient_id := c.GetString("patient_id") //患者
1337
+	replaced := c.GetString("replaced", "") //被替换的药品、项目、耗材id
1338
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1339
+	dataBody := make(map[string]interface{}, 0)
1340
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1341
+	if err != nil {
1342
+		utils.ErrorLog(err.Error())
1343
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1344
+		return
1345
+	}
1346
+	t_ids := ""
1347
+	if patient_id[len(patient_id)-1] == 44 {
1348
+		t_ids = patient_id[:len(patient_id)-1]
1349
+	} else {
1350
+		t_ids = patient_id
1351
+	}
1352
+	tmp_id := strings.Split(t_ids, ",")
1353
+	ids := service.GetHisInfoTempalteId(mode_id, orgid, types) //获取所有药品模板id
1354
+	drugid, _ := strconv.ParseInt(replaced[1:], 10, 64)
1355
+	for _, v := range tmp_id {
1356
+		v := v
1357
+		g.Go(func() error {
1358
+			pp, _ := strconv.ParseInt(v, 10, 64) //患者id
1359
+			var err error
1360
+			if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
1361
+				prescriptions, _ := dataBody["prescriptions"].([]interface{})
1362
+				if len(prescriptions) > 0 {
1363
+					for _, item := range prescriptions {
1364
+						items := item.(map[string]interface{})
1365
+						var s models.HisPrescriptionProjectTemplate
1366
+						if items["id"] != nil {
1367
+							id := items["id"].(string)
1368
+							if id != "" {
1369
+								tmpPid := id[1:]
1370
+								project_id, _ := strconv.ParseInt(tmpPid, 10, 64)
1371
+								if id[0] == 112 {
1372
+									s.Type = 2
1373
+								}
1374
+								if id[0] == 105 {
1375
+									s.Type = 3
1376
+								}
1377
+								s.ProjectId = project_id
1378
+							} else {
1379
+								s.ProjectId = int64(0)
1380
+							}
1381
+
1382
+						}
1383
+						if items["frequency_type"] != nil && reflect.TypeOf(items["frequency_type"]).String() == "string" {
1384
+							tmp_drugid := items["frequency_type"].(string)
1385
+							frequency_type, _ := strconv.ParseInt(tmp_drugid, 10, 64)
1386
+							s.FrequencyType = frequency_type
1387
+						}
1388
+						if items["frequency_type"] != nil && reflect.TypeOf(items["frequency_type"]).String() == "float64" {
1389
+							frequency_type := int64(items["frequency_type"].(float64))
1390
+							s.FrequencyType = frequency_type
1391
+						}
1392
+						if items["day_count"] != nil && reflect.TypeOf(items["day_count"]).String() == "string" {
1393
+							tmp_drugid := items["day_count"].(string)
1394
+							day_count, _ := strconv.ParseInt(tmp_drugid, 10, 64)
1395
+							s.DayCount = day_count
1396
+						}
1397
+						if items["day_count"] != nil && reflect.TypeOf(items["day_count"]).String() == "float64" {
1398
+							day_count := int64(items["day_count"].(float64))
1399
+							s.DayCount = day_count
1400
+						}
1401
+						if items["week_day"] != nil && reflect.TypeOf(items["week_day"]).String() == "string" {
1402
+							week_day, _ := items["week_day"].(string)
1403
+							s.WeekDay = week_day
1404
+						}
1405
+						if items["week_day"] != nil && reflect.TypeOf(items["week_day"]).String() == "float64" {
1406
+							week_day := config.ToString(items["week_day"].(float64))
1407
+							s.WeekDay = week_day
1408
+						}
1409
+						if items["price"] != nil && reflect.TypeOf(items["price"]).String() == "string" {
1410
+							price, _ := strconv.ParseFloat(items["price"].(string), 64)
1411
+							s.Price = price
1412
+						}
1413
+
1414
+						if items["price"] != nil && reflect.TypeOf(items["price"]).String() == "float64" {
1415
+							price := items["price"].(float64)
1416
+							s.Price = price
1417
+						}
1418
+						if items["prescribing_number"] != nil && reflect.TypeOf(items["prescribing_number"]).String() == "string" {
1419
+							total, _ := items["prescribing_number"].(string)
1420
+							//totals, _ := strconv.ParseInt(total, 10, 64)
1421
+							s.Count = total
1422
+						}
1423
+						if items["prescribing_number"] != nil && reflect.TypeOf(items["prescribing_number"]).String() == "float64" {
1424
+							total := config.ToString(items["prescribing_number"].(float64))
1425
+							//totals, _ := strconv.ParseInt(total, 10, 64)
1426
+							s.Count = total
1427
+						}
1428
+						if items["single_dose"] != nil && reflect.TypeOf(items["single_dose"]).String() == "string" {
1429
+							single_dose, _ := items["single_dose"].(string)
1430
+							s.SingleDose = single_dose
1431
+						}
1432
+						if items["single_dose"] != nil && reflect.TypeOf(items["single_dose"]).String() == "float64" {
1433
+							single_dose := config.ToString(items["single_dose"].(float64))
1434
+							s.SingleDose = single_dose
1435
+						}
1436
+						if items["delivery_way"] != nil && reflect.TypeOf(items["delivery_way"]).String() == "string" {
1437
+							delivery_way, _ := items["delivery_way"].(string)
1438
+							s.DeliveryWay = delivery_way
1439
+						}
1440
+						if items["execution_frequency"] != nil && reflect.TypeOf(items["execution_frequency"]).String() == "string" {
1441
+							execution_frequency, _ := items["execution_frequency"].(string)
1442
+							s.ExecutionFrequency = execution_frequency
1443
+						}
1444
+						if items["remark"] != nil && reflect.TypeOf(items["remark"]).String() == "string" {
1445
+							remark, _ := items["remark"].(string)
1446
+							s.Remark = remark
1447
+						}
1448
+						if items["day"] != nil && reflect.TypeOf(items["remark"]).String() == "string" {
1449
+							day, _ := items["number_days"].(string)
1450
+							s.Day = day
1451
+						}
1452
+						if items["day"] != nil && reflect.TypeOf(items["remark"]).String() == "float64" {
1453
+							day := config.ToString(items["number_days"].(float64))
1454
+							s.Day = day
1455
+						}
1456
+
1457
+						if items["unit"] != nil && reflect.TypeOf(items["unit"]).String() == "string" {
1458
+							unit, _ := items["unit"].(string)
1459
+							s.Unit = unit
1460
+						}
1461
+						err = service.ReplaceProjectPrescriptionTemplate(orgid, pp, drugid, ids, s, tx)
1462
+						if err != nil {
1463
+							return err
1464
+						}
1465
+
1466
+					}
1467
+					return nil
1468
+				}
1469
+			}
1470
+			return err
1471
+		})
1472
+	}
1473
+	if errs := g.Wait(); errs != nil {
1474
+		err = errs
1475
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
1476
+		return
1477
+	}
1478
+	c.ServeSuccessJSON(map[string]interface{}{
1479
+		"list": "替换成功",
1480
+	})
1481
+	return
1482
+}
1483
+
1484
+//批量删除项目
1485
+func (c *HisConfigApiController) BatchDeleteItems() {
1486
+	var g errgroup.Group
1487
+	var err error
1488
+	tx := service.XTWriteDB().Begin()
1489
+	defer func() {
1490
+		if rec := recover(); rec != nil {
1491
+			err = fmt.Errorf("程序异常:%v", rec)
1492
+		}
1493
+		if err != nil {
1494
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1495
+			tx.Rollback()
1496
+		} else {
1497
+			tx.Commit()
1498
+		}
1499
+	}()
1500
+	mode_id, _ := c.GetInt64("mode_id", 0)  //透析模式
1501
+	types, _ := c.GetInt64("type", 2)       //1.药品 2.项目
1502
+	patient_id := c.GetString("patient_id") //患者
1503
+	replaced := c.GetString("replaced", "") //被删除的药品、项目、耗材id
1504
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1505
+	t_ids := ""
1506
+	if patient_id[len(patient_id)-1] == 44 {
1507
+		t_ids = patient_id[:len(patient_id)-1]
1508
+	} else {
1509
+		t_ids = patient_id
1510
+	}
1511
+	tmp_id := strings.Split(t_ids, ",")
1512
+	ids := service.GetHisInfoTempalteId(mode_id, orgid, types) //获取所有药品模板id
1513
+	drugid, _ := strconv.ParseInt(replaced[1:], 10, 64)
1514
+	for _, v := range tmp_id {
1515
+		v := v
1516
+		g.Go(func() error {
1517
+			pp, _ := strconv.ParseInt(v, 10, 64) //患者id
1518
+			var err error
1519
+			err = service.DeleteProjectTemplate(orgid, pp, drugid, ids, tx)
1520
+			return err
1521
+		})
1522
+	}
1523
+	if errs := g.Wait(); errs != nil {
1524
+		err = errs
1525
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
1526
+		return
1527
+	}
1528
+	c.ServeSuccessJSON(map[string]interface{}{
1529
+		"list": "删除成功",
1530
+	})
1531
+	return
1532
+}
1533
+
1534
+//批量删除药品
1535
+func (c *HisConfigApiController) DeleteDrugsBatch() {
1536
+	var g errgroup.Group
1537
+	var err error
1538
+	tx := service.XTWriteDB().Begin()
1539
+	defer func() {
1540
+		if rec := recover(); rec != nil {
1541
+			err = fmt.Errorf("程序异常:%v", rec)
1542
+		}
1543
+		if err != nil {
1544
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1545
+			tx.Rollback()
1546
+		} else {
1547
+			tx.Commit()
1548
+		}
1549
+	}()
1550
+	mode_id, _ := c.GetInt64("mode_id", 0)  //透析模式
1551
+	types, _ := c.GetInt64("type", 1)       //1.药品 2.项目
1552
+	patient_id := c.GetString("patient_id") //患者
1553
+	replaced := c.GetString("replaced", "") //被替换的药品、项目、耗材id
1554
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1555
+	t_ids := ""
1556
+	if patient_id[len(patient_id)-1] == 44 {
1557
+		t_ids = patient_id[:len(patient_id)-1]
1558
+	} else {
1559
+		t_ids = patient_id
1560
+	}
1561
+	tmp_id := strings.Split(t_ids, ",")
1562
+	ids := service.GetHisInfoTempalteId(mode_id, orgid, types) //获取所有药品模板id
1563
+	drugid, _ := strconv.ParseInt(replaced, 10, 64)
1564
+	for _, v := range tmp_id {
1565
+		v := v
1566
+		g.Go(func() error {
1567
+			pp, _ := strconv.ParseInt(v, 10, 64) //患者id
1568
+			var err error
1569
+			err = service.DeletePrescriptionTemplate(orgid, pp, drugid, ids, tx)
1570
+			return err
1571
+		})
1572
+	}
1573
+	if errs := g.Wait(); errs != nil {
1574
+		err = errs
1575
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
1576
+		return
1577
+	}
1578
+	c.ServeSuccessJSON(map[string]interface{}{
1579
+		"list": "删除成功",
1580
+	})
1581
+	return
1582
+}
1583
+
1584
+//批量添加
1585
+func (c *HisConfigApiController) AddsTemplate() {
1586
+	var g errgroup.Group
1587
+	var err error
1588
+	defer func() {
1589
+		if rec := recover(); rec != nil {
1590
+			err = fmt.Errorf("程序异常:%v", rec)
1591
+		}
1592
+		if err != nil {
1593
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1594
+		}
1595
+	}()
1596
+	//id, _ := c.GetInt64("id")
1597
+	name := c.GetString("name", "")
1598
+	mode_id, _ := c.GetInt64("mode_id", 0)
1599
+	types, _ := c.GetInt64("type", 1) //没啥用
1600
+	patient_id := c.GetString("patient_id")
1601
+	//patient_id, _ := c.GetInt64("patient_id", 0)
1602
+	if name == "" {
1603
+		name = service.DialysisModeName(mode_id)
1604
+	}
1605
+	adminInfo := c.GetAdminUserInfo()
1606
+	dataBody := make(map[string]interface{}, 0)
1607
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1608
+	if err != nil {
1609
+		utils.ErrorLog(err.Error())
1610
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1611
+		return
1612
+	}
1613
+	t_ids := ""
1614
+	if patient_id[len(patient_id)-1] == 44 {
1615
+		t_ids = patient_id[:len(patient_id)-1]
1616
+	} else {
1617
+		t_ids = patient_id
1618
+	}
1619
+	tmp_id := strings.Split(t_ids, ",")
1620
+	for _, v := range tmp_id {
1621
+		v := v
1622
+		g.Go(func() error {
1623
+			var err error
1624
+			pa, _ := strconv.ParseInt(v, 10, 64)
1625
+			tmp_bool_id := service.IsDialysisMode(adminInfo.CurrentOrgId, pa, mode_id)
1626
+
1627
+			var src_template models.HisPrescriptionTemplate
1628
+			if !tmp_bool_id {
1629
+				template := models.HisPrescriptionTemplate{
1630
+					UserOrgId: adminInfo.CurrentOrgId,
1631
+					PatientId: pa,
1632
+					Type:      types,
1633
+					Status:    1,
1634
+					Ctime:     time.Now().Unix(),
1635
+					Mtime:     time.Now().Unix(),
1636
+					Name:      name,
1637
+					Mode:      mode_id,
1638
+				}
1639
+				src_template = template
1640
+				service.CreateHisPrescriptionTemplate(&src_template)
1641
+			} else {
1642
+				//查询出该模板的id
1643
+				src_template, err = service.IdOfTheTemplate(adminInfo.CurrentOrgId, pa, mode_id)
1644
+				if err != nil {
1645
+					return err
1646
+				}
1647
+				src_template.Name = name
1648
+				src_template.Mode = mode_id
1649
+				service.SaveHisPrescriptionTemplate(&src_template)
1650
+			}
1651
+
1652
+			if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
1653
+				prescriptions, _ := dataBody["prescriptions"].([]interface{})
1654
+				if len(prescriptions) > 0 {
1655
+					for _, item := range prescriptions {
1656
+						items := item.(map[string]interface{})
1657
+
1658
+						id := int64(0)
1659
+						//fmt.Println("111111111111111111111")
1660
+						//if items["type"] == nil {
1661
+						//	utils.ErrorLog("type")
1662
+						//	//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1663
+						//	fmt.Println("222222222222222")
1664
+						//	err = fmt.Errorf("参数错误")
1665
+						//	return err
1666
+						//}
1667
+						//fmt.Println("33333333333")
1668
+						//type1 := types
1669
+						med_type := ""
1670
+						var tmps float64
1671
+						if items["patient_value"] != nil && reflect.TypeOf(items["patient_value"]).String() == "float64" {
1672
+							tmps = items["patient_value"].(float64)
1673
+						}
1674
+						if items["patient_value"] != nil && reflect.TypeOf(items["patient_value"]).String() == "string" {
1675
+							tmps, _ = strconv.ParseFloat(items["patient_value"].(string), 64)
1676
+						}
1677
+						if tmps == 1 {
1678
+							med_type = "11"
1679
+						} else if tmps == 2 {
1680
+							med_type = "14"
1681
+						} else {
1682
+							err = fmt.Errorf("医疗类型参数错误")
1683
+						}
1684
+
1685
+						ctime := time.Now().Unix()
1686
+						prescription := &models.HisPrescriptionInfoTemplate{
1687
+							ID:          id,
1688
+							PatientId:   pa,
1689
+							UserOrgId:   adminInfo.CurrentOrgId,
1690
+							Ctime:       ctime,
1691
+							Mtime:       ctime,
1692
+							Type:        types,
1693
+							Modifier:    adminInfo.AdminUser.Id,
1694
+							Creator:     adminInfo.AdminUser.Id,
1695
+							Status:      1,
1696
+							PTemplateId: src_template.ID,
1697
+							MedType:     med_type,
1698
+						}
1699
+						service.CreateHisPrescriptionInfoTemplate(prescription)
1700
+
1701
+						if items["tableDatas"] != nil && reflect.TypeOf(items["tableDatas"]).String() == "[]interface {}" {
1702
+							advices := items["tableDatas"].([]interface{})
1703
+							//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
1704
+							groupNo := int64(0)
1705
+							ctime := time.Now().Unix()
1706
+							mtime := ctime
1707
+							if len(advices) > 0 {
1708
+								for k, advice := range advices {
1709
+									var s models.HisPrescriptionAdviceTemplate
1710
+									s.PrescriptionId = prescription.ID
1711
+									s.AdviceType = 2
1712
+									s.StopState = 2
1713
+									s.ExecutionState = 2
1714
+									s.Status = 1
1715
+									s.UserOrgId = adminInfo.CurrentOrgId
1716
+									s.Groupno = groupNo
1717
+									s.CreatedTime = ctime
1718
+									s.UpdatedTime = mtime
1719
+									s.PatientId = pa
1720
+									errcode := service.FensetAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
1721
+									if errcode > 0 {
1722
+										//c.ServeFailJSONWithSGJErrorCode(errcode)
1723
+										err = fmt.Errorf("参数错误")
1724
+										return err
1725
+									}
1726
+									if s.FrequencyType == 0 {
1727
+										s.FrequencyType = 1
1728
+									}
1729
+									s.Groupno = int64(k + 1) //序号
1730
+									if s.DrugId != 0 {
1731
+										service.CreateHisPrescriptionAdviceTemplate(&s)
1732
+									}
1733
+								}
1734
+							}
1735
+						}
1736
+						if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
1737
+							projects := items["project"].([]interface{})
1738
+							if len(projects) > 0 {
1739
+								for _, project := range projects {
1740
+									var p models.HisPrescriptionProjectTemplate
1741
+									p.PrescriptionId = prescription.ID
1742
+									p.Ctime = time.Now().Unix()
1743
+									p.Mtime = time.Now().Unix()
1744
+									p.PatientId = pa
1745
+									p.UserOrgId = adminInfo.CurrentOrgId
1746
+									p.Status = 1
1747
+									errcode := service.FensetProjectTemplateWithJSON(&p, project.(map[string]interface{}))
1748
+									if errcode > 0 {
1749
+										//c.ServeFailJSONWithSGJErrorCode(errcode)
1750
+										err = fmt.Errorf("参数错误")
1751
+										return err
1752
+									}
1753
+									if p.FrequencyType == 0 {
1754
+										p.FrequencyType = 1
1755
+									}
1756
+									if p.ProjectId != 0 {
1757
+										service.CreateHisPrescriptionProjectTemplate(&p)
1758
+									}
1759
+
1760
+								}
1761
+							}
1762
+						}
1763
+					}
1764
+					return nil
1765
+				}
1766
+			}
1767
+			return err
1768
+		})
1769
+	}
1770
+	if errs := g.Wait(); errs != nil {
1771
+		err = errs
1772
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
1773
+		return
1774
+	}
1775
+	c.ServeSuccessJSON(map[string]interface{}{
1776
+		"list": "创建成功",
1777
+	})
1778
+	return
1779
+
1780
+}
1781
+
1782
+//根据透析模式和患者id获取该患者的处方内容
1783
+func (c *HisConfigApiController) PTemplateInformation() {
1784
+	var err error
1785
+	defer func() {
1786
+		if rec := recover(); rec != nil {
1787
+			err = fmt.Errorf("程序异常:%v", rec)
1788
+		}
1789
+		if err != nil {
1790
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1791
+		}
1792
+	}()
1793
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1794
+	mode_id, _ := c.GetInt64("mode_id", 0)    //透析模式
1795
+	patient_id, _ := c.GetInt64("patient_id") //患者
1796
+	list, err := service.PTemplateInformation(orgid, mode_id, patient_id)
1797
+	if err != nil {
1798
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1799
+		return
1800
+	}
1801
+	c.ServeSuccessJSON(map[string]interface{}{
1802
+		"list": list,
1803
+	})
1804
+	return
1805
+}
1806
+
1807
+//删除单条记录
1808
+func (c *HisConfigApiController) DeleteOne() {
1809
+	var err error
1810
+	defer func() {
1811
+		if rec := recover(); rec != nil {
1812
+			err = fmt.Errorf("程序异常:%v", rec)
1813
+		}
1814
+		if err != nil {
1815
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1816
+		}
1817
+	}()
1818
+	orgid := c.GetAdminUserInfo().CurrentOrgId
1819
+	types, _ := c.GetInt64("type") //透析模式
1820
+	id, _ := c.GetInt64("id")      //患者
1821
+	err = service.DeleteOne(types, id)
1822
+	if err != nil {
1823
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1824
+		return
1825
+	}
1826
+	err = service.Scavenger(orgid)
1827
+	if err != nil {
1828
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
1829
+		return
1830
+	}
1831
+	c.ServeSuccessJSON(map[string]interface{}{
1832
+		"list": "成功",
1833
+	})
1834
+	return
1835
+}

+ 0 - 4
controllers/mobile_api_controllers/check_weight_api_controller.go 查看文件

@@ -300,15 +300,11 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
300 300
 
301 301
 			//判断透析模式,针对河间咸的
302 302
 			if adminUserInfo.Org.Id == 10090 {
303
-
304 303
 				if dialysisSolution.ModeId != 2 && dialysisSolution.ModeId != 5 && dialysisSolution.ModeId != 12 {
305
-
306 304
 					dialysisSolution.DisplaceLiquiPart = 0
307 305
 					dialysisSolution.DisplaceLiquiValue = 0
308 306
 				}
309
-
310 307
 				if lastDialysisPrescribe.ModeId != 2 && lastDialysisPrescribe.ModeId != 5 && lastDialysisPrescribe.ModeId != 12 {
311
-
312 308
 					dialysisSolution.DisplaceLiquiPart = 0
313 309
 					dialysisSolution.DisplaceLiquiValue = 0
314 310
 				}

+ 118 - 3
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

@@ -87,7 +87,7 @@ func (this *DialysisAPIController) Scheduals() {
87 87
 	defer redis.Close()
88 88
 
89 89
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
90
-
90
+	fmt.Println("key22332323232232323", key)
91 91
 	scheduals_json_str, _ := redis.Get(key).Result()
92 92
 	redis.Set(key, "", time.Second)
93 93
 	patients, _ := service.GetAllPatientListSix(orgID)
@@ -412,6 +412,7 @@ func (this *DialysisAPIController) DialysisRecord() {
412 412
 
413 413
 	go func() {
414 414
 		doctorAdvices, _ = service.MobileGetDoctorAdvicesByGroups(adminInfo.Org.Id, patientID, date.Unix())
415
+
415 416
 		ch <- struct{}{}
416 417
 	}()
417 418
 
@@ -573,7 +574,7 @@ func (this *DialysisAPIController) DialysisRecord() {
573 574
 	if is_advice_open.IsAdviceOpen == 1 {
574 575
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
575 576
 	}
576
-
577
+	fmt.Println("doctorAdvices23344334344433434334343434wode", doctorAdvices)
577 578
 	returnData := map[string]interface{}{
578 579
 		"patient":                        patient,
579 580
 		"schedual":                       schedual,
@@ -992,7 +993,8 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
992 993
 	weightReduce, _ := c.GetFloat("weight_loss", 0)
993 994
 	temperature, _ := c.GetFloat("temperature", 0)
994 995
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
995
-	breathing_rate, _ := c.GetFloat("breathing_rate", 0)
996
+	//breathing_rate, _ := c.GetFloat("breathing_rate", 0)
997
+	breathing_rate := c.GetString("breathing_rate")
996 998
 	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
997 999
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
998 1000
 	actual_ultrafiltration, _ := c.GetFloat("actual_ultrafiltration", 0)
@@ -1065,6 +1067,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1065 1067
 	machine_run := c.GetString("machine_run")
1066 1068
 	after_urea := c.GetString("after_urea")
1067 1069
 	pip_coagulation := c.GetString("pip_coagulation")
1070
+	accumulated_blood_volume := c.GetString("accumulated_blood_volume")
1068 1071
 	if id <= 0 {
1069 1072
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1070 1073
 		return
@@ -1168,6 +1171,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1168 1171
 		MachineRun:                   machine_run,
1169 1172
 		AfterUrea:                    after_urea,
1170 1173
 		PipCoagulation:               pip_coagulation,
1174
+		AccumulatedBloodVolume:       accumulated_blood_volume,
1171 1175
 	}
1172 1176
 
1173 1177
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
@@ -1531,6 +1535,17 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1531 1535
 		}
1532 1536
 
1533 1537
 		prescription.Creater = adminUserInfo.AdminUser.Id
1538
+
1539
+		//针对河间咸得
1540
+		if adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10090 || adminUserInfo.Org.Id == 3877 {
1541
+
1542
+			if prescription.ModeId != 2 && prescription.ModeId != 5 && prescription.ModeId != 12 {
1543
+
1544
+				prescription.DisplaceLiquiPart = 0
1545
+				prescription.DisplaceLiquiValue = 0
1546
+			}
1547
+		}
1548
+
1534 1549
 		err := service.AddSigleRecord(&prescription)
1535 1550
 
1536 1551
 		//获取key,清空redis
@@ -1753,6 +1768,14 @@ func (c *DialysisAPIController) Finish() {
1753 1768
 		tempassessmentAfterDislysis.UserOrgId = adminUserInfo.Org.Id
1754 1769
 	}
1755 1770
 
1771
+	//长沙南雅
1772
+	if adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10340 {
1773
+		//获取最后一条透析处方数据
1774
+		prescription, _ := service.GetLastDialysisPrescriptionByPatientIdTwo(adminUserInfo.Org.Id, id, recordDate.Unix())
1775
+		evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.Org.Id, id, recordDate.Unix())
1776
+		tempassessmentAfterDislysis.WeightAfter = evaluation.WeightBefore - prescription.TargetUltrafiltration
1777
+	}
1778
+
1756 1779
 	if dialysisOrder.Stage == 1 {
1757 1780
 		temp_time := (float64(endDate.Unix()) - float64(dialysisOrder.StartTime)) / 3600
1758 1781
 		value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)
@@ -2351,6 +2374,7 @@ func (this *DialysisAPIController) StartDialysis() {
2351 2374
 		if errcode == nil {
2352 2375
 			record.SystolicBloodPressure = befor.SystolicBloodPressure
2353 2376
 			record.DiastolicBloodPressure = befor.DiastolicBloodPressure
2377
+
2354 2378
 			record.BreathingRate = befor.BreathingRate
2355 2379
 			record.PulseFrequency = befor.PulseFrequency
2356 2380
 			record.Temperature = befor.Temperature
@@ -2708,6 +2732,21 @@ func (c *DialysisAPIController) PostSolution() {
2708 2732
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
2709 2733
 		PreImpulse:                 impulse,
2710 2734
 	}
2735
+
2736
+	//针对河间咸的
2737
+	if adminUserInfo.Org.Id == 10090 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 3877 {
2738
+
2739
+		if solution.ModeId != 2 && solution.ModeId != 5 && solution.ModeId != 12 {
2740
+			solution.DisplaceLiquiPart = 0
2741
+			solution.DisplaceLiquiValue = 0
2742
+		}
2743
+
2744
+		if prescription.ModeId != 2 && prescription.ModeId != 5 && prescription.ModeId != 12 {
2745
+			prescription.DisplaceLiquiPart = 0
2746
+			prescription.DisplaceLiquiValue = 0
2747
+		}
2748
+	}
2749
+
2711 2750
 	service.SavePrescriptionAndCreateSolution(&solution, &prescription)
2712 2751
 
2713 2752
 	//获取key,清空redis
@@ -5911,3 +5950,79 @@ func (this *DialysisAPIController) GetRoleList() {
5911 5950
 	})
5912 5951
 	return
5913 5952
 }
5953
+
5954
+func (this *DialysisAPIController) SavePatientSign() {
5955
+
5956
+	adminUserInfo := this.GetMobileAdminUserInfo()
5957
+	patient_id, _ := this.GetInt64("patient_id")
5958
+	dialysis_date, _ := this.GetInt64("dialysis_date")
5959
+	orgid := adminUserInfo.Org.Id
5960
+
5961
+	var esdata models.DialysisOrder
5962
+	var err error
5963
+	if err = json.Unmarshal(this.Ctx.Input.RequestBody, &esdata); err != nil {
5964
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5965
+		return
5966
+	}
5967
+
5968
+	esdata.Hash = esdata.Hash
5969
+	esdata.Url = beego.AppConfig.String("qiniu_domain") + esdata.Hash
5970
+
5971
+	order := models.DialysisOrder{
5972
+		Hash: esdata.Hash,
5973
+		Url:  esdata.Url,
5974
+	}
5975
+	err = service.UpdatePatientSign(patient_id, dialysis_date, order, orgid)
5976
+	redis := service.RedisClient()
5977
+
5978
+	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dialysis_date, 10) + ":dialysis_order"
5979
+	redis.Set(key, "", time.Second)
5980
+	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(dialysis_date, 10) + ":dialysis_orders_list_all"
5981
+
5982
+	//清空key 值
5983
+	redis.Set(keyOne, "", time.Second)
5984
+	//scheduleDateStartOne := startDate.Format("2006-01-02")
5985
+	//keyTwo := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
5986
+
5987
+	//redis.Set(keyTwo, "", time.Second)
5988
+
5989
+	keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dialysis_date, 10) + ":doctor_advices"
5990
+	redis.Set(keyThree, "", time.Second)
5991
+	keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dialysis_date, 10) + ":monitor_records"
5992
+	redis.Set(keyFour, "", time.Second)
5993
+
5994
+	keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":patient_info"
5995
+	redis.Set(keyFive, "", time.Second)
5996
+
5997
+	keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dialysis_date, 10) + ":his_doctor_advice"
5998
+	redis.Set(keySix, "", time.Second)
5999
+
6000
+	keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":device_list_all"
6001
+	redis.Set(keySeven, "", time.Second)
6002
+	if err != nil {
6003
+		fmt.Println(err)
6004
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
6005
+		return
6006
+	}
6007
+	this.ServeSuccessJSON(map[string]interface{}{
6008
+		"electronic_signature": esdata,
6009
+	})
6010
+}
6011
+
6012
+func (this *DialysisAPIController) GetPatientSign() {
6013
+
6014
+	patient_id, _ := this.GetInt64("patient_id")
6015
+
6016
+	dialysis_date, _ := this.GetInt64("dialysis_date")
6017
+	adminUserInfo := this.GetMobileAdminUserInfo()
6018
+	orgId := adminUserInfo.Org.Id
6019
+	dialysisOrder, err := service.GetPatientSign(patient_id, dialysis_date, orgId)
6020
+	if err != nil {
6021
+		fmt.Println(err)
6022
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
6023
+		return
6024
+	}
6025
+	this.ServeSuccessJSON(map[string]interface{}{
6026
+		"dialysisOrder": dialysisOrder,
6027
+	})
6028
+}

+ 4 - 2
controllers/mobile_api_controllers/dialysis_api_controller_extend.go 查看文件

@@ -62,7 +62,8 @@ func (this *DialysisAPIController) AddMonitorRecord() {
62 62
 	fmt.Println(operateTime)
63 63
 
64 64
 	pulseFrequency, _ := this.GetFloat("pulse_frequency")
65
-	breathingRated, _ := this.GetFloat("breathing_rated")
65
+	//breathingRated, _ := this.GetFloat("breathing_rated")
66
+	breathingRated := this.GetString("breathing_rated")
66 67
 	systolicBP, _ := this.GetFloat("systolic_bp")
67 68
 	diastolicBP, _ := this.GetFloat("diastolic_bp")
68 69
 	BPType, _ := this.GetInt("bp_type")
@@ -239,7 +240,8 @@ func (this *DialysisAPIController) EditMonitorRecord() {
239 240
 		operateTime = 0
240 241
 	}
241 242
 	pulseFrequency, _ := this.GetFloat("pulse_frequency")
242
-	breathingRated, _ := this.GetFloat("breathing_rated")
243
+	//breathingRated, _ := this.GetFloat("breathing_rated")
244
+	breathingRated := this.GetString("breathing_rated")
243 245
 	systolicBP, _ := this.GetFloat("systolic_bp")
244 246
 	diastolicBP, _ := this.GetFloat("diastolic_bp")
245 247
 	BPType, _ := this.GetInt("bp_type")

+ 3 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go 查看文件

@@ -168,4 +168,7 @@ func MobileAPIControllersRegisterRouters() {
168 168
 
169 169
 	beego.Router("/m/api/getrolelist", &DialysisAPIController{}, "Get:GetRoleList")
170 170
 
171
+	beego.Router("/m/api/savepatientsign", &DialysisAPIController{}, "Post:SavePatientSign")
172
+	beego.Router("/m/api/getpatientsign", &DialysisAPIController{}, "Get:GetPatientSign")
173
+
171 174
 }

+ 7 - 2
controllers/mobile_api_controllers/patient_api_controller.go 查看文件

@@ -2457,7 +2457,7 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2457 2457
 	}
2458 2458
 
2459 2459
 	if dataBody["breathing_rate"] != nil && reflect.TypeOf(dataBody["breathing_rate"]).String() == "string" {
2460
-		breathingRate, _ := strconv.ParseFloat(dataBody["breathing_rate"].(string), 64)
2460
+		breathingRate := dataBody["breathing_rate"].(string)
2461 2461
 		evaluation.BreathingRate = breathingRate
2462 2462
 	}
2463 2463
 
@@ -2740,6 +2740,11 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2740 2740
 
2741 2741
 		evaluation.Suction = suction
2742 2742
 	}
2743
+	if dataBody["weight_befor_remake"] != nil && reflect.TypeOf(dataBody["weight_befor_remake"]).String() == "string" {
2744
+		weight_befor_remake := dataBody["weight_befor_remake"].(string)
2745
+
2746
+		evaluation.WeightBeforRemake = weight_befor_remake
2747
+	}
2743 2748
 	return
2744 2749
 }
2745 2750
 
@@ -3357,7 +3362,7 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
3357 3362
 
3358 3363
 	//临时医嘱
3359 3364
 	DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
3360
-
3365
+	fmt.Println("DoctorAdvice3223323323232323223323323223332232332wode", DoctorAdvice)
3361 3366
 	hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
3362 3367
 	config, err := service.GetHisDoctorConfig(adminUserInfo.Org.Id)
3363 3368
 

+ 24 - 4
controllers/patient_api_controller.go 查看文件

@@ -82,6 +82,15 @@ func PatientApiRegistRouters() {
82 82
 
83 83
 //GetPatientsList 取患者列表
84 84
 func (c *PatientApiController) GetPatientsList() {
85
+	var err error
86
+	defer func() {
87
+		if rec := recover(); rec != nil {
88
+			err = fmt.Errorf("程序异常:%v", rec)
89
+		}
90
+		if err != nil {
91
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
92
+		}
93
+	}()
85 94
 	page, _ := c.GetInt64("page", 1)
86 95
 	limit, _ := c.GetInt64("limit", 10)
87 96
 	schedulType, _ := c.GetInt64("schedul_type", 0)
@@ -132,7 +141,9 @@ func (c *PatientApiController) GetPatientsList() {
132 141
 		theEndtTIme = theTime.Unix()
133 142
 	}
134 143
 
135
-	patients, total, _ := service.GetPatientList(adminUserInfo.CurrentOrgId, keywords, page, limit, schedulType, bindingState, lapseto, source, theStartTIme, theEndtTIme, contagion, reimbursement_way, isscheduling, isprescription, isStartTime, isEndTime)
144
+	var patients []*models.Patients
145
+	var total int64
146
+	patients, total, err = service.GetPatientList(adminUserInfo.CurrentOrgId, keywords, page, limit, schedulType, bindingState, lapseto, source, theStartTIme, theEndtTIme, contagion, reimbursement_way, isscheduling, isprescription, isStartTime, isEndTime)
136 147
 
137 148
 	c.ServeSuccessJSON(map[string]interface{}{
138 149
 		"patients": patients,
@@ -1103,7 +1114,15 @@ func (c *PatientApiController) CreateDryWeights() {
1103 1114
 }
1104 1115
 
1105 1116
 func (c *PatientApiController) CreateGroupAdvice() {
1106
-
1117
+	var err error
1118
+	defer func() {
1119
+		if rec := recover(); rec != nil {
1120
+			err = fmt.Errorf("程序异常:%v", rec)
1121
+		}
1122
+		if err != nil {
1123
+			service.SaveErrs(c.GetAdminUserInfo().CurrentOrgId, c.Ctx.Input, err)
1124
+		}
1125
+	}()
1107 1126
 	patient, _ := c.GetInt64("id", 0)
1108 1127
 	groupNo, _ := c.GetInt64("groupno", 0)
1109 1128
 
@@ -1113,14 +1132,15 @@ func (c *PatientApiController) CreateGroupAdvice() {
1113 1132
 	}
1114 1133
 
1115 1134
 	adminUserInfo := c.GetAdminUserInfo()
1116
-	patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
1135
+	var patientInfo models.Patients
1136
+	patientInfo, err = service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
1117 1137
 	if patientInfo.ID == 0 {
1118 1138
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
1119 1139
 		return
1120 1140
 	}
1121 1141
 
1122 1142
 	dataBody := make(map[string]interface{}, 0)
1123
-	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1143
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1124 1144
 	if err != nil {
1125 1145
 		utils.ErrorLog(err.Error())
1126 1146
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)

+ 205 - 31
controllers/pharmacy_controller.go 查看文件

@@ -5,6 +5,7 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
+	"fmt"
8 9
 	"github.com/astaxie/beego"
9 10
 	"time"
10 11
 )
@@ -15,36 +16,42 @@ type PharmacyController struct {
15 16
 
16 17
 func PharmacyApiRegistRouters() {
17 18
 	beego.Router("/api/pharmacy/ceshili", &PharmacyController{}, "get:Tlili")
18
-	beego.Router("/api/pharmacy/todaynumber", &PharmacyController{}, "get:TodayNumber")                   //查询今天的待发药,已发药人数(
19
-	beego.Router("/api/pharmacy/waitingdrug", &PharmacyController{}, "get:WaitingDrug")                   //获取当天待发药的所有患者(
20
-	beego.Router("/api/pharmacy/issueddrugs", &PharmacyController{}, "get:IssuedDrug")                    //获取当天已发药的所有患者(
21
-	beego.Router("/api/pharmacy/getpharmacycontent", &PharmacyController{}, "get:GetPharmacyContent")     //获取当天该患者的所有信息(
22
-	beego.Router("/api/pharmacy/dispensingmedicine", &PharmacyController{}, "get:DispensingMedicine")     //患者发药按钮点击(
23
-	beego.Router("/api/pharmacy/drugwithdrawal", &PharmacyController{}, "get:DrugWithdrawal")             //退药按钮点击
24
-	beego.Router("/api/pharmacy/dispensingdetails", &PharmacyController{}, "get:DispensingDetails")       //获取发药明细的患者列表(
25
-	beego.Router("/api/pharmacy/prescriptiondetails", &PharmacyController{}, "get:PrescriptionDetails")   //发药明细-详情(
26
-	beego.Router("/api/pharmacy/dispensemedicine", &PharmacyController{}, "get:DispenseMedicine")         //获取当天已发药的药品(
27
-	beego.Router("/api/pharmacy/waitingmedicine", &PharmacyController{}, "get:WaitingMedicine")           //获取当天待发药的药品(
28
-	beego.Router("/api/pharmacy/getpatientswithdrugs", &PharmacyController{}, "get:GetPatientsWithDrugs") //获取当天该药品的所有患者(
29
-	beego.Router("/api/pharmacy/medicinedeparture", &PharmacyController{}, "get:MedicineDeparture")       //药品发药按钮点击(
30
-	beego.Router("/api/pharmacy/getcurrentname", &PharmacyController{}, "get:GetCurrentName")             //获取当前登录账号的名字(
19
+	beego.Router("/api/pharmacy/todaynumber", &PharmacyController{}, "get:TodayNumber")                     //查询今天的待发药,已发药人数(
20
+	beego.Router("/api/pharmacy/waitingdrug", &PharmacyController{}, "get:WaitingDrug")                     //获取当天待发药的所有患者(
21
+	beego.Router("/api/pharmacy/issueddrugs", &PharmacyController{}, "get:IssuedDrug")                      //获取当天已发药的所有患者(
22
+	beego.Router("/api/pharmacy/getpharmacycontent", &PharmacyController{}, "get:GetPharmacyContent")       //获取当天该患者的所有信息(
23
+	beego.Router("/api/pharmacy/dispensingmedicine", &PharmacyController{}, "get:DispensingMedicine")       //患者发药按钮点击(
24
+	beego.Router("/api/pharmacy/drugwithdrawal", &PharmacyController{}, "get:DrugWithdrawal")               //退药按钮点击
25
+	beego.Router("/api/pharmacy/dispensingdetails", &PharmacyController{}, "get:DispensingDetails")         //获取发药明细的患者列表(
26
+	beego.Router("/api/pharmacy/prescriptiondetails", &PharmacyController{}, "get:PrescriptionDetails")     //发药明细-详情(
27
+	beego.Router("/api/pharmacy/dispensemedicine", &PharmacyController{}, "get:DispenseMedicine")           //获取当天已发药的药品(
28
+	beego.Router("/api/pharmacy/waitingmedicine", &PharmacyController{}, "get:WaitingMedicine")             //获取当天待发药的药品(
29
+	beego.Router("/api/pharmacy/getpatientswithdrugs", &PharmacyController{}, "get:GetPatientsWithDrugs")   //获取当天该药品的所有患者(
30
+	beego.Router("/api/pharmacy/medicinedeparture", &PharmacyController{}, "get:MedicineDeparture")         //药品发药按钮点击(
31
+	beego.Router("/api/pharmacy/getcurrentname", &PharmacyController{}, "get:GetCurrentName")               //获取当前登录账号的名字(
32
+	beego.Router("/api/pharmacy/getpartitionlist", &PharmacyController{}, "get:GetPartitionList")           //获取当前机构的分区列表
33
+	beego.Router("/api/pharmacy/routeofadministration", &PharmacyController{}, "get:RouteOfAdministration") //获取当前机构的给药途径
31 34
 }
35
+
36
+//测试
32 37
 func (this *PharmacyController) Tlili() {
33
-	times := this.GetString("time", "")
34
-	timeLayout := "2006-01-02"
35
-	loc, _ := time.LoadLocation("Local")
36
-	var stime, etime int64
37
-	if times == "" {
38
-		stime, etime = service.GetNowTime()
39
-	} else {
40
-		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
41
-		stime = stmp.Unix()
42
-		etime = stime + 86399
38
+	var err error
39
+	defer func() {
40
+		if rec := recover(); rec != nil {
41
+			err = fmt.Errorf("程序异常:%v", rec)
42
+		}
43
+		if err != nil {
44
+			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
45
+		}
46
+	}()
47
+	var list2 []*models.ReplacementDrugs
48
+	list2, err = service.ReplacementDrugs(9675, false)
49
+	if err != nil {
50
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
51
+		return
43 52
 	}
44
-	orgid := this.GetAdminUserInfo().CurrentOrgId
45
-	service.InitDrugidIsNil(orgid, stime, etime)
46 53
 	this.ServeSuccessJSON(map[string]interface{}{
47
-		"list": "err",
54
+		"list": list2,
48 55
 	})
49 56
 	return
50 57
 }
@@ -60,6 +67,9 @@ func (this *PharmacyController) GetCurrentName() {
60 67
 func (this *PharmacyController) TodayNumber() {
61 68
 	var err error
62 69
 	defer func() {
70
+		if rec := recover(); rec != nil {
71
+			err = fmt.Errorf("程序异常:%v", rec)
72
+		}
63 73
 		if err != nil {
64 74
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
65 75
 		}
@@ -68,6 +78,16 @@ func (this *PharmacyController) TodayNumber() {
68 78
 	times := this.GetString("time", "")
69 79
 	timeLayout := "2006-01-02"
70 80
 	loc, _ := time.LoadLocation("Local")
81
+	//shift, err := this.GetInt64("shift", 0) //班次
82
+	//if err != nil {
83
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
84
+	//	return
85
+	//}
86
+	//partition, err := this.GetInt64("partition", 0) //分区
87
+	//if err != nil {
88
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
89
+	//	return
90
+	//}
71 91
 	var stime, etime int64
72 92
 	if times == "" {
73 93
 		stime, etime = service.GetNowTime()
@@ -100,6 +120,9 @@ func (this *PharmacyController) TodayNumber() {
100 120
 func (this *PharmacyController) IssuedDrug() {
101 121
 	var err error
102 122
 	defer func() {
123
+		if rec := recover(); rec != nil {
124
+			err = fmt.Errorf("程序异常:%v", rec)
125
+		}
103 126
 		if err != nil {
104 127
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
105 128
 		}
@@ -107,6 +130,16 @@ func (this *PharmacyController) IssuedDrug() {
107 130
 	keyword := this.GetString("keyword", "")
108 131
 	times := this.GetString("time", "")
109 132
 	orgid := this.GetAdminUserInfo().CurrentOrgId
133
+	shift, err := this.GetInt64("shift", 0) //班次
134
+	if err != nil {
135
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
136
+		return
137
+	}
138
+	partition, err := this.GetInt64("partition", 0) //分区
139
+	if err != nil {
140
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
141
+		return
142
+	}
110 143
 	timeLayout := "2006-01-02"
111 144
 	loc, _ := time.LoadLocation("Local")
112 145
 	var stime, etime int64
@@ -125,20 +158,39 @@ func (this *PharmacyController) IssuedDrug() {
125 158
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
126 159
 		return
127 160
 	}
161
+	listt, err := service.PartitionAndLayout(stime, etime, orgid, shift, partition, flist)
162
+	if err != nil {
163
+		utils.ErrorLog(err.Error())
164
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
165
+		return
166
+	}
128 167
 	this.ServeSuccessJSON(map[string]interface{}{
129
-		"list": flist,
168
+		"list": listt,
130 169
 	})
131 170
 	return
132 171
 }
133 172
 func (this *PharmacyController) WaitingDrug() {
134 173
 	var err error
135 174
 	defer func() {
175
+		if rec := recover(); rec != nil {
176
+			err = fmt.Errorf("程序异常:%v", rec)
177
+		}
136 178
 		if err != nil {
137 179
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
138 180
 		}
139 181
 	}()
140 182
 	keyword := this.GetString("keyword", "")
141 183
 	times := this.GetString("time", "")
184
+	shift, err := this.GetInt64("shift", 0) //班次
185
+	if err != nil {
186
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
187
+		return
188
+	}
189
+	partition, err := this.GetInt64("partition", 0) //分区
190
+	if err != nil {
191
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
192
+		return
193
+	}
142 194
 	orgid := this.GetAdminUserInfo().CurrentOrgId
143 195
 	timeLayout := "2006-01-02"
144 196
 	loc, _ := time.LoadLocation("Local")
@@ -158,8 +210,14 @@ func (this *PharmacyController) WaitingDrug() {
158 210
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
159 211
 		return
160 212
 	}
213
+	listt, err := service.PartitionAndLayout(stime, etime, orgid, shift, partition, flist)
214
+	if err != nil {
215
+		utils.ErrorLog(err.Error())
216
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
217
+		return
218
+	}
161 219
 	this.ServeSuccessJSON(map[string]interface{}{
162
-		"list": flist,
220
+		"list": listt,
163 221
 	})
164 222
 	return
165 223
 }
@@ -168,6 +226,9 @@ func (this *PharmacyController) WaitingDrug() {
168 226
 func (this *PharmacyController) GetPharmacyContent() {
169 227
 	var err error
170 228
 	defer func() {
229
+		if rec := recover(); rec != nil {
230
+			err = fmt.Errorf("程序异常:%v", rec)
231
+		}
171 232
 		if err != nil {
172 233
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
173 234
 		}
@@ -207,6 +268,9 @@ func (this *PharmacyController) GetPharmacyContent() {
207 268
 func (this *PharmacyController) DispensingMedicine() {
208 269
 	var err error
209 270
 	defer func() {
271
+		if rec := recover(); rec != nil {
272
+			err = fmt.Errorf("程序异常:%v", rec)
273
+		}
210 274
 		if err != nil {
211 275
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
212 276
 		}
@@ -241,6 +305,9 @@ func (this *PharmacyController) DispensingMedicine() {
241 305
 func (this *PharmacyController) DrugWithdrawal() {
242 306
 	var err error
243 307
 	defer func() {
308
+		if rec := recover(); rec != nil {
309
+			err = fmt.Errorf("程序异常:%v", rec)
310
+		}
244 311
 		if err != nil {
245 312
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
246 313
 		}
@@ -276,6 +343,9 @@ func (this *PharmacyController) DrugWithdrawal() {
276 343
 func (this *PharmacyController) DispensingDetails() {
277 344
 	var err error
278 345
 	defer func() {
346
+		if rec := recover(); rec != nil {
347
+			err = fmt.Errorf("程序异常:%v", rec)
348
+		}
279 349
 		if err != nil {
280 350
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
281 351
 		}
@@ -321,6 +391,9 @@ func (this *PharmacyController) DispensingDetails() {
321 391
 func (this *PharmacyController) PrescriptionDetails() {
322 392
 	var err error
323 393
 	defer func() {
394
+		if rec := recover(); rec != nil {
395
+			err = fmt.Errorf("程序异常:%v", rec)
396
+		}
324 397
 		if err != nil {
325 398
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
326 399
 		}
@@ -351,6 +424,9 @@ func (this *PharmacyController) PrescriptionDetails() {
351 424
 func (this *PharmacyController) DispenseMedicine() {
352 425
 	var err error
353 426
 	defer func() {
427
+		if rec := recover(); rec != nil {
428
+			err = fmt.Errorf("程序异常:%v", rec)
429
+		}
354 430
 		if err != nil {
355 431
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
356 432
 		}
@@ -360,6 +436,7 @@ func (this *PharmacyController) DispenseMedicine() {
360 436
 	orgid := this.GetAdminUserInfo().CurrentOrgId
361 437
 	timeLayout := "2006-01-02"
362 438
 	loc, _ := time.LoadLocation("Local")
439
+	deliveryway := this.GetString("deliveryway", "")
363 440
 	var stime, etime int64
364 441
 	if times == "" {
365 442
 		stime, etime = service.GetNowTime()
@@ -376,8 +453,14 @@ func (this *PharmacyController) DispenseMedicine() {
376 453
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
377 454
 		return
378 455
 	}
456
+	llist, err := service.Administration(deliveryway, orgid, flist)
457
+	if err != nil {
458
+		utils.ErrorLog(err.Error())
459
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
460
+		return
461
+	}
379 462
 	this.ServeSuccessJSON(map[string]interface{}{
380
-		"list": flist,
463
+		"list": llist,
381 464
 	})
382 465
 	return
383 466
 }
@@ -386,6 +469,9 @@ func (this *PharmacyController) DispenseMedicine() {
386 469
 func (this *PharmacyController) WaitingMedicine() {
387 470
 	var err error
388 471
 	defer func() {
472
+		if rec := recover(); rec != nil {
473
+			err = fmt.Errorf("程序异常:%v", rec)
474
+		}
389 475
 		if err != nil {
390 476
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
391 477
 		}
@@ -395,6 +481,7 @@ func (this *PharmacyController) WaitingMedicine() {
395 481
 	orgid := this.GetAdminUserInfo().CurrentOrgId
396 482
 	timeLayout := "2006-01-02"
397 483
 	loc, _ := time.LoadLocation("Local")
484
+	deliveryway := this.GetString("deliveryway", "")
398 485
 	var stime, etime int64
399 486
 	if times == "" {
400 487
 		stime, etime = service.GetNowTime()
@@ -411,8 +498,14 @@ func (this *PharmacyController) WaitingMedicine() {
411 498
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
412 499
 		return
413 500
 	}
501
+	llist, err := service.Administration(deliveryway, orgid, flist)
502
+	if err != nil {
503
+		utils.ErrorLog(err.Error())
504
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
505
+		return
506
+	}
414 507
 	this.ServeSuccessJSON(map[string]interface{}{
415
-		"list": flist,
508
+		"list": llist,
416 509
 	})
417 510
 	return
418 511
 }
@@ -421,6 +514,9 @@ func (this *PharmacyController) WaitingMedicine() {
421 514
 func (this *PharmacyController) GetPatientsWithDrugs() {
422 515
 	var err error
423 516
 	defer func() {
517
+		if rec := recover(); rec != nil {
518
+			err = fmt.Errorf("程序异常:%v", rec)
519
+		}
424 520
 		if err != nil {
425 521
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
426 522
 		}
@@ -429,6 +525,21 @@ func (this *PharmacyController) GetPatientsWithDrugs() {
429 525
 	is_medicine, _ := this.GetInt64("is_medicine", 0) //0:待发药,1:已发药
430 526
 	times := this.GetString("time", "")
431 527
 	orgid := this.GetAdminUserInfo().CurrentOrgId
528
+	deliveryway := this.GetString("deliveryway", "")
529
+	if deliveryway == "" {
530
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
531
+		return
532
+	}
533
+	shift, err := this.GetInt64("shift", 0) //班次
534
+	if err != nil {
535
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
536
+		return
537
+	}
538
+	partition, err := this.GetInt64("partition", 0) //分区
539
+	if err != nil {
540
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
541
+		return
542
+	}
432 543
 	timeLayout := "2006-01-02"
433 544
 	loc, _ := time.LoadLocation("Local")
434 545
 	var stime, etime int64
@@ -446,8 +557,22 @@ func (this *PharmacyController) GetPatientsWithDrugs() {
446 557
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
447 558
 		return
448 559
 	}
560
+	listll, err := service.PartitionAndLayoutDrug(deliveryway, stime, etime, orgid, shift, partition, list)
561
+	if err != nil {
562
+		utils.ErrorLog(err.Error())
563
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
564
+		return
565
+	}
566
+	total, err := service.CalculateTheTotalAmount(listll, drug_id)
567
+	fmt.Println("total2322332232323232332322wo", total)
568
+	if err != nil {
569
+		utils.ErrorLog(err.Error())
570
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
571
+		return
572
+	}
449 573
 	this.ServeSuccessJSON(map[string]interface{}{
450
-		"list": list,
574
+		"list":  listll,
575
+		"total": total,
451 576
 	})
452 577
 	return
453 578
 }
@@ -456,6 +581,9 @@ func (this *PharmacyController) GetPatientsWithDrugs() {
456 581
 func (this *PharmacyController) MedicineDeparture() {
457 582
 	var err error
458 583
 	defer func() {
584
+		if rec := recover(); rec != nil {
585
+			err = fmt.Errorf("程序异常:%v", rec)
586
+		}
459 587
 		if err != nil {
460 588
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
461 589
 		}
@@ -477,3 +605,49 @@ func (this *PharmacyController) MedicineDeparture() {
477 605
 	})
478 606
 	return
479 607
 }
608
+
609
+func (this *PharmacyController) GetPartitionList() {
610
+	var err error
611
+	defer func() {
612
+		if rec := recover(); rec != nil {
613
+			err = fmt.Errorf("程序异常:%v", rec)
614
+		}
615
+		if err != nil {
616
+			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
617
+		}
618
+	}()
619
+	orgid := this.GetAdminUserInfo().CurrentOrgId
620
+	tmp := []*models.DeviceZone{{ID: 0, Name: "全部分区"}}
621
+	list, err := service.GetAllValidDeviceZones02(orgid)
622
+	if err != nil {
623
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
624
+		return
625
+	}
626
+	this.ServeSuccessJSON(map[string]interface{}{
627
+		"list": append(tmp, list...),
628
+	})
629
+	return
630
+}
631
+
632
+func (this *PharmacyController) RouteOfAdministration() {
633
+	var err error
634
+	defer func() {
635
+		if rec := recover(); rec != nil {
636
+			err = fmt.Errorf("程序异常:%v", rec)
637
+		}
638
+		if err != nil {
639
+			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
640
+		}
641
+	}()
642
+	orgid := this.GetAdminUserInfo().CurrentOrgId
643
+	tmp := []*models.DrugwayDic{{ID: 0, Name: "全部"}}
644
+	list, _, err := service.GetDrugWayDics(orgid)
645
+	if err != nil {
646
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
647
+		return
648
+	}
649
+	this.ServeSuccessJSON(map[string]interface{}{
650
+		"list": append(tmp, list...),
651
+	})
652
+	return
653
+}

+ 4 - 2
controllers/sign_weigh_api_controller.go 查看文件

@@ -356,7 +356,8 @@ func (c *SignWeighAPIController) SaveData() {
356 356
 	dry_weight, _ := c.GetFloat("dry_weight", 0)
357 357
 	temperature, _ := c.GetFloat("temperature", 0)
358 358
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
359
-	breathing_rate, _ := c.GetFloat("breathing_rate", 0)
359
+	//breathing_rate, _ := c.GetFloat("breathing_rate", 0)
360
+	breathing_rate := c.GetString("breathing_rate")
360 361
 	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
361 362
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
362 363
 
@@ -383,7 +384,8 @@ func (c *SignWeighAPIController) EditData() {
383 384
 	dry_weight, _ := c.GetFloat("dry_weight", 0)
384 385
 	temperature, _ := c.GetFloat("temperature", 0)
385 386
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
386
-	breathing_rate, _ := c.GetFloat("breathing_rate", 0)
387
+	//breathing_rate, _ := c.GetFloat("breathing_rate", 0)
388
+	breathing_rate := c.GetString("breathing_rate")
387 389
 	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
388 390
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
389 391
 

+ 0 - 1
controllers/stock_in_api_controller.go 查看文件

@@ -7021,7 +7021,6 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7021 7021
 	//更改审核状态
7022 7022
 	err := service.UpdateCheckWarehouseInfo(warehousing_info_id)
7023 7023
 	if err == nil {
7024
-
7025 7024
 		list, _ := service.GetWarehouseInfoList(warehousing_info_id, orgId)
7026 7025
 		Creator := this.GetAdminUserInfo().AdminUser.Id
7027 7026
 		for _, item := range list {

+ 3 - 0
controllers/supply_order_api_contorller.go 查看文件

@@ -125,6 +125,9 @@ func CheckParams(this *SupplyOrderApiController, m *map[string][]string) (map[st
125 125
 func (this *SupplyOrderApiController) GetSupplyList() {
126 126
 	var err error
127 127
 	defer func() {
128
+		if rec := recover(); rec != nil {
129
+			err = fmt.Errorf("程序异常:%v", rec)
130
+		}
128 131
 		if err != nil {
129 132
 			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
130 133
 		}

+ 4 - 0
enums/error_code.go 查看文件

@@ -260,6 +260,8 @@ const ( // ErrorCode
260 260
 
261 261
 	ErrorCodeDeleteMedicineWrong   = 3900003
262 262
 	ErrorCodeDeletePChargeWrongTwo = 3900004
263
+
264
+	ErrorCodeHisPatientNoRegException = 4000000
263 265
 )
264 266
 
265 267
 var ErrCodeMsgs = map[int]string{
@@ -508,6 +510,8 @@ var ErrCodeMsgs = map[int]string{
508 510
 	ErrorCodeDeletePChargeWrong:    "处方中包含收费处方或已经上传的处方,无法删除",
509 511
 	ErrorCodeDeleteMedicineWrong:   "该药品已经发药,无法删除",
510 512
 	ErrorCodeDeletePChargeWrongTwo: "该医嘱所属处方已经收费或已经上传的处方,无法删除",
513
+
514
+	ErrorCodeHisPatientNoRegException: "该患者尚未挂号,请先挂号",
511 515
 }
512 516
 
513 517
 type SGJError struct {

+ 1 - 1
models/common_models.go 查看文件

@@ -511,7 +511,7 @@ type XTMonitoringRecord struct {
511 511
 	OperateTime               int64   `gorm:"column:operate_time" json:"operate_time"`
512 512
 	MonitoringTime            string  `gorm:"column:monitoring_time" json:"monitoring_time"`
513 513
 	PulseFrequency            float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
514
-	BreathingRate             float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
514
+	BreathingRate             string  `gorm:"column:breathing_rate" json:"breathing_rate"`
515 515
 	SystolicBloodPressure     float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
516 516
 	DiastolicBloodPressure    float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
517 517
 	BloodPressureType         int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`

+ 1 - 0
models/data_models.go 查看文件

@@ -152,6 +152,7 @@ type FiledConfig struct {
152 152
 	CreateTime  int64  `gorm:"column:create_time" json:"create_time"`
153 153
 	UpdateTime  int64  `gorm:"column:update_time" json:"update_time"`
154 154
 	SysModule   int64  `gorm:"column:sys_module" json:"sys_module" form:"sys_module"`
155
+	IsWrite     int64  `gorm:"column:is_write" json:"is_write" form:"is_write"`
155 156
 }
156 157
 
157 158
 func (FiledConfig) TableName() string {

+ 2 - 2
models/device_models.go 查看文件

@@ -107,9 +107,9 @@ type DeviceZone struct {
107 107
 	OrgID      int64  `gorm:"column:org_id" json:"-"`
108 108
 	Name       string `json:"name"`
109 109
 	Type       int    `json:"type"`
110
-	Status     int8   `json:"-"`
111 110
 	CreateTime int64  `gorm:"column:ctime" json:"-"`
112 111
 	ModifyTime int64  `gorm:"column:mtime" json:"-"`
112
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
113 113
 }
114 114
 
115 115
 func (DeviceZone) TableName() string {
@@ -810,7 +810,7 @@ type XtAssessmentAfterDislysis struct {
810 810
 	DialysisOrderId                 int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
811 811
 	Temperature                     float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
812 812
 	PulseFrequency                  float64 `gorm:"column:pulse_frequency" json:"pulse_frequency" form:"pulse_frequency"`
813
-	BreathingRate                   float64 `gorm:"column:breathing_rate" json:"breathing_rate" form:"breathing_rate"`
813
+	BreathingRate                   string  `gorm:"column:breathing_rate" json:"breathing_rate" form:"breathing_rate"`
814 814
 	SystolicBloodPressure           float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure" form:"systolic_blood_pressure"`
815 815
 	DiastolicBloodPressure          float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure" form:"diastolic_blood_pressure"`
816 816
 	BloodPressureType               int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type" form:"blood_pressure_type"`

+ 8 - 3
models/dialysis.go 查看文件

@@ -242,7 +242,7 @@ type PredialysisEvaluation struct {
242 242
 	DialysisOrderId             int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
243 243
 	Temperature                 float64 `gorm:"column:temperature" json:"temperature"`
244 244
 	PulseFrequency              float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
245
-	BreathingRate               float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
245
+	BreathingRate               string  `gorm:"column:breathing_rate" json:"breathing_rate"`
246 246
 	SystolicBloodPressure       float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
247 247
 	DiastolicBloodPressure      float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
248 248
 	BloodPressureType           int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
@@ -320,6 +320,7 @@ type PredialysisEvaluation struct {
320 320
 	BloodPressureDuringDialysis    string  `gorm:"column:blood_pressure_during_dialysis" json:"blood_pressure_during_dialysis" form:"blood_pressure_during_dialysis"`
321 321
 	UreaBefor                      string  `gorm:"column:urea_befor" json:"urea_befor" form:"urea_befor"`
322 322
 	Suction                        string  `gorm:"column:suction" json:"suction" form:"suction"`
323
+	WeightBeforRemake              string  `gorm:"column:weight_befor_remake" json:"weight_befor_remake" form:"weight_befor_remake"`
323 324
 }
324 325
 
325 326
 func (PredialysisEvaluation) TableName() string {
@@ -556,7 +557,7 @@ type AssessmentAfterDislysis struct {
556 557
 	DialysisOrderId        int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
557 558
 	Temperature            float64 `gorm:"column:temperature" json:"temperature"`
558 559
 	PulseFrequency         float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
559
-	BreathingRate          float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
560
+	BreathingRate          string  `gorm:"column:breathing_rate" json:"breathing_rate"`
560 561
 	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
561 562
 	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
562 563
 	BloodPressureType      int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
@@ -640,6 +641,7 @@ type AssessmentAfterDislysis struct {
640 641
 	MachineRun                      string  `gorm:"column:machine_run" json:"machine_run" form:"machine_run"`
641 642
 	AfterUrea                       string  `gorm:"column:after_urea" json:"after_urea" form:"after_urea"`
642 643
 	PipCoagulation                  string  `gorm:"column:pip_coagulation" json:"pip_coagulation" form:"pip_coagulation"`
644
+	AccumulatedBloodVolume          string  `gorm:"column:accumulated_blood_volume" json:"accumulated_blood_volume" form:"accumulated_blood_volume"`
643 645
 }
644 646
 
645 647
 func (AssessmentAfterDislysis) TableName() string {
@@ -704,7 +706,7 @@ type MonitoringRecord struct {
704 706
 	OperateTime                 int64   `gorm:"column:operate_time" json:"operate_time"`
705 707
 	MonitoringTime              string  `gorm:"column:monitoring_time" json:"monitoring_time"`
706 708
 	PulseFrequency              float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
707
-	BreathingRate               float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
709
+	BreathingRate               string  `gorm:"column:breathing_rate" json:"breathing_rate"`
708 710
 	SystolicBloodPressure       float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
709 711
 	DiastolicBloodPressure      float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
710 712
 	BloodPressureType           int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
@@ -830,6 +832,8 @@ type DialysisOrder struct {
830 832
 	BloodAccessInternalFistula string        `gorm:"column:blood_access_internal_fistula" json:"blood_access_internal_fistula" form:"blood_access_internal_fistula"`
831 833
 	Catheter                   string        `gorm:"column:catheter" json:"catheter" form:"catheter"`
832 834
 	Cruor                      string        `gorm:"column:cruor" json:"cruor" form:"cruor"`
835
+	Url                        string        `gorm:"column:url" json:"url" form:"url"`
836
+	Hash                       string        `gorm:"column:hash" json:"hash" form:"hash"`
833 837
 }
834 838
 
835 839
 func (DialysisOrder) TableName() string {
@@ -1179,6 +1183,7 @@ type HisDoctorAdvice struct {
1179 1183
 	Way                   int64              `gorm:"column:way" json:"way" form:"way"`
1180 1184
 	DrugId                int64              `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1181 1185
 	DrugNameId            int64              `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
1186
+	ExecutionFrequencyId  int64              `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
1182 1187
 }
1183 1188
 
1184 1189
 func (HisDoctorAdvice) TableName() string {

+ 1 - 0
models/drug_pharmacy_management_models.go 查看文件

@@ -195,6 +195,7 @@ type PharmacyHisDoctorAdviceInfo struct {
195 195
 	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
196 196
 	Mtime                 int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
197 197
 	AdviceId              int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
198
+	ExecutionFrequencyId  int64   `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
198 199
 }
199 200
 
200 201
 func (PharmacyHisDoctorAdviceInfo) TableName() string {

+ 14 - 12
models/his_charge_models.go 查看文件

@@ -1,18 +1,19 @@
1 1
 package models
2 2
 
3 3
 type HisChargePrescriptionProject struct {
4
-	ID                int64             `gorm:"column:id" json:"id" form:"id"`
5
-	ProjectId         int64             `gorm:"column:project_id" json:"project_id" form:"project_id"`
6
-	UserOrgId         int64             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
7
-	Status            int64             `gorm:"column:status" json:"status" form:"status"`
8
-	PatientId         int64             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
9
-	RecordDate        int64             `gorm:"column:record_date" json:"record_date" form:"record_date"`
10
-	Count             string            `gorm:"column:count" json:"count" form:"count"`
11
-	Type              int64             `gorm:"column:type" json:"type" form:"type"`
12
-	Unit              string            `gorm:"column:unit" json:"unit" form:"unit"`
13
-	Remark            string            `gorm:"column:remark" json:"remark" form:"remark"`
14
-	HisChargeProject  HisChargeProject  `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
15
-	HisChargeGoodInfo HisChargeGoodInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
4
+	ID                   int64             `gorm:"column:id" json:"id" form:"id"`
5
+	ProjectId            int64             `gorm:"column:project_id" json:"project_id" form:"project_id"`
6
+	UserOrgId            int64             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
7
+	Status               int64             `gorm:"column:status" json:"status" form:"status"`
8
+	PatientId            int64             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
9
+	RecordDate           int64             `gorm:"column:record_date" json:"record_date" form:"record_date"`
10
+	Count                string            `gorm:"column:count" json:"count" form:"count"`
11
+	Type                 int64             `gorm:"column:type" json:"type" form:"type"`
12
+	Unit                 string            `gorm:"column:unit" json:"unit" form:"unit"`
13
+	Remark               string            `gorm:"column:remark" json:"remark" form:"remark"`
14
+	HisChargeProject     HisChargeProject  `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
15
+	HisChargeGoodInfo    HisChargeGoodInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
16
+	ExecutionFrequencyId int64             `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
16 17
 }
17 18
 
18 19
 func (HisChargePrescriptionProject) TableName() string {
@@ -31,6 +32,7 @@ type HisChargeDoctorAdviceInfo struct {
31 32
 	AdviceDate            int64  `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
32 33
 	Drug                  Drug   `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
33 34
 	IsMedicine            int64  `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
35
+	ExecutionFrequencyId  int64  `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
34 36
 }
35 37
 
36 38
 func (HisChargeDoctorAdviceInfo) TableName() string {

+ 88 - 32
models/his_models.go 查看文件

@@ -256,6 +256,7 @@ type HisDoctorAdviceInfo struct {
256 256
 	LmtUsedFlag           int64                  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
257 257
 	HisOrderInfo          HisOrderInfo           `gorm:"ForeignKey:AdviceId;AssociationForeignKey:ID" json:"order_info"`
258 258
 	IsMedicine            int64                  `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
259
+	ExecutionFrequencyId  int64                  `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
259 260
 }
260 261
 
261 262
 func (HisDoctorAdviceInfo) TableName() string {
@@ -803,10 +804,11 @@ type HisPrintPrescriptionProject struct {
803 804
 
804 805
 	XtHisProjectTeam XtHisProjectTeam `gorm:"ForeignKey:TeamId;AssociationForeignKey:ID" json:"team"`
805 806
 
806
-	FrequencyType int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
807
-	DayCount      int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
808
-	WeekDay       string `gorm:"column:week_day" json:"week_day" form:"week_day"`
809
-	IsCheckTeam   int64  `gorm:"-" json:"is_check_team" form:"is_check_team"`
807
+	FrequencyType        int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
808
+	DayCount             int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
809
+	WeekDay              string `gorm:"column:week_day" json:"week_day" form:"week_day"`
810
+	IsCheckTeam          int64  `gorm:"-" json:"is_check_team" form:"is_check_team"`
811
+	ExecutionFrequencyId int64  `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
810 812
 }
811 813
 
812 814
 func (HisPrintPrescriptionProject) TableName() string {
@@ -851,11 +853,12 @@ type HisPrescriptionProject struct {
851 853
 
852 854
 	XtHisProjectTeam XtHisProjectTeam `gorm:"ForeignKey:TeamId;AssociationForeignKey:ID" json:"team"`
853 855
 
854
-	FrequencyType int64        `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
855
-	DayCount      int64        `gorm:"column:day_count" json:"day_count" form:"day_count"`
856
-	WeekDay       string       `gorm:"column:week_day" json:"week_day" form:"week_day"`
857
-	IsCheckTeam   int64        `gorm:"-" json:"is_check_team" form:"is_check_team"`
858
-	HisOrderInfo  HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
856
+	FrequencyType        int64        `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
857
+	DayCount             int64        `gorm:"column:day_count" json:"day_count" form:"day_count"`
858
+	WeekDay              string       `gorm:"column:week_day" json:"week_day" form:"week_day"`
859
+	IsCheckTeam          int64        `gorm:"-" json:"is_check_team" form:"is_check_team"`
860
+	HisOrderInfo         HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
861
+	ExecutionFrequencyId int64        `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
859 862
 }
860 863
 
861 864
 func (HisPrescriptionProject) TableName() string {
@@ -1932,11 +1935,12 @@ type NewCustomHisPrescriptionProject struct {
1932 1935
 
1933 1936
 	XtHisProjectTeam XtHisProjectTeam `gorm:"ForeignKey:TeamId;AssociationForeignKey:ID" json:"team"`
1934 1937
 
1935
-	FrequencyType int64        `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1936
-	DayCount      int64        `gorm:"column:day_count" json:"day_count" form:"day_count"`
1937
-	WeekDay       string       `gorm:"column:week_day" json:"week_day" form:"week_day"`
1938
-	IsCheckTeam   int64        `gorm:"-" json:"is_check_team" form:"is_check_team"`
1939
-	HisOrderInfo  HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
1938
+	FrequencyType        int64        `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1939
+	DayCount             int64        `gorm:"column:day_count" json:"day_count" form:"day_count"`
1940
+	WeekDay              string       `gorm:"column:week_day" json:"week_day" form:"week_day"`
1941
+	IsCheckTeam          int64        `gorm:"-" json:"is_check_team" form:"is_check_team"`
1942
+	HisOrderInfo         HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
1943
+	ExecutionFrequencyId int64        `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
1940 1944
 }
1941 1945
 
1942 1946
 func (NewCustomHisPrescriptionProject) TableName() string {
@@ -1964,24 +1968,25 @@ func (HisYidiClearRecord) TableName() string {
1964 1968
 }
1965 1969
 
1966 1970
 type HisPrescriptionProjectTwo struct {
1967
-	ID             int64   `gorm:"column:id" json:"id" form:"id"`
1968
-	ProjectId      int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
1969
-	Price          float64 `gorm:"column:price" json:"price" form:"price"`
1970
-	UserOrgId      int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1971
-	Status         int64   `gorm:"column:status" json:"status" form:"status"`
1972
-	PatientId      int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1973
-	RecordDate     int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
1974
-	PrescriptionId int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1975
-	Count          string  `gorm:"column:count" json:"count" form:"count"`
1976
-	FeedetlSn      string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1977
-	Type           int64   `gorm:"column:type" json:"type" form:"type"`
1978
-	Doctor         int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
1979
-	ExecutionTime  int64   `gborm:"column:execution_time" json:"execution_time" form:"execution_time"`
1980
-	ExecutionStaff int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1981
-	ExecutionState int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1982
-	CheckTime      int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
1983
-	CheckState     int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
1984
-	Checker        int64   `gorm:"column:checker" json:"checker" form:"checker"`
1971
+	ID                   int64   `gorm:"column:id" json:"id" form:"id"`
1972
+	ProjectId            int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
1973
+	Price                float64 `gorm:"column:price" json:"price" form:"price"`
1974
+	UserOrgId            int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1975
+	Status               int64   `gorm:"column:status" json:"status" form:"status"`
1976
+	PatientId            int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1977
+	RecordDate           int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
1978
+	PrescriptionId       int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1979
+	Count                string  `gorm:"column:count" json:"count" form:"count"`
1980
+	FeedetlSn            string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1981
+	Type                 int64   `gorm:"column:type" json:"type" form:"type"`
1982
+	Doctor               int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
1983
+	ExecutionTime        int64   `gborm:"column:execution_time" json:"execution_time" form:"execution_time"`
1984
+	ExecutionStaff       int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1985
+	ExecutionState       int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1986
+	CheckTime            int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
1987
+	CheckState           int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
1988
+	Checker              int64   `gorm:"column:checker" json:"checker" form:"checker"`
1989
+	ExecutionFrequencyId int64   `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
1985 1990
 }
1986 1991
 
1987 1992
 func (HisPrescriptionProjectTwo) TableName() string {
@@ -2369,3 +2374,54 @@ type HisHospitalCheckRecordTwenty struct {
2369 2374
 func (HisHospitalCheckRecordTwenty) TableName() string {
2370 2375
 	return "his_hospital_check_record"
2371 2376
 }
2377
+
2378
+type UploadInfo struct {
2379
+	Bce02a   string `json:"bce02a"`
2380
+	Bck01c   string `json:"bck01c"`
2381
+	Diag     []*Diag
2382
+	Fasong   string `json:"fasong"`
2383
+	PresInfo []*PresInfo
2384
+	Vaa01    int `json:"vaa01"`
2385
+	Vaa07    int `json:"vaa07"`
2386
+}
2387
+
2388
+type Diag struct {
2389
+	Bak02 string `json:"bak02"`
2390
+	Vao06 string `json:"vao06"`
2391
+}
2392
+
2393
+type PresDetail struct {
2394
+	Item  []*Item
2395
+	Vaf59 string `json:"vaf59"`
2396
+}
2397
+
2398
+type PresInfo struct {
2399
+	Cbm06      string `json:"cbm06"`
2400
+	Cbm07      string `json:"cbm07"`
2401
+	Cbmid      string `json:"cbmid"`
2402
+	PresDetail []*PresDetail
2403
+}
2404
+
2405
+type Item struct {
2406
+	Bbx01  string `json:"bbx01"`
2407
+	Bby01  string `json:"bby01"`
2408
+	Bck01b string `json:"bck01b"`
2409
+	Bck01d string `json:"bck01d"`
2410
+	Bda01  string `json:"bda01"`
2411
+	Bdi01  string `json:"bdi01"`
2412
+	Rownr  string `json:"rownr"`
2413
+	Vaf11  string `json:"vaf11"`
2414
+	Vaf14  string `json:"vaf14"`
2415
+	Vaf15  string `json:"vaf15"`
2416
+	Vaf17  string `json:"vaf17"`
2417
+	Vaf18  int    `json:"vaf18"`
2418
+	Vaf19  string `json:"vaf19"`
2419
+	Vaf20  string `json:"vaf20"`
2420
+	Vaf21  string `json:"vaf21"`
2421
+	Vaf22  string `json:"vaf22"`
2422
+	Vaf32  string `json:"vaf32"`
2423
+	Vaf35  string `json:"vaf35"`
2424
+	Vaf36  string `json:"vaf36"`
2425
+	Vaf58  string `json:"vaf58"`
2426
+	Vaf61  string `json:"vaf61"`
2427
+}

+ 35 - 33
models/his_summary_models.go 查看文件

@@ -179,39 +179,40 @@ func (VmHisOrderInfo) TableName() string {
179 179
 }
180 180
 
181 181
 type VmHisPrescriptionProject struct {
182
-	ID                 int64   `gorm:"column:id" json:"id" form:"id"`
183
-	ProjectId          int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
184
-	Price              float64 `gorm:"column:price" json:"price" form:"price"`
185
-	UserOrgId          int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
186
-	Status             int64   `gorm:"column:status" json:"status" form:"status"`
187
-	Ctime              int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
188
-	Mtime              int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
189
-	PatientId          int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
190
-	HisPatientId       int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
191
-	RecordDate         int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
192
-	PrescriptionId     int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
193
-	Count              string  `gorm:"column:count" json:"count" form:"count"`
194
-	FeedetlSn          string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
195
-	MedListCodg        string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
196
-	SingleDose         string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
197
-	DeliveryWay        string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
198
-	ExecutionFrequency string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
199
-	Day                string  `gorm:"column:day" json:"day" form:"day"`
200
-	Remark             string  `gorm:"column:remark" json:"remark" form:"remark"`
201
-	Unit               string  `gorm:"column:unit" json:"unit" form:"unit"`
202
-	Type               int64   `gorm:"column:type" json:"type" form:"type"`
203
-	Doctor             int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
204
-	ExecutionTime      int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
205
-	ExecutionStaff     int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
206
-	ExecutionState     int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
207
-	CheckTime          int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
208
-	CheckState         int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
209
-	Checker            int64   `gorm:"column:checker" json:"checker" form:"checker"`
210
-	StartTime          int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
211
-	TeamId             int64   `gorm:"column:team_id" json:"team_id" form:"team_id"`
212
-	FrequencyType      int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
213
-	DayCount           int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
214
-	WeekDay            string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
182
+	ID                   int64   `gorm:"column:id" json:"id" form:"id"`
183
+	ProjectId            int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
184
+	Price                float64 `gorm:"column:price" json:"price" form:"price"`
185
+	UserOrgId            int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
186
+	Status               int64   `gorm:"column:status" json:"status" form:"status"`
187
+	Ctime                int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
188
+	Mtime                int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
189
+	PatientId            int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
190
+	HisPatientId         int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
191
+	RecordDate           int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
192
+	PrescriptionId       int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
193
+	Count                string  `gorm:"column:count" json:"count" form:"count"`
194
+	FeedetlSn            string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
195
+	MedListCodg          string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
196
+	SingleDose           string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
197
+	DeliveryWay          string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
198
+	ExecutionFrequency   string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
199
+	Day                  string  `gorm:"column:day" json:"day" form:"day"`
200
+	Remark               string  `gorm:"column:remark" json:"remark" form:"remark"`
201
+	Unit                 string  `gorm:"column:unit" json:"unit" form:"unit"`
202
+	Type                 int64   `gorm:"column:type" json:"type" form:"type"`
203
+	Doctor               int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
204
+	ExecutionTime        int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
205
+	ExecutionStaff       int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
206
+	ExecutionState       int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
207
+	CheckTime            int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
208
+	CheckState           int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
209
+	Checker              int64   `gorm:"column:checker" json:"checker" form:"checker"`
210
+	StartTime            int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
211
+	TeamId               int64   `gorm:"column:team_id" json:"team_id" form:"team_id"`
212
+	FrequencyType        int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
213
+	DayCount             int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
214
+	WeekDay              string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
215
+	ExecutionFrequencyId int64   `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
215 216
 }
216 217
 
217 218
 func (VmHisPrescriptionProject) TableName() string {
@@ -276,6 +277,7 @@ type VmHisDoctorAdviceInfo struct {
276 277
 	Mtime                 int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
277 278
 	AdviceId              int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
278 279
 	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
280
+	ExecutionFrequencyId  int64   `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
279 281
 }
280 282
 
281 283
 func (VmHisDoctorAdviceInfo) TableName() string {

+ 1 - 1
models/patient_models.go 查看文件

@@ -1362,7 +1362,7 @@ type XtAssessmentBeforeDislysis struct {
1362 1362
 	DialysisOrderId                int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
1363 1363
 	Temperature                    float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
1364 1364
 	PulseFrequency                 float64 `gorm:"column:pulse_frequency" json:"pulse_frequency" form:"pulse_frequency"`
1365
-	BreathingRate                  float64 `gorm:"column:breathing_rate" json:"breathing_rate" form:"breathing_rate"`
1365
+	BreathingRate                  string  `gorm:"column:breathing_rate" json:"breathing_rate" form:"breathing_rate"`
1366 1366
 	SystolicBloodPressure          float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure" form:"systolic_blood_pressure"`
1367 1367
 	DiastolicBloodPressure         float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure" form:"diastolic_blood_pressure"`
1368 1368
 	BloodPressureType              int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type" form:"blood_pressure_type"`

+ 431 - 142
models/pharmacy_models.go 查看文件

@@ -2,183 +2,192 @@ package models
2 2
 
3 3
 //药房表
4 4
 type Pharmary struct {
5
-	ID			int64	`gorm:"column:id" json:"id" form:"id"`
6
-	UserOrgId	int64	`gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
7
-	PatientId  int64	`gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
8
-	Ctime 		int64	`gorm:"column:ctime" json:"ctime" form:"ctime"`
9
-	Mtime 		int64	`gorm:"column:mtime" json:"mtime" form:"mtime"`
10
-	Status 		int64	`gorm:"column:status" json:"status" form:"status"`
11
-	RecordDate  int64	`gorm:"column:record_date" json:"record_date" form:"record_date"`
5
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
6
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
7
+	PatientId  int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
8
+	Ctime      int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
9
+	Mtime      int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
10
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
11
+	RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
12 12
 }
13 13
 
14
-func (Pharmary)TableName() string {
14
+func (Pharmary) TableName() string {
15 15
 	return "sgj_xt.xt_pharmacy"
16 16
 }
17 17
 
18 18
 type XtErrs struct {
19
-	OrgId			int64	`gorm:"column:org_id" json:"org_id" form:"org_id"`
20
-	Route			string	`gorm:"column:route" json:"route" form:"route"`
21
-	Parameter		string	`gorm:"column:parameter" json:"parameter" form:"parameter"`
22
-	Text_err		string	`gorm:"column:text_err" json:"text_err" form:"text_err"`
19
+	OrgId     int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
20
+	Route     string `gorm:"column:route" json:"route" form:"route"`
21
+	Parameter string `gorm:"column:parameter" json:"parameter" form:"parameter"`
22
+	Text_err  string `gorm:"column:text_err" json:"text_err" form:"text_err"`
23 23
 }
24
-func (XtErrs)TableName() string {
24
+
25
+func (XtErrs) TableName() string {
25 26
 	return "sgj_xt.xt_errs"
26 27
 }
27 28
 
28 29
 //病人
29 30
 type TmpPatient struct {
30
-	PatientID int64
31
-	Name string
32
-	DialysisNo string	//透析号
31
+	PatientID  int64
32
+	Name       string
33
+	DialysisNo string //透析号
33 34
 }
34 35
 
35 36
 //药品信息
36 37
 type PharmacyContent struct {
37
-	Name string		//名称
38
+	Name         string //名称
38 39
 	SingleDosage string //单次用量
39
-	Usage string	//用法
40
-	Frequency string //频率
41
-	Days string	//天数
42
-	Total string //总量
43
-	Doctor string	//开立医生
44
-	DataSources string	//数据来源
45
-	Remarks string	//备注
40
+	Usage        string //用法
41
+	Frequency    string //频率
42
+	Days         string //天数
43
+	Total        string //总量
44
+	Doctor       string //开立医生
45
+	DataSources  string //数据来源
46
+	Remarks      string //备注
46 47
 }
48
+
47 49
 //发药明细列表
48 50
 type DispensingList struct {
49
-	PatientID int64	//	患者id
50
-	Name string	//患者姓名
51
-	DoctorId	int64	//医生id
52
-	DoctorName string	//医生姓名
53
-	RecordTime	int64	//发药时间(转化前)
54
-	RecordDate 	string	//发药时间(转化后)
51
+	PatientID  int64  //	患者id
52
+	Name       string //患者姓名
53
+	DoctorId   int64  //医生id
54
+	DoctorName string //医生姓名
55
+	RecordTime int64  //发药时间(转化前)
56
+	RecordDate string //发药时间(转化后)
55 57
 }
56 58
 type PrescripDetailsList struct {
57 59
 	Name string //处方名
58
-	Id int64	//处方id
60
+	Id   int64  //处方id
59 61
 	Pres []*PrescripDetails
60 62
 }
63
+
61 64
 //处方详情
62 65
 type PrescripDetails struct {
63
-	Drugname string		//药品名称
66
+	Drugname     string //药品名称
64 67
 	SingleDosage string //单次用量
65
-	Usage string	//用法
66
-	Frequency string //频率
67
-	Days string	//天数
68
-	Total string //总量
69
-	UnitPrice string//单价
70
-	Remarks string	//备注
68
+	Usage        string //用法
69
+	Frequency    string //频率
70
+	Days         string //天数
71
+	Total        string //总量
72
+	UnitPrice    string //单价
73
+	Remarks      string //备注
71 74
 }
75
+
72 76
 //临时医嘱
73 77
 type StatOrder struct {
74
-	StartTime string//开始时间
75
-	Name string//医嘱名称
76
-	Specifications string //药品规格
77
-	PreQuantity string//开药数量
78
-	SingleDosage string//单次用量
79
-	RouteOfAdministration string//给药途径
80
-	ExecutionFrequency string//执行频率
78
+	StartTime             string //开始时间
79
+	Name                  string //医嘱名称
80
+	Specifications        string //药品规格
81
+	PreQuantity           string //开药数量
82
+	SingleDosage          string //单次用量
83
+	RouteOfAdministration string //给药途径
84
+	ExecutionFrequency    string //执行频率
81 85
 }
86
+
82 87
 //退库用的结构体
83 88
 type SpecialForStock struct {
84
-	BatchNumber 		string	`json:"batch_number"`
85
-	BatchNumberId		int64	`json:"batch_number_id"`
86
-	Dealer				string	`json:"dealer"`
87
-	DrugId				int64	`json:"drug_id"`
88
-	DrugName			string	`json:"drug_name"`
89
-	DrugType			int64	`json:"drug_type"`
90
-	DrugWarehouseInfo	interface{}	`json:"drug_warehouse_info"`
91
-	ExpiryDate			string	`json:"expiry_date"`
92
-	LastPrice			float64	`json:"last_price"`
93
-	Manufacturer		string	`json:"manufacturer"`
94
-	MaxUnit				string	`json:"max_unit"`
95
-	MinUnit				string	`json:"min_unit"`
96
-	Name 				string	`json:"name"`
97
-	Price 				string	`json:"price"`
98
-	ProductDate			string	`json:"product_date"`
99
-	RegisterAccount		string	`json:"register_account"`
100
-	Remark				string	`json:"remark"`
101
-	RetailPrice			string	`json:"retail_price"`
102
-	ReturnCount			string	`json:"return_count"`
103
-
89
+	BatchNumber       string      `json:"batch_number"`
90
+	BatchNumberId     int64       `json:"batch_number_id"`
91
+	Dealer            string      `json:"dealer"`
92
+	DrugId            int64       `json:"drug_id"`
93
+	DrugName          string      `json:"drug_name"`
94
+	DrugType          int64       `json:"drug_type"`
95
+	DrugWarehouseInfo interface{} `json:"drug_warehouse_info"`
96
+	ExpiryDate        string      `json:"expiry_date"`
97
+	LastPrice         float64     `json:"last_price"`
98
+	Manufacturer      string      `json:"manufacturer"`
99
+	MaxUnit           string      `json:"max_unit"`
100
+	MinUnit           string      `json:"min_unit"`
101
+	Name              string      `json:"name"`
102
+	Price             string      `json:"price"`
103
+	ProductDate       string      `json:"product_date"`
104
+	RegisterAccount   string      `json:"register_account"`
105
+	Remark            string      `json:"remark"`
106
+	RetailPrice       string      `json:"retail_price"`
107
+	ReturnCount       string      `json:"return_count"`
104 108
 }
109
+
105 110
 //药品发药药品列表
106 111
 type ListOfDrugs struct {
107
-	ID int64	`json:"id"`		//药品id
108
-	Name string	`json:"name"`	//药品 名称
109
-	Specifications string	`json:"specifications"` //规格
110
-	Stock string	`json:"stock"`  //库存(当前的仓库库存)
112
+	ID             int64  `json:"id"`             //药品id
113
+	Name           string `json:"name"`           //药品 名称
114
+	Specifications string `json:"specifications"` //规格
115
+	Stock          string `json:"stock"`          //库存(当前的仓库库存)
111 116
 }
117
+
112 118
 //病人信息
113 119
 type PatientInformation struct {
114
-	Id			string  `json:"id"`//hid表示his_doctor_advice_info的id ,xid表示xt_doctor_advice的id
115
-	Name 		string  `json:"name"`//患者姓名
116
-	SingleDosage string	`json:"single_dosage"` //单次用量
117
-	Usage string		`json:"usage"`//用法
118
-	Frequency string `json:"frequency"`//频率
119
-	Days string	`json:"days"`//天数
120
-	Total string `json:"total"`//总量
121
-	DataSources string	`json:"data_sources"`//数据来源
122
-	People	string	`json:"people"`//领药人
120
+	Id           string `json:"id"`            //hid表示his_doctor_advice_info的id ,xid表示xt_doctor_advice的id
121
+	PatientId    int64  `json:"patient_id"`    //患者id
122
+	Name         string `json:"name"`          //患者姓名
123
+	SingleDosage string `json:"single_dosage"` //单次用量
124
+	Usage        string `json:"usage"`         //用法
125
+	Frequency    string `json:"frequency"`     //频率
126
+	Days         string `json:"days"`          //天数
127
+	Total        string `json:"total"`         //总量
128
+	DataSources  string `json:"data_sources"`  //数据来源
129
+	People       string `json:"people"`        //领药人
130
+	Quantity     int64  `json:"quantity"`      //总量拆分——数据部分
131
+	Unit         string `json:"unit"`          //总量拆分——单位部分
123 132
 }
124 133
 type HisDoctorAdviceInfoL struct {
125
-	ID                    int64                  `gorm:"column:id" json:"id" form:"id"`
126
-	UserOrgId             int64                  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
127
-	PatientId             int64                  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
128
-	HisPatientId          int64                  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
129
-	AdviceType            int64                  `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
130
-	AdviceDate            int64                  `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
131
-	StartTime             int64                  `gorm:"column:start_time" json:"start_time" form:"start_time"`
132
-	AdviceName            string                 `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
133
-	AdviceDesc            string                 `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
134
-	ReminderDate          int64                  `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
135
-	SingleDose            float64                `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
136
-	SingleDoseUnit        string                 `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
137
-	PrescribingNumber     float64                `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
138
-	PrescribingNumberUnit string                 `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
139
-	DeliveryWay           string                 `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
140
-	ExecutionFrequency    string                 `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
141
-	AdviceDoctor          int64                  `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
142
-	Status                int64                  `gorm:"column:status" json:"status" form:"status"`
143
-	CreatedTime           int64                  `gorm:"column:created_time" json:"created_time" form:"created_time"`
144
-	UpdatedTime           int64                  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
145
-	AdviceAffirm          string                 `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
146
-	Remark                string                 `gorm:"column:remark" json:"remark" form:"remark"`
147
-	StopTime              int64                  `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
148
-	StopReason            string                 `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
149
-	StopDoctor            int64                  `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
150
-	StopState             int64                  `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
151
-	ParentId              int64                  `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
152
-	ExecutionTime         int64                  `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
153
-	ExecutionStaff        int64                  `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
154
-	ExecutionState        int64                  `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
155
-	Checker               int64                  `gorm:"column:checker" json:"checker" form:"checker"`
156
-	RecordDate            int64                  `gorm:"column:record_date" json:"record_date" form:"record_date"`
157
-	DialysisOrderId       int64                  `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
158
-	CheckTime             int64                  `gorm:"column:check_time" json:"check_time" form:"check_time"`
159
-	CheckState            int64                  `gorm:"column:check_state" json:"check_state" form:"check_state"`
160
-	DrugSpec              float64                `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
161
-	DrugSpecUnit          string                 `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
162
-	Groupno               int64                  `gorm:"column:groupno" json:"groupno" form:"groupno"`
163
-	RemindType            int64                  `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
164
-	FrequencyType         int64                  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
165
-	DayCount              int64                  `gorm:"column:day_count" json:"day_count" form:"day_count"`
166
-	WeekDay               string                 `gorm:"column:week_day" json:"week_day" form:"week_day"`
167
-	TemplateId            string                 `gorm:"column:template_id" json:"template_id" form:"template_id"`
168
-	Modifier              int64                  `gorm:"column:modifier" json:"modifier" form:"modifier"`
169
-	DrugId                int64                  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
170
-	Price                 float64                `gorm:"column:price" json:"price" form:"price"`
171
-	PrescriptionId        int64                  `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
172
-	MedListCodg           string                 `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
173
-	FeedetlSn             string                 `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
174
-	Day                   int64                  `gorm:"column:day" json:"day" form:"day"`
175
-	Diagnosis             int64                  `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
176
-	Way                   int64                  `gorm:"column:way" json:"way" form:"way"`
177
-	HospApprFlag          int64                  `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
178
-	LmtUsedFlag           int64                  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
179
-	IsMedicine			  int64					 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
180
-	People				  int64					 `gorm:"column:people" json:"people" form:"people"`
181
-	DispensingTime		  int64					 `gorm:"column:dispensing_time" json:"dispensing_time" form:"dispensing_time"`
134
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
135
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
136
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
137
+	HisPatientId          int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
138
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
139
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
140
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
141
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
142
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
143
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
144
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
145
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
146
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
147
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
148
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
149
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
150
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
151
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
152
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
153
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
154
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
155
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
156
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
157
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
158
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
159
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
160
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
161
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
162
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
163
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
164
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
165
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
166
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
167
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
168
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
169
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
170
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
171
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
172
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
173
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
174
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
175
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
176
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
177
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
178
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
179
+	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
180
+	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
181
+	MedListCodg           string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
182
+	FeedetlSn             string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
183
+	Day                   int64   `gorm:"column:day" json:"day" form:"day"`
184
+	Diagnosis             int64   `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
185
+	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
186
+	HospApprFlag          int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
187
+	LmtUsedFlag           int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
188
+	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
189
+	People                int64   `gorm:"column:people" json:"people" form:"people"`
190
+	DispensingTime        int64   `gorm:"column:dispensing_time" json:"dispensing_time" form:"dispensing_time"`
182 191
 }
183 192
 
184 193
 func (HisDoctorAdviceInfoL) TableName() string {
@@ -231,24 +240,304 @@ type XtDoctorAdviceL struct {
231 240
 	UserName              string  `gorm:"column:user_name" json:"user_name" form:"user_name"`
232 241
 	CheckerName           string  `gorm:"column:user_name" json:"name" form:"name"`
233 242
 	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
234
-	IsMedicine			  int64	  `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
235
-	People				  int64	  `gorm:"column:people" json:"people" form:"people"`
236
-	DispensingTime		  int64	  `gorm:"column:dispensing_time" json:"dispensing_time" form:"dispensing_time"`
243
+	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
244
+	People                int64   `gorm:"column:people" json:"people" form:"people"`
245
+	DispensingTime        int64   `gorm:"column:dispensing_time" json:"dispensing_time" form:"dispensing_time"`
237 246
 }
238 247
 
239 248
 func (XtDoctorAdviceL) TableName() string {
240 249
 	return "sgj_xt.xt_doctor_advice"
241 250
 }
251
+
242 252
 type TmpTTT struct {
243 253
 	PatientID int64
244 254
 }
245 255
 type TmpLLL struct {
246
-	DrugId    int64
256
+	DrugId int64
247 257
 }
248 258
 type TmpID struct {
249
-	Id    int64
259
+	Id             int64
250 260
 	DispensingTime int64
251 261
 }
252
-type TmpAdviceDoctor  struct {
253
-	AdviceDoctor    int64
262
+type TmpAdviceDoctor struct {
263
+	AdviceDoctor int64
264
+}
265
+
266
+//替换药品名称
267
+type ReplacementDrugs struct {
268
+	Id   int64  `json:"id"`
269
+	Name string `json:"name"`
270
+}
271
+
272
+//病人
273
+type DialysisPatient struct {
274
+	ID   int64  `json:"id"`
275
+	Name string `json:"name"`
276
+}
277
+
278
+//项目下拉列表
279
+type DropDownList struct {
280
+	Id   string `json:"id"`
281
+	Name string `json:"name"`
282
+}
283
+type XtHisProjectL struct {
284
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
285
+	ProjectName                 string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
286
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
287
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
288
+	Price                       float64 `gorm:"column:price" json:"price" form:"price"`
289
+	Unit                        string  `gorm:"column:unit" json:"unit" form:"unit"`
290
+	CostClassify                int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
291
+	ExecutiveSection            int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
292
+	MedicalCoverage             int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
293
+	StatisticalClassification   int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"` //统计分类(组
294
+	DiseaseDirectory            int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
295
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
296
+	MedicalCode                 string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
297
+	TubeColor                   int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
298
+	MedicalStatus               int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
299
+	Remark                      string  `gorm:"column:remark" json:"remark" form:"remark"`
300
+	Sign                        int64   `gorm:"column:sign" json:"sign" form:"sign"`
301
+	DefaultNumber               string  `gorm:"column:default_number" json:"prescribing_number" form:"default_number"`
302
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
303
+	IsCharge                    int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
304
+	IsEstimate                  int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
305
+	IsWorkload                  int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
306
+	Sort                        string  `gorm:"column:sort" json:"sort" form:"sort"`
307
+	DoctorAdvice                int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
308
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
309
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
310
+	CreatedTime                 int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
311
+	UpdatedTime                 int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
312
+	SingleDose                  string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
313
+	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
314
+	DeliveryWay                 string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
315
+	NumberDays                  string  `gorm:"column:number_days" json:"day" form:"number_days"`
316
+	Total                       string  `gorm:"column:total" json:"total" form:"total"`
317
+	Category                    int64   `gorm:"column:category" json:"category" form:"category"`
318
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
319
+	SpecailProject              int64   `gorm:"column:specail_project" json:"specail_project" form:"specail_project"`
320
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
321
+	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
322
+	Translate                   string  `json:"translate"` //翻译——统计分类(组
323
+}
324
+
325
+func (XtHisProjectL) TableName() string {
326
+	return "sgj_xt.xt_his_project"
327
+}
328
+
329
+type GoodInfoL struct {
330
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
331
+	GoodCode               string  `gorm:"column:good_code" json:"good_code" form:"good_code"`
332
+	SpecificationName      string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
333
+	GoodTypeId             int64   `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
334
+	GoodUnit               int64   `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
335
+	BuyPrice               float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
336
+	SellPrice              float64 `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
337
+	Remark                 string  `gorm:"column:remark" json:"remark" form:"remark"`
338
+	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
339
+	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
340
+	Manufacturer           int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
341
+	Dealer                 int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
342
+	ExpiryDateWarnDayCount int64   `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
343
+	StockWarnCount         int64   `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
344
+	IsReuse                int64   `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
345
+	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
346
+	FilmArea               string  `gorm:"column:film_area" json:"film_area" form:"film_area"`
347
+	IsUse                  int64   `gorm:"column:is_use" json:"is_use" form:"is_use"`
348
+	FilmMaterialQuality    string  `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
349
+	OrgId                  int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
350
+	Modifier               int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
351
+	Creater                int64   `gorm:"column:creater" json:"creater" form:"creater"`
352
+	GoodName               string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
353
+	Pinyin                 string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
354
+	Wubi                   string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
355
+	GoodKind               int64   `gorm:"column:good_kind" json:"good_kind" form:"good_kind"` //组
356
+	MedicalInsuranceLevel  int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
357
+	RetailPrice            float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
358
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
359
+	ProvincesCode          string  `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
360
+
361
+	IsSpecialDiseases           int64                `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
362
+	IsRecord                    int64                `gorm:"column:is_record" json:"is_record" form:"is_record"`
363
+	StatisticsCategory          int64                `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
364
+	GoodStatus                  string               `gorm:"column:good_status" json:"good_status" form:"good_status"`
365
+	DefaultCount                int64                `gorm:"column:default_count" json:"default_count" form:"default_count"`
366
+	Sign                        int64                `gorm:"column:sign" json:"sign" form:"sign"`
367
+	IsDefault                   int64                `gorm:"column:is_default" json:"is_default" form:"is_default"`
368
+	IsChargeUse                 int64                `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
369
+	IsChargePredict             int64                `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
370
+	IsStatisticsWork            int64                `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
371
+	Sort                        int64                `gorm:"column:sort" json:"sort" form:"sort"`
372
+	IsDoctorUse                 int64                `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
373
+	Agent                       string               `gorm:"column:agent" json:"agent" form:"agent"`
374
+	GoodNumber                  string               `gorm:"column:good_number" json:"good_number" form:"good_number"`
375
+	GoodsType                   GoodsType            `gorm:"ForeignKey:ID;AssociationForeignKey:GoodTypeId" json:"type"`
376
+	CommdityCode                string               `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
377
+	SocialSecurityDirectoryCode string               `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
378
+	ProductionType              string               `gorm:"column:production_type" json:"production_type" form:"production_type"`
379
+	SpecialMedical              string               `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
380
+	IsMark                      int64                `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
381
+	MinNumber                   int64                `gorm:"column:min_number" json:"min_number" form:"min_number"`
382
+	PackingUnit                 string               `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
383
+	PackingPrice                float64              `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
384
+	DefaultCountUnit            string               `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
385
+	MinUnit                     string               `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
386
+	Total                       float64              `gorm:"column:total" json:"total" form:"total"`
387
+	StWarehousingInfo           []*StWarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_warehouse_info"`
388
+	CancelStockInfo             []*CancelStockInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
389
+	RegisterNumber              string               `gorm:"column:register_number" json:"register_number" form:"register_number"`
390
+	GoodSotckInfo               []*GoodSotckInfo     `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"good_stock_in"`
391
+	IsUser                      int64                `gorm:"column:is_user" json:"is_user" form:"is_user"`
392
+	Number                      string               `gorm:"column:number" json:"number" form:"number"`
393
+	IsWarehouse                 int64                `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
394
+	SumCount                    int64                `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
395
+	BatchRetaiPrice             float64              `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
396
+	SumInCount                  int64                `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
397
+	WarehousingInfo             []*WarehousingInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_info"`
398
+	Translate                   string               `json:"translate"` //翻译——统计分类(组
399
+}
400
+
401
+func (GoodInfoL) TableName() string {
402
+	return "sgj_xt.xt_good_information"
403
+}
404
+
405
+type BaseDrugLibL struct {
406
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
407
+	DrugName                    string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
408
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
409
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
410
+	DrugAlias                   string  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
411
+	DrugAliasPinyin             string  `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
412
+	DrugAliasWubi               string  `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
413
+	DrugCategory                int64   `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
414
+	DrugSpec                    string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
415
+	DrugType                    int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
416
+	DrugStockLimit              string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
417
+	DrugOriginPlace             string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
418
+	DrugDosageForm              int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
419
+	MedicalInsuranceLevel       int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
420
+	MaxUnit                     string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
421
+	MinNumber                   int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
422
+	MinUnit                     string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
423
+	Dose                        string  `gorm:"column:dose" json:"dose" form:"dose"`
424
+	DoseUnit                    string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
425
+	MinPrice                    float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
426
+	UnitMatrixing               string  `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
427
+	RetailPrice                 float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
428
+	LastPrice                   float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
429
+	DrugControl                 int64   `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
430
+	Number                      string  `gorm:"column:number" json:"number" form:"number"`
431
+	DrugClassify                string  `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
432
+	DrugDose                    float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
433
+	DrugDoseUnit                int64   `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
434
+	MedicalInsuranceNumber      string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
435
+	ProvincesCode               string  `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
436
+	Manufacturer                int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
437
+	PharmacologyCategory        int64   `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
438
+	StatisticsCategory          int64   `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
439
+	Code                        string  `gorm:"column:code" json:"code" form:"code"`
440
+	IsSpecialDiseases           int64   `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
441
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
442
+	Agent                       string  `gorm:"column:agent" json:"agent" form:"agent"`
443
+	DrugStatus                  string  `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
444
+	LimitRemark                 string  `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
445
+	DeliveryWay                 string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
446
+	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
447
+	SingleDose                  float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
448
+	SingleDoseUnit              string  `json:"single_dose_unit"` //danwei
449
+	PrescribingNumber           float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
450
+	Label                       int64   `gorm:"column:label" json:"label" form:"label"`
451
+	Sort                        int64   `gorm:"column:sort" json:"sort" form:"sort"`
452
+	IsUseDoctorAdvice           int64   `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
453
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
454
+	IsChargePredict             int64   `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
455
+	IsStatisticsWork            int64   `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
456
+	IsChargeUse                 int64   `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
457
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
458
+	Ctime                       int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
459
+	Mtime                       int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
460
+	OrgId                       int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
461
+	DrugCode                    string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
462
+	Dealer                      int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
463
+	PrescriptionMark            int64   `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
464
+	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
465
+	DrugRemark                  string  `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
466
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
467
+	DoseCode                    string  `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
468
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
469
+	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
470
+	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
471
+	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
472
+	DrugDay               string                 `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
473
+	Total                 float64                `gorm:"column:total" json:"total" form:"total"`
474
+	PrescribingNumberUnit string                 `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
475
+	DrugWarehouseInfo     []*XtDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
476
+	IsUse                 int64                  `gorm:"column:is_user" json:"is_user" form:"is_user"`
477
+	BatchRetaiPrice       float64                `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
478
+	SumCount              int64                  `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
479
+	SumInCount            int64                  `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
480
+	IsPharmacy            int64                  `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
481
+	List1                 interface{}            `json:"list_1"`
482
+	List2                 interface{}            `json:"list_2"`
483
+}
484
+
485
+func (BaseDrugLibL) TableName() string {
486
+	return "xt_base_drug"
487
+}
488
+
489
+//组
490
+type HisPrescriptionInfoTemplateL struct {
491
+	ID                             int64                              `gorm:"column:id" json:"id" form:"id"`
492
+	UserOrgId                      int64                              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
493
+	RecordDate                     int64                              `gorm:"column:record_date" json:"record_date" form:"record_date"`
494
+	PatientId                      int64                              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
495
+	Status                         int64                              `gorm:"column:status" json:"status" form:"status"`
496
+	Ctime                          int64                              `gorm:"column:ctime" json:"ctime" form:"ctime"`
497
+	Mtime                          int64                              `gorm:"column:mtime" json:"mtime" form:"mtime"`
498
+	Type                           int64                              `gorm:"column:type" json:"type" form:"type"`
499
+	Creator                        int64                              `gorm:"column:creator" json:"creator" form:"creator"`
500
+	Modifier                       int64                              `gorm:"column:modifier" json:"modifier" form:"modifier"`
501
+	PType                          int64                              `gorm:"column:p_type" json:"p_type" form:"p_type"`
502
+	PTemplateId                    int64                              `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
503
+	HisPrescriptionAdviceTemplate  []*HisPrescriptionAdviceTemplate   `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
504
+	HisPrescriptionProjectTemplate []*HisPrescriptionProjectTemplateL `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
505
+	MedType                        string                             `gorm:"column:med_type" json:"med_type" form:"med_type"`
506
+}
507
+
508
+func (HisPrescriptionInfoTemplateL) TableName() string {
509
+	return "his_prescription_info_template"
510
+}
511
+
512
+type HisPrescriptionProjectTemplateL struct {
513
+	ID                 int64         `gorm:"column:id" json:"id" form:"id"`
514
+	ProjectId          int64         `gorm:"column:project_id" json:"project_id" form:"project_id"`
515
+	Price              float64       `gorm:"column:price" json:"price" form:"price"`
516
+	UserOrgId          int64         `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
517
+	Status             int64         `gorm:"column:status" json:"status" form:"status"`
518
+	Ctime              int64         `gorm:"column:ctime" json:"ctime" form:"ctime"`
519
+	Mtime              int64         `gorm:"column:mtime" json:"mtime" form:"mtime"`
520
+	PatientId          int64         `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
521
+	HisPatientId       int64         `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
522
+	RecordDate         int64         `gorm:"column:record_date" json:"record_date" form:"record_date"`
523
+	Count              string        `gorm:"column:count" json:"count" form:"count"`
524
+	FeedetlSn          string        `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
525
+	MedListCodg        string        `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
526
+	SingleDose         string        `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
527
+	DeliveryWay        string        `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
528
+	ExecutionFrequency string        `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
529
+	Day                string        `gorm:"column:day" json:"day" form:"day"`
530
+	Remark             string        `gorm:"column:remark" json:"remark" form:"remark"`
531
+	Unit               string        `gorm:"column:unit" json:"unit" form:"unit"`
532
+	Type               int64         `gorm:"column:type" json:"type" form:"type"`
533
+	PrescriptionId     int64         `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
534
+	XtHisProject       XtHisProjectL `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
535
+	GoodInfo           GoodInfoL     `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"good_info"`
536
+	FrequencyType      int64         `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
537
+	DayCount           int64         `gorm:"column:day_count" json:"day_count" form:"day_count"`
538
+	WeekDay            string        `gorm:"column:week_day" json:"week_day" form:"week_day"`
539
+}
540
+
541
+func (HisPrescriptionProjectTemplateL) TableName() string {
542
+	return "his_prescription_project_template"
254 543
 }

+ 36 - 34
models/stock_models.go 查看文件

@@ -1309,6 +1309,7 @@ type BloodHisDoctorAdviceInfo struct {
1309 1309
 	Way                   int64                       `gorm:"column:way" json:"way" form:"way"`
1310 1310
 	HospApprFlag          int64                       `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
1311 1311
 	LmtUsedFlag           int64                       `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
1312
+	ExecutionFrequencyId  int64                       `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
1312 1313
 }
1313 1314
 
1314 1315
 func (BloodHisDoctorAdviceInfo) TableName() string {
@@ -1316,40 +1317,41 @@ func (BloodHisDoctorAdviceInfo) TableName() string {
1316 1317
 }
1317 1318
 
1318 1319
 type BloodHisPrescriptionProject struct {
1319
-	ID                 int64                          `gorm:"column:id" json:"id" form:"id"`
1320
-	ProjectId          int64                          `gorm:"column:project_id" json:"project_id" form:"project_id"`
1321
-	Price              float64                        `gorm:"column:price" json:"price" form:"price"`
1322
-	UserOrgId          int64                          `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1323
-	Status             int64                          `gorm:"column:status" json:"status" form:"status"`
1324
-	Ctime              int64                          `gorm:"column:ctime" json:"ctime" form:"ctime"`
1325
-	Mtime              int64                          `gorm:"column:mtime" json:"mtime" form:"mtime"`
1326
-	PatientId          int64                          `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1327
-	HisPatientId       int64                          `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1328
-	RecordDate         int64                          `gorm:"column:record_date" json:"record_date" form:"record_date"`
1329
-	PrescriptionId     int64                          `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1330
-	Count              string                         `gorm:"column:count" json:"count" form:"count"`
1331
-	FeedetlSn          string                         `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1332
-	MedListCodg        string                         `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
1333
-	SingleDose         string                         `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1334
-	DeliveryWay        string                         `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1335
-	ExecutionFrequency string                         `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1336
-	Day                string                         `gorm:"column:day" json:"day" form:"day"`
1337
-	Remark             string                         `gorm:"column:remark" json:"remark" form:"remark"`
1338
-	Unit               string                         `gorm:"column:unit" json:"unit" form:"unit"`
1339
-	Type               int64                          `gorm:"column:type" json:"type" form:"type"`
1340
-	Doctor             int64                          `gorm:"column:doctor" json:"doctor" form:"doctor"`
1341
-	ExecutionTime      int64                          `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1342
-	ExecutionStaff     int64                          `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1343
-	ExecutionState     int64                          `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1344
-	CheckTime          int64                          `gorm:"column:check_time" json:"check_time" form:"check_time"`
1345
-	CheckState         int64                          `gorm:"column:check_state" json:"check_state" form:"check_state"`
1346
-	Checker            int64                          `gorm:"column:checker" json:"checker" form:"checker"`
1347
-	StartTime          int64                          `gorm:"column:start_time" json:"start_time" form:"start_time"`
1348
-	TeamId             int64                          `gorm:"column:team_id" json:"team_id" form:"team_id"`
1349
-	FrequencyType      int64                          `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1350
-	DayCount           int64                          `gorm:"column:day_count" json:"day_count" form:"day_count"`
1351
-	WeekDay            string                         `gorm:"column:week_day" json:"week_day" form:"week_day"`
1352
-	ChildDoctorAdvice  []*BloodHisPrescriptionProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ProjectId" json:"child"`
1320
+	ID                   int64                          `gorm:"column:id" json:"id" form:"id"`
1321
+	ProjectId            int64                          `gorm:"column:project_id" json:"project_id" form:"project_id"`
1322
+	Price                float64                        `gorm:"column:price" json:"price" form:"price"`
1323
+	UserOrgId            int64                          `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1324
+	Status               int64                          `gorm:"column:status" json:"status" form:"status"`
1325
+	Ctime                int64                          `gorm:"column:ctime" json:"ctime" form:"ctime"`
1326
+	Mtime                int64                          `gorm:"column:mtime" json:"mtime" form:"mtime"`
1327
+	PatientId            int64                          `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1328
+	HisPatientId         int64                          `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1329
+	RecordDate           int64                          `gorm:"column:record_date" json:"record_date" form:"record_date"`
1330
+	PrescriptionId       int64                          `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1331
+	Count                string                         `gorm:"column:count" json:"count" form:"count"`
1332
+	FeedetlSn            string                         `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1333
+	MedListCodg          string                         `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
1334
+	SingleDose           string                         `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1335
+	DeliveryWay          string                         `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1336
+	ExecutionFrequency   string                         `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1337
+	Day                  string                         `gorm:"column:day" json:"day" form:"day"`
1338
+	Remark               string                         `gorm:"column:remark" json:"remark" form:"remark"`
1339
+	Unit                 string                         `gorm:"column:unit" json:"unit" form:"unit"`
1340
+	Type                 int64                          `gorm:"column:type" json:"type" form:"type"`
1341
+	Doctor               int64                          `gorm:"column:doctor" json:"doctor" form:"doctor"`
1342
+	ExecutionTime        int64                          `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1343
+	ExecutionStaff       int64                          `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1344
+	ExecutionState       int64                          `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1345
+	CheckTime            int64                          `gorm:"column:check_time" json:"check_time" form:"check_time"`
1346
+	CheckState           int64                          `gorm:"column:check_state" json:"check_state" form:"check_state"`
1347
+	Checker              int64                          `gorm:"column:checker" json:"checker" form:"checker"`
1348
+	StartTime            int64                          `gorm:"column:start_time" json:"start_time" form:"start_time"`
1349
+	TeamId               int64                          `gorm:"column:team_id" json:"team_id" form:"team_id"`
1350
+	FrequencyType        int64                          `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1351
+	DayCount             int64                          `gorm:"column:day_count" json:"day_count" form:"day_count"`
1352
+	WeekDay              string                         `gorm:"column:week_day" json:"week_day" form:"week_day"`
1353
+	ChildDoctorAdvice    []*BloodHisPrescriptionProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ProjectId" json:"child"`
1354
+	ExecutionFrequencyId int64                          `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
1353 1355
 }
1354 1356
 
1355 1357
 func (BloodHisPrescriptionProject) TableName() string {

+ 13 - 0
service/admin_service.go 查看文件

@@ -300,6 +300,19 @@ func GetAdminUserElectronicSignature(orgID int64, appID int64, userID int64) (*m
300 300
 	return &es, nil
301 301
 }
302 302
 
303
+func GetPatientSignature(orgID int64, patientid int64, dialysis_date int64) (*models.DialysisOrder, error) {
304
+	var es models.DialysisOrder
305
+	err := XTReadDB().Model(&models.DialysisOrder{}).Where("user_org_id=? and patient_id=? and dialysis_date=? and status=1", orgID, patientid, dialysis_date).First(&es).Error
306
+
307
+	if err == gorm.ErrRecordNotFound {
308
+		return nil, nil
309
+	}
310
+	if err != nil {
311
+		return nil, err
312
+	}
313
+	return &es, nil
314
+}
315
+
303 316
 func GetPatinentHead(orgid int64, appid int64, userid int64) (*models.SgjUserAdminPatientHead, error) {
304 317
 	var es models.SgjUserAdminPatientHead
305 318
 	err := readUserDb.Model(&models.SgjUserAdminPatientHead{}).Where("org_id = ? and app_id = ? and creator=? and status =1", orgid, appid, userid).First(&es).Error

+ 1 - 1
service/auto_create_week_schedules_service.go 查看文件

@@ -142,7 +142,7 @@ func _refreshWeekSchedulesWithTemplateItems(tx *gorm.DB, orgID int64, week time.
142 142
 
143 143
 	now := time.Now()
144 144
 	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&week)
145
-	disableErr := tx.Model(&models.Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date >= ? AND schedule_date <= ?", orgID, monday.Unix(), sunday.Unix()).Updates(map[string]interface{}{"status": 0, "mtime": now.Unix()}).Error
145
+	disableErr := tx.Model(&models.Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date >= ? AND schedule_date <= ?", orgID, monday.Unix(), sunday.Unix()).Updates(map[string]interface{}{"status": 0, "updated_time": now.Unix()}).Error
146 146
 	//fmt.Println("disableErr323232332323232233222332232332",disableErr)
147 147
 	if disableErr != nil {
148 148
 		return disableErr

+ 161 - 0
service/coordinate_service.go 查看文件

@@ -8,6 +8,7 @@ import (
8 8
 	"github.com/jinzhu/gorm"
9 9
 	"io/ioutil"
10 10
 	"net/http"
11
+	"time"
11 12
 )
12 13
 
13 14
 func SavePatientMessageInfo() (string, string) {
@@ -329,3 +330,163 @@ func GetHisOrderFour(patient_id string, infoSeq string, docId string) (order mod
329 330
 	}
330 331
 	return
331 332
 }
333
+
334
+func GetHisPatientForCoordinate(id_card_no string) (string, string) {
335
+
336
+	//input := make(map[string]interface{})
337
+	inputData := make(map[string]interface{})
338
+	inputData["idcard"] = id_card_no // 就诊凭证编号
339
+
340
+	var inputLog string
341
+	bytesData, err := json.Marshal(inputData)
342
+	inputLog = string(bytesData)
343
+	fmt.Println(string(bytesData))
344
+	if err != nil {
345
+		fmt.Println(err.Error())
346
+		return err.Error(), ""
347
+	}
348
+	reader := bytes.NewReader(bytesData)
349
+	var url string
350
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/getPatientType"
351
+	url = gdyb_url
352
+
353
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
354
+	request, err := http.NewRequest("GET", url, reader)
355
+	if err != nil {
356
+		fmt.Println(err.Error())
357
+		return err.Error(), ""
358
+	}
359
+
360
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
361
+	request.Header.Set("code", "Xmrjyy")
362
+
363
+	client := http.Client{}
364
+	resp, err := client.Do(request)
365
+	if err != nil {
366
+		fmt.Println(err.Error())
367
+		return err.Error(), ""
368
+	}
369
+	respBytes, err := ioutil.ReadAll(resp.Body)
370
+	if err != nil {
371
+		fmt.Println(err.Error())
372
+		return err.Error(), ""
373
+	}
374
+	fmt.Println(string(respBytes))
375
+	str := string(respBytes)
376
+	return str, inputLog
377
+
378
+}
379
+func UploadPrescriptionForCoordinate(info models.UploadInfo) (string, string) {
380
+
381
+	//input := make(map[string]interface{})
382
+	inputData := make(map[string]interface{})
383
+
384
+	diags := make([]map[string]interface{}, 0)
385
+	//diags := make([]map[string]interface{}, 0)
386
+
387
+	presInfos := make([]map[string]interface{}, 0)
388
+
389
+	for _, item := range info.Diag {
390
+		inputDataDiag := make(map[string]interface{})
391
+		inputDataDiag["vao06"] = item.Vao06
392
+		inputDataDiag["bak02"] = item.Bak02
393
+		diags = append(diags, inputDataDiag)
394
+	}
395
+
396
+	for _, item := range info.PresInfo {
397
+		inputDataPresInfo := make(map[string]interface{})
398
+		inputDataPresInfo["cbm06"] = item.Cbm06
399
+		inputDataPresInfo["cbm07"] = item.Cbm06
400
+		inputDataPresInfo["cbmid"] = item.Cbmid
401
+		presDetails := make([]map[string]interface{}, 0)
402
+
403
+		for _, subItem := range item.PresDetail {
404
+			inputDataPresDetail := make(map[string]interface{})
405
+			inputDataPresDetail["vaf59"] = subItem.Vaf59
406
+			Items := make([]map[string]interface{}, 0)
407
+			for _, subSubItem := range subItem.Item {
408
+				inputDataItem := make(map[string]interface{})
409
+				inputDataItem["bbx01"] = subSubItem.Bbx01
410
+				inputDataItem["bda01"] = subSubItem.Bda01
411
+				inputDataItem["bby01"] = subSubItem.Bby01
412
+				inputDataItem["bck01b"] = subSubItem.Bck01b
413
+				inputDataItem["bck01d"] = subSubItem.Bck01d
414
+				inputDataItem["bdi01"] = subSubItem.Bdi01
415
+				inputDataItem["rownr"] = subSubItem.Rownr
416
+				inputDataItem["vaf11"] = subSubItem.Vaf11
417
+				inputDataItem["vaf14"] = subSubItem.Vaf14
418
+				inputDataItem["vaf15"] = subSubItem.Vaf15
419
+				inputDataItem["vaf17"] = subSubItem.Vaf17
420
+				inputDataItem["vaf18"] = subSubItem.Vaf18
421
+				inputDataItem["vaf19"] = subSubItem.Vaf19
422
+				inputDataItem["vaf20"] = subSubItem.Vaf20
423
+				inputDataItem["vaf21"] = subSubItem.Vaf21
424
+				inputDataItem["vaf22"] = subSubItem.Vaf22
425
+				inputDataItem["vaf32"] = subSubItem.Vaf32
426
+				inputDataItem["vaf35"] = subSubItem.Vaf35
427
+				inputDataItem["vaf36"] = subSubItem.Vaf36
428
+				inputDataItem["vaf58"] = subSubItem.Vaf58
429
+				inputDataItem["vaf61"] = subSubItem.Vaf61
430
+				Items = append(Items, inputDataItem)
431
+
432
+			}
433
+			inputDataPresDetail["item"] = Items
434
+			presDetails = append(presDetails, inputDataPresDetail)
435
+		}
436
+		inputDataPresInfo["presDetail"] = presDetails
437
+		presInfos = append(presInfos, inputDataPresInfo)
438
+	}
439
+
440
+	inputData["vaa01"] = info.Vaa01   // 就诊凭证编号
441
+	inputData["Fasong"] = info.Fasong // 就诊凭证编号
442
+	inputData["vaa07"] = info.Vaa07   // 就诊凭证编号
443
+	inputData["bck01c"] = info.Bck01c // 就诊凭证编号
444
+	inputData["bce02a"] = "1001"      // 就诊凭证编号
445
+
446
+	inputData["diag"] = diags         // 就诊凭证编号
447
+	inputData["presInfo"] = presInfos // 就诊凭证编号
448
+
449
+	var inputLog string
450
+	bytesData, err := json.Marshal(inputData)
451
+	inputLog = string(bytesData)
452
+	fmt.Println(string(bytesData))
453
+	if err != nil {
454
+		fmt.Println(err.Error())
455
+		return err.Error(), ""
456
+	}
457
+	reader := bytes.NewReader(bytesData)
458
+	var url string
459
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/sendPretreat"
460
+	url = gdyb_url
461
+
462
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
463
+	request, err := http.NewRequest("POST", url, reader)
464
+	if err != nil {
465
+		fmt.Println(err.Error())
466
+		return err.Error(), ""
467
+	}
468
+
469
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
470
+	request.Header.Set("code", "Xmrjyy")
471
+
472
+	client := http.Client{}
473
+	resp, err := client.Do(request)
474
+	if err != nil {
475
+		fmt.Println(err.Error())
476
+		return err.Error(), ""
477
+	}
478
+	respBytes, err := ioutil.ReadAll(resp.Body)
479
+	if err != nil {
480
+		fmt.Println(err.Error())
481
+		return err.Error(), ""
482
+	}
483
+	fmt.Println(string(respBytes))
484
+	str := string(respBytes)
485
+	return str, inputLog
486
+
487
+}
488
+
489
+func UpDatePrescriptionNumberForCoordinate(user_org_id int64, ids []int64, number string) (err error) {
490
+	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix(), "order_status": 6}).Error
491
+	return
492
+}

+ 7 - 2
service/data.go 查看文件

@@ -317,8 +317,8 @@ func BatchInspectionConfiguration(orgid int64) (err error) {
317 317
 	return
318 318
 }
319 319
 
320
-func ShowFiledConfig(org_id int64, isShow int, id int64) (err error) {
321
-	err = readDb.Model(&models.FiledConfig{}).Where("org_id = ? AND id = ?", org_id, id).Updates(map[string]interface{}{"create_time": time.Now().Unix(), "update_time": time.Now().Unix(), "is_show": isShow}).Error
320
+func ShowFiledConfig(org_id int64, isShow int, is_write int, id int64) (err error) {
321
+	err = readDb.Model(&models.FiledConfig{}).Where("org_id = ? AND id = ?", org_id, id).Updates(map[string]interface{}{"create_time": time.Now().Unix(), "update_time": time.Now().Unix(), "is_show": isShow, "is_write": is_write}).Error
322 322
 	return
323 323
 }
324 324
 
@@ -343,3 +343,8 @@ func CreateContinueSchedule(schedule *models.ContinueSchedule) error {
343 343
 	err := writeDb.Model(&schedule).Create(&schedule).Error
344 344
 	return err
345 345
 }
346
+
347
+func GetExecutionFrequencyByName(name string, org_id int64) (ef models.ExecutionFrequencyDic, err error) {
348
+	err = readDb.Model(&models.ExecutionFrequencyDic{}).Where("org_id = ? AND name = ?", org_id, name).First(&ef).Error
349
+	return
350
+}

+ 14 - 2
service/dialysis_service.go 查看文件

@@ -131,7 +131,7 @@ func GetTotalDialysisCout(orgid int64, patientid int64) (order []*models.Dialysi
131 131
 //临时医嘱
132 132
 func FindDoctorAdviceOrderById(orgID int64, patientsId int64, recordDate int64) (patient []*models.DoctorAdvice, err error) {
133 133
 	err = readDb.Model(&models.DoctorAdvice{}).
134
-		Where("patient_id = ? and user_org_id=? and status=1 and record_date = ? and advice_type = 2", patientsId, orgID, recordDate).
134
+		Where("patient_id = ? and user_org_id=? and status=1 and advice_date = ? and advice_type = 2", patientsId, orgID, recordDate).
135 135
 		Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno, IF(parent_id > 0, parent_id, id) as advice_order").Order("start_time asc, groupno desc, advice_order desc, id asc").
136 136
 		Find(&patient).Error
137 137
 	return
@@ -1304,7 +1304,7 @@ func UpdateAssessmentAfterDate(patient_id int64, org_id int64, date int64, actua
1304 1304
 	err = writeDb.Model(&models.AssessmentAfterDislysis{}).Where("status =1 AND user_org_id = ? AND patient_id = ? AND assessment_date = ?", org_id, patient_id, date).Updates(map[string]interface{}{"actual_treatment_hour": actual_treatment_hour, "actual_treatment_minute": actual_treatment_minute}).Error
1305 1305
 	return
1306 1306
 }
1307
-func UpdateAssessmentAfterDateOne(patient_id int64, org_id int64, date int64, actual_treatment_hour int64, actual_treatment_minute int64, BreathingRate float64) (err error) {
1307
+func UpdateAssessmentAfterDateOne(patient_id int64, org_id int64, date int64, actual_treatment_hour int64, actual_treatment_minute int64, BreathingRate string) (err error) {
1308 1308
 	err = writeDb.Model(&models.AssessmentAfterDislysis{}).Where("status =1 AND user_org_id = ? AND patient_id = ? AND assessment_date = ?", org_id, patient_id, date).Updates(map[string]interface{}{"actual_treatment_hour": actual_treatment_hour, "actual_treatment_minute": actual_treatment_minute, "breathing_rate": BreathingRate}).Error
1309 1309
 	return
1310 1310
 }
@@ -1786,3 +1786,15 @@ func GetOrgFollowIsExist(orgid int64) (*models.SgjOrgFollowOne, error) {
1786 1786
 	}
1787 1787
 	return &follow, nil
1788 1788
 }
1789
+
1790
+func UpdatePatientSign(patient_id int64, dialysis_date int64, order models.DialysisOrder, orgid int64) error {
1791
+
1792
+	err := XTWriteDB().Model(&order).Where("patient_id = ? and dialysis_date= ? and status = 1 and user_org_id = ?", patient_id, dialysis_date, orgid).Update(map[string]interface{}{"url": order.Url, "hash": order.Hash}).Error
1793
+	return err
1794
+}
1795
+
1796
+func GetPatientSign(patient_id int64, dialysis_date int64, orgid int64) (models.DialysisOrder, error) {
1797
+	order := models.DialysisOrder{}
1798
+	err := XTReadDB().Where("patient_id=? and dialysis_date = ? and user_org_id = ? and status = 1", patient_id, dialysis_date, orgid).Find(&order).Error
1799
+	return order, err
1800
+}

+ 822 - 0
service/his_config_service.go 查看文件

@@ -1,7 +1,15 @@
1 1
 package service
2 2
 
3 3
 import (
4
+	"XT_New/enums"
4 5
 	"XT_New/models"
6
+	"XT_New/utils"
7
+	"fmt"
8
+	"github.com/astaxie/beego/config"
9
+	"golang.org/x/sync/errgroup"
10
+
11
+	"reflect"
12
+	"strconv"
5 13
 	"time"
6 14
 )
7 15
 
@@ -56,3 +64,817 @@ func DelelteHisPrescriptionProjectTemplate(id int64, user_org_id int64) (err err
56 64
 
57 65
 	return
58 66
 }
67
+
68
+//封装保存接口
69
+func FenCreatePrescriptionTemplate(id, mode_id, types, patient_id int64, name string, adminInfo *AdminUserInfo, dataBody map[string]interface{}) (err error) {
70
+	tmp_bool_id := IsDialysisMode(adminInfo.CurrentOrgId, patient_id, mode_id)
71
+
72
+	var src_template models.HisPrescriptionTemplate
73
+	if !tmp_bool_id {
74
+		template := models.HisPrescriptionTemplate{
75
+			UserOrgId: adminInfo.CurrentOrgId,
76
+			PatientId: patient_id,
77
+			Type:      types,
78
+			Status:    1,
79
+			Ctime:     time.Now().Unix(),
80
+			Mtime:     time.Now().Unix(),
81
+			Name:      name,
82
+			Mode:      mode_id,
83
+		}
84
+		src_template = template
85
+		CreateHisPrescriptionTemplate(&src_template)
86
+	} else {
87
+		//查询出该模板的id
88
+		err = XTReadDB().Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? and patient_id = ? and status = 1 and mode = ?", adminInfo.CurrentOrgId, patient_id, mode_id).Find(&src_template).Error
89
+		if err != nil {
90
+			return
91
+		}
92
+		src_template.Name = name
93
+		src_template.Mode = mode_id
94
+		SaveHisPrescriptionTemplate(&src_template)
95
+	}
96
+
97
+	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
98
+		prescriptions, _ := dataBody["prescriptions"].([]interface{})
99
+		if len(prescriptions) > 0 {
100
+			for _, item := range prescriptions {
101
+				items := item.(map[string]interface{})
102
+
103
+				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
104
+					utils.ErrorLog("id")
105
+					//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
106
+					err = fmt.Errorf("参数错误")
107
+					return
108
+				}
109
+
110
+				id := int64(items["id"].(float64))
111
+
112
+				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
113
+					utils.ErrorLog("type")
114
+					//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
115
+					err = fmt.Errorf("参数错误")
116
+					return
117
+				}
118
+				types := int64(items["type"].(float64))
119
+
120
+				if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
121
+					utils.ErrorLog("med_type")
122
+					//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
123
+					err = fmt.Errorf("参数错误")
124
+					return
125
+				}
126
+				med_type := strconv.Itoa(int(items["med_type"].(float64)))
127
+
128
+				ctime := time.Now().Unix()
129
+				prescription := &models.HisPrescriptionInfoTemplate{
130
+					ID:          id,
131
+					PatientId:   patient_id,
132
+					UserOrgId:   adminInfo.CurrentOrgId,
133
+					Ctime:       ctime,
134
+					Mtime:       ctime,
135
+					Type:        types,
136
+					Modifier:    adminInfo.AdminUser.Id,
137
+					Creator:     adminInfo.AdminUser.Id,
138
+					Status:      1,
139
+					PTemplateId: src_template.ID,
140
+					MedType:     med_type,
141
+				}
142
+				CreateHisPrescriptionInfoTemplate(prescription)
143
+
144
+				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
145
+					advices := items["advices"].([]interface{})
146
+					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
147
+					groupNo := int64(0)
148
+					ctime := time.Now().Unix()
149
+					mtime := ctime
150
+					if len(advices) > 0 {
151
+						for _, advice := range advices {
152
+							var s models.HisPrescriptionAdviceTemplate
153
+							s.PrescriptionId = prescription.ID
154
+							s.AdviceType = 2
155
+							s.StopState = 2
156
+							s.ExecutionState = 2
157
+							s.Status = 1
158
+							s.UserOrgId = adminInfo.CurrentOrgId
159
+							s.Groupno = groupNo
160
+							s.CreatedTime = ctime
161
+							s.UpdatedTime = mtime
162
+							s.PatientId = patient_id
163
+							errcode := FensetAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
164
+							if errcode > 0 {
165
+								//c.ServeFailJSONWithSGJErrorCode(errcode)
166
+								err = fmt.Errorf("参数错误")
167
+								return
168
+							}
169
+							CreateHisPrescriptionAdviceTemplate(&s)
170
+						}
171
+					}
172
+				}
173
+				if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
174
+					projects := items["project"].([]interface{})
175
+					if len(projects) > 0 {
176
+						for _, project := range projects {
177
+							var p models.HisPrescriptionProjectTemplate
178
+							p.PrescriptionId = prescription.ID
179
+							p.Ctime = time.Now().Unix()
180
+							p.Mtime = time.Now().Unix()
181
+							p.PatientId = patient_id
182
+							p.UserOrgId = adminInfo.CurrentOrgId
183
+							p.Status = 1
184
+							errcode := FensetProjectTemplateWithJSON(&p, project.(map[string]interface{}))
185
+							if errcode > 0 {
186
+								//c.ServeFailJSONWithSGJErrorCode(errcode)
187
+								err = fmt.Errorf("参数错误")
188
+								return
189
+							}
190
+							CreateHisPrescriptionProjectTemplate(&p)
191
+
192
+						}
193
+					}
194
+				}
195
+			}
196
+			return nil
197
+		}
198
+	}
199
+	return
200
+}
201
+
202
+//复制一个setProjectTemplateWithJSON接口
203
+func FensetProjectTemplateWithJSON(project *models.HisPrescriptionProjectTemplate, json map[string]interface{}) int {
204
+	if json["id"] != nil {
205
+		id := json["id"].(string)
206
+		if id != "" {
207
+			tmpPid := id[1:]
208
+			project_id, _ := strconv.ParseInt(tmpPid, 10, 64)
209
+			if id[0] == 112 {
210
+				project.Type = 2
211
+			}
212
+			if id[0] == 105 {
213
+				project.Type = 3
214
+			}
215
+			project.ProjectId = project_id
216
+		} else {
217
+			project.ProjectId = int64(0)
218
+		}
219
+
220
+	}
221
+	if json["frequency_type"] != nil && reflect.TypeOf(json["frequency_type"]).String() == "string" {
222
+		tmp_drugid := json["frequency_type"].(string)
223
+		frequency_type, _ := strconv.ParseInt(tmp_drugid, 10, 64)
224
+		project.FrequencyType = frequency_type
225
+	}
226
+	if json["frequency_type"] != nil && reflect.TypeOf(json["frequency_type"]).String() == "float64" {
227
+		frequency_type := int64(json["frequency_type"].(float64))
228
+		project.FrequencyType = frequency_type
229
+	}
230
+
231
+	if json["day_count"] != nil && reflect.TypeOf(json["day_count"]).String() == "string" {
232
+		tmp_drugid := json["day_count"].(string)
233
+		day_count, _ := strconv.ParseInt(tmp_drugid, 10, 64)
234
+		project.DayCount = day_count
235
+	}
236
+	if json["day_count"] != nil && reflect.TypeOf(json["day_count"]).String() == "float64" {
237
+		day_count := int64(json["day_count"].(float64))
238
+		project.DayCount = day_count
239
+	}
240
+
241
+	if json["week_day"] != nil && reflect.TypeOf(json["week_day"]).String() == "string" {
242
+		week_day, _ := json["week_day"].(string)
243
+		project.WeekDay = week_day
244
+	}
245
+	if json["week_day"] != nil && reflect.TypeOf(json["week_day"]).String() == "float64" {
246
+		week_day := config.ToString(json["week_day"].(float64))
247
+		project.WeekDay = week_day
248
+	}
249
+
250
+	//if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
251
+	//	types := int64(json["type"].(float64))
252
+	//	project.Type = types
253
+	//}
254
+	//if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
255
+	//	project_id := int64(json["project_id"].(float64))
256
+	//	project.ProjectId = project_id
257
+	//}
258
+	if json["price"] != nil && reflect.TypeOf(json["price"]).String() == "string" {
259
+		price, _ := strconv.ParseFloat(json["price"].(string), 64)
260
+		project.Price = price
261
+	}
262
+
263
+	if json["price"] != nil && reflect.TypeOf(json["price"]).String() == "float64" {
264
+		price := json["price"].(float64)
265
+		project.Price = price
266
+	}
267
+
268
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
269
+		total, _ := json["prescribing_number"].(string)
270
+		//totals, _ := strconv.ParseInt(total, 10, 64)
271
+		project.Count = total
272
+	}
273
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "float64" {
274
+		total := config.ToString(json["prescribing_number"].(float64))
275
+		//totals, _ := strconv.ParseInt(total, 10, 64)
276
+		project.Count = total
277
+	}
278
+
279
+	//if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
280
+	//	medical_code, _ := json["medical_code"].(string)
281
+	//	project.MedListCodg = medical_code
282
+	//}
283
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
284
+		single_dose, _ := json["single_dose"].(string)
285
+		project.SingleDose = single_dose
286
+	}
287
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "float64" {
288
+		single_dose := config.ToString(json["single_dose"].(float64))
289
+		project.SingleDose = single_dose
290
+	}
291
+
292
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
293
+		delivery_way, _ := json["delivery_way"].(string)
294
+		project.DeliveryWay = delivery_way
295
+	}
296
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
297
+		execution_frequency, _ := json["execution_frequency"].(string)
298
+		project.ExecutionFrequency = execution_frequency
299
+	}
300
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
301
+		remark, _ := json["remark"].(string)
302
+		project.Remark = remark
303
+	}
304
+	if json["day"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
305
+		day, _ := json["number_days"].(string)
306
+		project.Day = day
307
+	}
308
+	if json["day"] != nil && reflect.TypeOf(json["remark"]).String() == "float64" {
309
+		day := config.ToString(json["number_days"].(float64))
310
+		project.Day = day
311
+	}
312
+
313
+	if json["unit"] != nil && reflect.TypeOf(json["unit"]).String() == "string" {
314
+		unit, _ := json["unit"].(string)
315
+		project.Unit = unit
316
+	}
317
+	return 0
318
+}
319
+
320
+//复制一个setAdviceTemplateWithJSON接口
321
+func FensetAdviceTemplateWithJSON(advice *models.HisPrescriptionAdviceTemplate, json map[string]interface{}) int {
322
+	//if json["advice_id"] != nil || reflect.TypeOf(json["advice_id"]).String() == "float64" {
323
+	//	advice_id := int64(json["advice_id"].(float64))
324
+	//	advice.ID = advice_id
325
+	//}
326
+
327
+	if json["drug_name"] == nil {
328
+		utils.ErrorLog("drug_name")
329
+		return enums.ErrorCodeParamWrong
330
+	}
331
+	var tmpdrugid int64
332
+	if json["drug_name"] != nil && reflect.TypeOf(json["drug_name"]).String() == "string" {
333
+		tmpdrugid, _ = strconv.ParseInt(json["drug_name"].(string), 10, 64)
334
+	}
335
+	if json["drug_name"] != nil && reflect.TypeOf(json["drug_name"]).String() == "float64" {
336
+		tmpdrugid = int64(json["drug_name"].(float64))
337
+	}
338
+
339
+	advice.AdviceName = FindDrugsName(tmpdrugid)
340
+	//adviceDesc, _ := json["advice_desc"].(string)
341
+	//advice.AdviceDesc = adviceDesc
342
+	//if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
343
+	//	drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
344
+	//	advice.DrugSpec = drugSpec
345
+	//}
346
+
347
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
348
+		remark, _ := json["remark"].(string)
349
+		advice.Remark = remark
350
+	}
351
+
352
+	if json["id"] == nil {
353
+		advice.DrugId = 0
354
+	} else {
355
+		if json["id"] != nil && reflect.TypeOf(json["id"]).String() == "string" {
356
+			tmp_drugid := json["id"].(string)
357
+			drug_id, _ := strconv.ParseInt(tmp_drugid, 10, 64)
358
+			advice.DrugId = drug_id
359
+		}
360
+		if json["id"] != nil && reflect.TypeOf(json["id"]).String() == "float64" {
361
+			drug_id := int64(json["id"].(float64))
362
+			advice.DrugId = drug_id
363
+		}
364
+	}
365
+
366
+	//if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
367
+	//	drugSpecUnit, _ := json["min_unit"].(string)
368
+	//	advice.DrugSpecUnit = drugSpecUnit
369
+	//}
370
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
371
+		singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
372
+		advice.SingleDose = singleDose
373
+	}
374
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "float64" {
375
+		singleDose := json["single_dose"].(float64)
376
+		advice.SingleDose = singleDose
377
+	}
378
+	if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
379
+		singleDoseUnit, _ := json["single_dose_unit"].(string)
380
+		advice.SingleDoseUnit = singleDoseUnit
381
+	}
382
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
383
+		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
384
+		advice.PrescribingNumber = prescribingNumber
385
+	}
386
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "float64" {
387
+		prescribingNumber := json["prescribing_number"].(float64)
388
+		advice.PrescribingNumber = prescribingNumber
389
+	}
390
+	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
391
+		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
392
+		advice.PrescribingNumberUnit = prescribingNumberUnit
393
+	}
394
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
395
+		deliveryWay, _ := json["delivery_way"].(string)
396
+		advice.DeliveryWay = deliveryWay
397
+	}
398
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
399
+		executionFrequency, _ := json["execution_frequency"].(string)
400
+		advice.ExecutionFrequency = executionFrequency
401
+	}
402
+	fmt.Println("44444444444")
403
+	if json["price"] != nil && reflect.TypeOf(json["price"]).String() == "string" {
404
+		price, _ := strconv.ParseFloat(json["price"].(string), 64)
405
+		advice.Price = price
406
+	}
407
+	if json["price"] != nil && reflect.TypeOf(json["price"]).String() == "float64" {
408
+		price := json["price"].(float64)
409
+		advice.Price = price
410
+	}
411
+	//if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
412
+	//	med_list_codg, _ := json["medical_insurance_number"].(string)
413
+	//	advice.MedListCodg = med_list_codg
414
+	//}
415
+	//fmt.Println("333333333")
416
+	if json["day"] != nil && reflect.TypeOf(json["day"]).String() == "string" {
417
+		day, _ := strconv.ParseInt(json["day"].(string), 10, 64)
418
+		advice.Day = day
419
+	}
420
+	if json["day"] != nil && reflect.TypeOf(json["day"]).String() == "float64" {
421
+		day := int64(json["day"].(float64))
422
+		advice.Day = day
423
+	}
424
+	//if json["groupno"] != nil || reflect.TypeOf(json["groupno"]).String() == "float64" {
425
+	//	groupno := int64(json["groupno"].(float64))
426
+	//	advice.Groupno = groupno
427
+	//}
428
+
429
+	//if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {//原型图没画不考虑
430
+	//	frequency_type := int64(json["frequency_type"].(float64))
431
+	//	advice.FrequencyType = frequency_type
432
+	//}
433
+	//
434
+	//if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
435
+	//	day_count := int64(json["day_count"].(float64))
436
+	//	advice.DayCount = day_count
437
+	//}
438
+	//
439
+	//if json["week_day"] != nil || reflect.TypeOf(json["week_day"]).String() == "string" {
440
+	//	week_day, _ := json["week_day"].(string)
441
+	//	advice.WeekDay = week_day
442
+	//}
443
+	//fmt.Println("aaaaaaaaaaaaaaaaaaaaaaaaa")
444
+	return 0
445
+}
446
+
447
+//判断该患者是否有该透析模式
448
+func IsDialysisMode(orgid, patient_id, mode int64) bool {
449
+	var total int
450
+	XTReadDB().Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? and patient_id = ? and status = 1 and mode = ?", orgid, patient_id, mode).Count(&total)
451
+	if total > 0 {
452
+		return true
453
+	} else {
454
+		return false
455
+	}
456
+}
457
+
458
+//获取该透析模式的患者列表
459
+func GetDialysisModePatient(orgid, model int64) (list []*models.DialysisPatient, err error) {
460
+	var tmp []*models.DialysisPatient
461
+	err = XTReadDB().Raw("select id,name from xt_patients,(SELECT patient_id FROM his_prescription_template WHERE user_org_id = ? and "+
462
+		"mode = ? and status = 1)a where id = a.patient_id", orgid, model).Scan(&tmp).Error
463
+	if err != nil {
464
+		return
465
+	}
466
+	return tmp, err
467
+}
468
+
469
+//如果没有名字默认透析模式
470
+func DialysisModeName(mode int64) string {
471
+	tmp := make(map[int64]string)
472
+	tmp[1] = "HD"
473
+	tmp[2] = "HDF"
474
+	tmp[3] = "HD+HP"
475
+	tmp[4] = "HP"
476
+	tmp[5] = "HF"
477
+	tmp[6] = "SCUF"
478
+	tmp[7] = "IUF"
479
+	tmp[8] = "HFHD"
480
+	tmp[9] = "HFHD+HP"
481
+	tmp[10] = "PHF"
482
+	tmp[11] = "HFR"
483
+	tmp[12] = "HDF+HP"
484
+	tmp[13] = "CRRT"
485
+	tmp[14] = "腹水回输"
486
+	//tmp[15] = "HD前置换"
487
+	//tmp[16] = "HD后置换"
488
+	//tmp[17] = "HDF前置换"
489
+	//tmp[18] = "HDF后置换"
490
+	tmp[19] = "IUF+HD"
491
+	tmp[20] = "UF"
492
+	tmp[21] = "HD+"
493
+	tmp[22] = "血浆胆红素吸附+HDF"
494
+	tmp[23] = "血浆胆红素吸附"
495
+	tmp[24] = "I-HDF"
496
+	tmp[25] = "HD高通"
497
+	tmp[26] = "CVVH"
498
+	tmp[27] = "CVVHD"
499
+	tmp[28] = "CVVHDF"
500
+	tmp[29] = "PE"
501
+	tmp[30] = "血浆胆红素吸附+HP"
502
+	tmp[31] = "HPD"
503
+	tmp[32] = "HDP"
504
+	if v, ok := tmp[mode]; ok {
505
+		return v
506
+	}
507
+	return ""
508
+}
509
+
510
+//查询出该模板的id
511
+func IdOfTheTemplate(orgid, patient_id, mode_id int64) (src_template models.HisPrescriptionTemplate, err error) {
512
+	err = XTReadDB().Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? and "+
513
+		"patient_id = ? and status = 1 and mode = ?", orgid, patient_id, mode_id).Find(&src_template).Error
514
+	return src_template, err
515
+}
516
+
517
+//根据透析模式、患者姓名、药品项目获取处方内容
518
+func GetPrescriptionContent(mode, orgid, patient_id int64) (list []*models.HisPrescriptionInfoTemplate, err error) {
519
+	var tmp models.HisPrescriptionTemplate
520
+	err = XTReadDB().Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? and patient_id = ? and mode = ? and status = 1", orgid, patient_id, mode).Find(&tmp).Error
521
+	if err != nil {
522
+		return
523
+	}
524
+	var prescriptions []*models.HisPrescriptionInfoTemplate
525
+	prescriptions, err = GetHisPrescriptionTemplate(tmp.ID, orgid)
526
+	return prescriptions, err
527
+
528
+}
529
+
530
+//获取该透析模式患者列表(批量删除时用)药品
531
+func GetDialysisDrugDelect(orgid, model, drug_id int64) (list []*models.DialysisPatient, err error) {
532
+	var tmp []*models.DialysisPatient
533
+	err = XTReadDB().Raw("select id,name from xt_patients,("+
534
+		"select distinct patient_id from his_prescription_advice_template,("+
535
+		"select his_prescription_info_template.id from his_prescription_info_template,("+
536
+		"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
537
+		")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
538
+		")hisa where status = 1 and prescription_id = hisa.id and drug_id = ?)a where id = a.patient_id", orgid, model, drug_id).Scan(&tmp).Error
539
+	if err != nil {
540
+		return
541
+	}
542
+	return tmp, err
543
+}
544
+
545
+//获取该透析模式患者列表(批量删除时用)项目
546
+func GetDialysisProjectDelect2(orgid, model, drug_id int64) (list []*models.DialysisPatient, err error) {
547
+	var tmp []*models.DialysisPatient
548
+	err = XTReadDB().Raw("select id,name from xt_patients,("+
549
+		"select distinct patient_id from his_prescription_project_template,("+
550
+		"select his_prescription_info_template.id from his_prescription_info_template,("+
551
+		"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
552
+		")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
553
+		")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 2)a where id = a.patient_id", orgid, model, drug_id).Scan(&tmp).Error
554
+	if err != nil {
555
+		return
556
+	}
557
+	return tmp, err
558
+}
559
+
560
+//获取该透析模式患者列表(批量删除时用)耗材
561
+func GetDialysisProjectDelect3(orgid, model, drug_id int64) (list []*models.DialysisPatient, err error) {
562
+	var tmp []*models.DialysisPatient
563
+	err = XTReadDB().Raw("select id,name from xt_patients,("+
564
+		"select distinct patient_id from his_prescription_project_template,("+
565
+		"select his_prescription_info_template.id from his_prescription_info_template,("+
566
+		"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
567
+		")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
568
+		")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 3)a where id = a.patient_id", orgid, model, drug_id).Scan(&tmp).Error
569
+	if err != nil {
570
+		return
571
+	}
572
+	return tmp, err
573
+}
574
+
575
+//根据透析模式删除药品
576
+func ModeDeleteDrug(orgid, model, drug_id int64, patient_id []int64) (err error) {
577
+	//开事务
578
+	tx := XTWriteDB().Begin()
579
+	defer func() {
580
+		if err != nil {
581
+			utils.ErrorLog("事务失败,原因为: %v", err)
582
+			tx.Rollback()
583
+		} else {
584
+			tx.Commit()
585
+		}
586
+	}()
587
+	var g errgroup.Group
588
+	var tmp []*models.DialysisPatient
589
+	err = tx.Raw("select his_prescription_advice_template.id from his_prescription_advice_template,("+
590
+		"select his_prescription_info_template.id from his_prescription_info_template,("+
591
+		"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
592
+		")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
593
+		")hisa where status = 1 and prescription_id = hisa.id and drug_id = ? and patient_id in (?)", orgid, model, drug_id, patient_id).Scan(&tmp).Error
594
+	for _, v := range tmp {
595
+		g.Go(func() error {
596
+			tmp := v
597
+			var err error
598
+			err = tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("id = ?", tmp.ID).Updates(map[string]interface{}{
599
+				"status":       0,
600
+				"updated_time": time.Now().Unix(),
601
+			}).Error
602
+			return err
603
+		})
604
+	}
605
+	if errs := g.Wait(); errs != nil {
606
+		err = errs
607
+		return
608
+	}
609
+	return
610
+}
611
+
612
+//根据透析模式删除项目和耗材
613
+func ModeDelectItemsAndConsumables(orgid, model int64, drug_id string, patient_id []int64) (err error) {
614
+	//开事务
615
+	tx := XTWriteDB().Begin()
616
+	defer func() {
617
+		if err != nil {
618
+			utils.ErrorLog("事务失败,原因为: %v", err)
619
+			tx.Rollback()
620
+		} else {
621
+			tx.Commit()
622
+		}
623
+	}()
624
+	front := drug_id[:1]
625
+	after := drug_id[1:]
626
+	project_id, _ := strconv.ParseInt(after, 10, 64)
627
+	var g errgroup.Group
628
+	var tmp []*models.DialysisPatient
629
+	if front == "p" {
630
+		err = tx.Raw("select his_prescription_project_template.id from his_prescription_project_template,("+
631
+			"select his_prescription_info_template.id from his_prescription_info_template,("+
632
+			"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
633
+			")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
634
+			")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 2 and patient_id in (?)", orgid, model, project_id, patient_id).Scan(&tmp).Error
635
+		if err != nil {
636
+			return
637
+		}
638
+	}
639
+	if front == "i" {
640
+		err = tx.Raw("select his_prescription_project_template.id from his_prescription_project_template,("+
641
+			"select his_prescription_info_template.id from his_prescription_info_template,("+
642
+			"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
643
+			")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
644
+			")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 3 and patient_id in (?)", orgid, model, project_id, patient_id).Scan(&tmp).Error
645
+		if err != nil {
646
+			return
647
+		}
648
+	}
649
+	for _, v := range tmp {
650
+		g.Go(func() error {
651
+			tmp := v
652
+			var err error
653
+			err = tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("id = ?", tmp.ID).Updates(map[string]interface{}{
654
+				"status": 0,
655
+				"mtime":  time.Now().Unix(),
656
+			}).Error
657
+			return err
658
+		})
659
+	}
660
+	if errs := g.Wait(); errs != nil {
661
+		err = errs
662
+		return
663
+	}
664
+	return
665
+}
666
+
667
+//替换该透析模式药品
668
+func ReplaceDrug(orgid, model, drug_id int64, patient_id []int64, advice models.HisPrescriptionAdviceTemplate) (err error) {
669
+	//开事务
670
+	tx := XTWriteDB().Begin()
671
+	defer func() {
672
+		if err != nil {
673
+			utils.ErrorLog("事务失败,原因为: %v", err)
674
+			tx.Rollback()
675
+		} else {
676
+			tx.Commit()
677
+		}
678
+	}()
679
+	var g errgroup.Group
680
+	var tmp []*models.DialysisPatient
681
+	err = tx.Raw("select his_prescription_advice_template.id from his_prescription_advice_template,("+
682
+		"select his_prescription_info_template.id from his_prescription_info_template,("+
683
+		"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
684
+		")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
685
+		")hisa where status = 1 and prescription_id = hisa.id and drug_id = ? and patient_id in (?)", orgid, model, drug_id, patient_id).Scan(&tmp).Error
686
+	for _, v := range tmp {
687
+		g.Go(func() error {
688
+			tmp := v
689
+			var err error
690
+			err = tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("id = ?", tmp.ID).Updates(map[string]interface{}{
691
+				"drug_id":                 advice.DrugId,
692
+				"single_dose":             advice.SingleDose,
693
+				"single_dose_unit":        advice.SingleDoseUnit,
694
+				"delivery_way":            advice.DeliveryWay,
695
+				"execution_frequency":     advice.ExecutionFrequency,
696
+				"day":                     advice.Day,
697
+				"prescribing_number":      advice.PrescribingNumber,
698
+				"prescribing_number_unit": advice.PrescribingNumberUnit,
699
+				"price":                   advice.Price,
700
+				"remark":                  advice.Remark,
701
+				"updated_time":            time.Now().Unix(),
702
+			}).Error
703
+			return err
704
+		})
705
+	}
706
+	if errs := g.Wait(); errs != nil {
707
+		err = errs
708
+		return
709
+	}
710
+	return
711
+}
712
+
713
+//替换该透析模式耗材
714
+func ReplaceItemsAndConsumables(orgid, model int64, drug_id string, patient_id []int64, project models.HisPrescriptionProjectTemplate) (err error) {
715
+	//开事务
716
+	tx := XTWriteDB().Begin()
717
+	defer func() {
718
+		if err != nil {
719
+			utils.ErrorLog("事务失败,原因为: %v", err)
720
+			tx.Rollback()
721
+		} else {
722
+			tx.Commit()
723
+		}
724
+	}()
725
+	front := drug_id[:1]
726
+	after := drug_id[1:]
727
+	project_id, _ := strconv.ParseInt(after, 10, 64)
728
+	var g errgroup.Group
729
+	var tmp []*models.DialysisPatient
730
+	if front == "p" {
731
+		project.Type = 2
732
+		err = tx.Raw("select his_prescription_project_template.id from his_prescription_project_template,("+
733
+			"select his_prescription_info_template.id from his_prescription_info_template,("+
734
+			"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
735
+			")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
736
+			")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 2 and patient_id in (?)", orgid, model, project_id, patient_id).Scan(&tmp).Error
737
+		if err != nil {
738
+			return
739
+		}
740
+	}
741
+	if front == "i" {
742
+		project.Type = 3
743
+		err = tx.Raw("select his_prescription_project_template.id from his_prescription_project_template,("+
744
+			"select his_prescription_info_template.id from his_prescription_info_template,("+
745
+			"SELECT id FROM his_prescription_template WHERE user_org_id = ? and mode = ? and status = 1"+
746
+			")his where status = 1 and his_prescription_info_template.p_template_id = his.id"+
747
+			")hisb where status = 1 and prescription_id = hisb.id and project_id = ? and type = 3 and patient_id in (?)", orgid, model, project_id, patient_id).Scan(&tmp).Error
748
+		if err != nil {
749
+			return
750
+		}
751
+	}
752
+	for _, v := range tmp {
753
+		g.Go(func() error {
754
+			tmp := v
755
+			var err error
756
+			err = tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("id = ?", tmp.ID).Updates(map[string]interface{}{
757
+				"single_dose":         project.SingleDose,
758
+				"delivery_way":        project.DeliveryWay,
759
+				"execution_frequency": project.ExecutionFrequency,
760
+				"day":                 project.Day,
761
+				"count":               project.Count,
762
+				"price":               project.Price,
763
+				"remark":              project.Remark,
764
+				"type":                project.Type,
765
+				"mtime":               time.Now().Unix(),
766
+			}).Error
767
+			return err
768
+		})
769
+	}
770
+	if errs := g.Wait(); errs != nil {
771
+		err = errs
772
+		return
773
+	}
774
+	return
775
+}
776
+
777
+//跟据id查询药品、项目、耗材、套餐
778
+func QueryFourTables(id string, orgid int64) (tmp interface{}, err error) {
779
+	if id[0] == 112 {
780
+		after := id[1:]
781
+		var project []*models.XtHisProjectL
782
+		err = XTReadDB().Model(&project).Where("id = ?", after).Find(&project).Error
783
+		if err != nil {
784
+			return nil, err
785
+		} else {
786
+			for i := 0; i < len(project); i++ {
787
+				project[i].Translate, err = TranslateZu(project[i].StatisticalClassification, orgid, "统计分类")
788
+				if err != nil {
789
+					return nil, err
790
+				}
791
+			}
792
+			return project, err
793
+		}
794
+
795
+	} else if id[0] == 105 {
796
+		after := id[1:]
797
+		var good []*models.GoodInfoL
798
+		err = XTReadDB().Model(&models.GoodInfoL{}).Where("id = ?", after).Find(&good).Error
799
+		if err != nil {
800
+			return nil, err
801
+		} else {
802
+			for i := 0; i < len(good); i++ {
803
+				good[i].Translate = "耗材"
804
+			}
805
+			return good, err
806
+		}
807
+
808
+	} else if id[0] == 104 {
809
+		after := id[1:]
810
+		var team []*models.XtHisProjectTeam
811
+		err = XTReadDB().Model(&models.XtHisProjectTeam{}).Where("id = ?", after).Find(&team).Error
812
+		if err != nil {
813
+			return nil, err
814
+		} else {
815
+			return team, err
816
+		}
817
+
818
+	} else {
819
+		var lib []*models.BaseDrugLibL
820
+		err = XTReadDB().Model(&models.BaseDrugLibL{}).Where("id = ?", id).Find(&lib).Error
821
+		if err != nil {
822
+			return nil, err
823
+		} else {
824
+			for i := 0; i < len(lib); i++ {
825
+				lib[i].SingleDoseUnit = TypeConversion02(config.ToString(lib[i].DrugDoseUnit))
826
+				if err != nil {
827
+					return nil, err
828
+				}
829
+				type m struct {
830
+					Name string `json:"name"`
831
+				}
832
+				newM := []m{
833
+					{
834
+						lib[i].DoseUnit, //计量单位
835
+					},
836
+					{
837
+						lib[i].MinUnit, //拆零单位
838
+					},
839
+				}
840
+				newN := []m{
841
+					{
842
+						lib[i].MinUnit,
843
+					},
844
+					{
845
+						lib[i].MaxUnit,
846
+					},
847
+				}
848
+				lib[i].List1 = newM
849
+				lib[i].List2 = newN
850
+			}
851
+			return lib, err
852
+		}
853
+	}
854
+}
855
+
856
+//获取机构项目中所用的组
857
+func GetDataConfig(orgid int64) (dataconfig []*models.DictDataconfig, err error) {
858
+	err = XTReadDB().Raw("select * from xt_drug_data_config where parent_id in "+
859
+		"(select id from xt_drug_data_config where name = \"统计分类\" and parent_id = 0) "+
860
+		"and status =1 and (org_id = ? or org_id = 0)", orgid).Scan(&dataconfig).Error
861
+	return
862
+}
863
+
864
+//翻译项目中的组
865
+func TranslateZu(sc, orgid int64, types string) (s string, err error) {
866
+	var dataconfig []*models.DictDataconfig
867
+	tmp := "select * from xt_drug_data_config where parent_id in (select id from xt_drug_data_config where name = \"" + types + "\" and parent_id = 0) and value = " + config.ToString(sc) + " and status = 1 and (org_id = " + config.ToString(orgid) + " or org_id = 0)"
868
+
869
+	err = XTReadDB().Raw(tmp).Scan(&dataconfig).Error
870
+	if err != nil {
871
+		return
872
+	}
873
+	if len(dataconfig) > 1 {
874
+		err = fmt.Errorf("sql数据异常:%v", tmp)
875
+	}
876
+	if len(dataconfig) == 0 {
877
+		return "", err
878
+	}
879
+	return dataconfig[0].Name, err
880
+}

+ 25 - 4
service/his_service.go 查看文件

@@ -125,6 +125,8 @@ type Patients struct {
125 125
 	Status       int64  `gorm:"column:status" json:"status" form:"status"`
126 126
 	IdCardNo     string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
127 127
 	ScheduleType int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
128
+	Phone        int64  `gorm:"column:phone" json:"phone" form:"phone"`
129
+	Gender       int64  `gorm:"column:gender" json:"gender" form:"gender"`
128 130
 
129 131
 	Schedule              Schedule              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"schedule"`
130 132
 	HisPatient            HisPatient            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_patient"`
@@ -1697,6 +1699,7 @@ type HisDoctorAdviceInfo struct {
1697 1699
 	Drug                 Drug                 `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
1698 1700
 	VMHisPrescriptionTwo VMHisPrescriptionTwo `gorm:"ForeignKey:ID;AssociationForeignKey:PrescriptionId" json:"prescription"`
1699 1701
 	IsMedicine           int64                `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
1702
+	ExecutionFrequencyId int64                `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
1700 1703
 }
1701 1704
 
1702 1705
 func (HisDoctorAdviceInfo) TableName() string {
@@ -1740,9 +1743,10 @@ type HisPrescriptionProject struct {
1740 1743
 	StartTime      int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
1741 1744
 	TeamId         int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
1742 1745
 
1743
-	FrequencyType int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1744
-	DayCount      int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
1745
-	WeekDay       string `gorm:"column:week_day" json:"week_day" form:"week_day"`
1746
+	FrequencyType        int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1747
+	DayCount             int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
1748
+	WeekDay              string `gorm:"column:week_day" json:"week_day" form:"week_day"`
1749
+	ExecutionFrequencyId int64  `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
1746 1750
 }
1747 1751
 
1748 1752
 func (HisPrescriptionProject) TableName() string {
@@ -2078,7 +2082,7 @@ func GetNewAllChargeHisPatientList(org_id int64, keywords string, record_date in
2078 2082
 	db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
2079 2083
 		return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", org_id, record_date).Preload("VMHisOrders", "user_org_id = ? AND status = 1 AND settle_accounts_date = ? ", org_id, record_date)
2080 2084
 	})
2081
-	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1 AND order_status <>", org_id, record_date)
2085
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1 AND order_status = 2", org_id, record_date)
2082 2086
 	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1", org_id, record_date).Find(&patients).Error
2083 2087
 
2084 2088
 	for _, item := range patients {
@@ -2207,6 +2211,20 @@ func GetHisPrescriptionTemplate(template_id int64, org_id int64) (prescription [
2207 2211
 	return
2208 2212
 }
2209 2213
 
2214
+//组
2215
+func GetHisPrescriptionTemplateL(template_id int64, org_id int64) (prescription []*models.HisPrescriptionInfoTemplateL, err error) {
2216
+	err = readDb.Model(&models.HisPrescriptionInfoTemplateL{}).
2217
+		Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
2218
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
2219
+		}).
2220
+		Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
2221
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisProject").Preload("GoodInfo", "status=1")
2222
+		}).
2223
+		Where("status = 1 AND p_template_id = ? ", template_id).
2224
+		Find(&prescription).Error
2225
+	return
2226
+}
2227
+
2210 2228
 func FindHisConsumablesByID(orgID int64, patient_id int64, recordDate int64, good_id int64) (consumables models.DialysisBeforePrepare, err error) {
2211 2229
 	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1 AND good_id = ?", orgID, patient_id, recordDate, good_id).First(&consumables).Error
2212 2230
 	return
@@ -2331,6 +2349,9 @@ func SaveHisOrder(his *models.HisOrder) (err error) {
2331 2349
 	err = writeDb.Save(&his).Error
2332 2350
 	return
2333 2351
 }
2352
+func UpdataHisPateintTwo(his *models.VMHisPatient) {
2353
+	writeDb.Save(&his)
2354
+}
2334 2355
 
2335 2356
 func GetPrescriptionByIds(ids []string, org_id int64) (prescription []*models.HisPrescription, err error) {
2336 2357
 	err = readDb.Model(&models.HisPrescription{}).

+ 30 - 10
service/mobile_dialysis_service.go 查看文件

@@ -314,14 +314,15 @@ func (VMDoctorAdvice) TableName() string {
314 314
 }
315 315
 
316 316
 type VMHisDoctorAdviceInfo struct {
317
-	ID             int64 `gorm:"column:id" json:"id" form:"id"`
318
-	UserOrgId      int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
319
-	PatientId      int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
320
-	HisPatientId   int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
321
-	ExecutionTime  int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
322
-	ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
323
-	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
324
-	IsMedicine     int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
317
+	ID                   int64 `gorm:"column:id" json:"id" form:"id"`
318
+	UserOrgId            int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
319
+	PatientId            int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
320
+	HisPatientId         int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
321
+	ExecutionTime        int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
322
+	ExecutionStaff       int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
323
+	ExecutionState       int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
324
+	IsMedicine           int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
325
+	ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
325 326
 }
326 327
 
327 328
 func (VMHisDoctorAdviceInfo) TableName() string {
@@ -626,6 +627,14 @@ func MobileGetPredialysisEvaluationOne(orgID int64, patientID int64, recordDate
626 627
 	return &record, nil
627 628
 }
628 629
 
630
+func MobileGetPredialysisEvaluationTwo(orgID int64, patientID int64, recordDate int64) (models.PredialysisEvaluation, error) {
631
+
632
+	var record models.PredialysisEvaluation
633
+	err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
634
+
635
+	return record, err
636
+}
637
+
629 638
 // 透前评估
630 639
 func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int64) (*models.PredialysisEvaluation, error) {
631 640
 
@@ -634,6 +643,7 @@ func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int
634 643
 	defer redis.Close()
635 644
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":assessment_before_dislysis"
636 645
 	assessment_before_dislysis_str, _ := redis.Get(key).Result()
646
+	redis.Set(key, "", time.Second)
637 647
 	if len(assessment_before_dislysis_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
638 648
 		err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
639 649
 		if err != nil {
@@ -751,10 +761,11 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
751 761
 
752 762
 	// cur_date := time.Now().Format("2006-01-02")
753 763
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":doctor_advices"
754
-
764
+	fmt.Println("key23233232323323wi", key)
755 765
 	doctor_advices_str, _ := redis.Get(key).Result()
756
-
766
+	redis.Set(doctor_advices_str, "", time.Second)
757 767
 	if len(doctor_advices_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
768
+
758 769
 		err := readDb.Model(&models.DoctorAdvice{}).
759 770
 			Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and (advice_type = 2 || advice_type = 3)", patientID, orgID, recordDate).
760 771
 			Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno,way,drug_id,is_medicine,drug_name_id, IF(parent_id > 0, parent_id, id) as advice_order").
@@ -901,6 +912,7 @@ func MobileGetMonitorRecords(orgID int64, patientID int64, recordDate int64) ([]
901 912
 
902 913
 	// cur_date := time.Now().Format("2006-01-02")
903 914
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":monitor_records"
915
+	redis.Set(key, "", time.Second)
904 916
 	monitor_records_str, _ := redis.Get(key).Result()
905 917
 
906 918
 	if len(monitor_records_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -2949,6 +2961,14 @@ func GetLastDialysisPrescriptionByPatientId(orgid int64, patientid int64, record
2949 2961
 	return &prescription, nil
2950 2962
 }
2951 2963
 
2964
+func GetLastDialysisPrescriptionByPatientIdTwo(orgid int64, patientid int64, recorddate int64) (models.DialysisPrescription, error) {
2965
+
2966
+	prescription := models.DialysisPrescription{}
2967
+	err := readDb.Model(&models.DialysisPrescription{}).Where("user_org_id = ? and patient_id = ? and record_date = ? and status = 1", orgid, patientid, recorddate).Find(&prescription).Error
2968
+
2969
+	return prescription, err
2970
+}
2971
+
2952 2972
 type HisMScheduleDoctorAdviceVM struct {
2953 2973
 	ID                     int64                            `gorm:"column:id" json:"id"`
2954 2974
 	UserOrgId              int64                            `gorm:"column:user_org_id" json:"user_org_id"`

+ 3 - 3
service/patient_service.go 查看文件

@@ -74,7 +74,7 @@ func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bind
74 74
 //GetAllPatientList 返回全部患者的列表
75 75
 func GetAllPatientList(orgID int64) (patients []*models.Patients, total int64, err error) {
76 76
 
77
-	db := readDb.Table("xt_patients as p").Where("p.user_org_id=? and p.status=1 and p.lapseto = 1", orgID)
77
+	db := readDb.Table("xt_patients as p").Where("p.user_org_id=? and p.status=1", orgID)
78 78
 
79 79
 	err = db.Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time").Count(&total).Find(&patients).Error
80 80
 	return
@@ -129,7 +129,7 @@ func GetAllPatientListByList(orgID int64) (patients []*models.MSchedualPatientLi
129 129
 
130 130
 func GetAllDevicetByListSix(orgID int64) (devices []*models.MDeviceNumberForList, err error) {
131 131
 
132
-	err = readDb.Model(&models.MDeviceNumberForList{}).Preload("Zone", "status = 1 AND org_id = ?", orgID).Where("org_id=? and status=1 ", orgID).Find(&devices).Error
132
+	err = readDb.Model(&models.MDeviceNumberForList{}).Preload("Zone", "status = 1 AND org_id = ?", orgID).Where("org_id=?", orgID).Find(&devices).Error
133 133
 	return devices, err
134 134
 }
135 135
 
@@ -572,7 +572,7 @@ func FindPatientWithDeviceByNo(orgID int64, no string, time int64) (patient mode
572 572
 		return db.Preload("DeviceNumber", "org_id = ?", orgID).
573 573
 			Preload("DeviceZone", "org_id = ?", orgID).
574 574
 			Where("user_org_id = ? AND schedule_date = ? ", orgID, time)
575
-	}).Preload("InfectiousDiseases", "status = 1").Where("user_org_id=? and dialysis_no = ? and status=1 and lapseto =1", orgID, no).First(&patient).Error
575
+	}).Preload("InfectiousDiseases", "status = 1").Where("user_org_id=? and dialysis_no = ? and status = 1", orgID, no).First(&patient).Error
576 576
 	return
577 577
 }
578 578
 

+ 590 - 1
service/pharmacy_service.go 查看文件

@@ -8,9 +8,11 @@ import (
8 8
 	"github.com/astaxie/beego/config"
9 9
 	"github.com/astaxie/beego/context"
10 10
 	"github.com/jinzhu/gorm"
11
+	"golang.org/x/sync/errgroup"
11 12
 	"math"
12 13
 	"strconv"
13 14
 	"strings"
15
+	"sync"
14 16
 	"time"
15 17
 )
16 18
 
@@ -527,6 +529,7 @@ func FindMedicationList(orgid, drug_id, stime, etime, is_medicine int64) (pp []*
527 529
 		pp = append(pp, &models.PatientInformation{
528 530
 			Id:           "h" + config.ToString(v.ID),
529 531
 			Name:         FindUserName(v.PatientId),
532
+			PatientId:    v.PatientId,
530 533
 			SingleDosage: config.ToString(v.SingleDose) + v.SingleDoseUnit,
531 534
 			Usage:        v.DeliveryWay,
532 535
 			Frequency:    v.ExecutionFrequency,
@@ -534,6 +537,8 @@ func FindMedicationList(orgid, drug_id, stime, etime, is_medicine int64) (pp []*
534 537
 			Total:        config.ToString(v.PrescribingNumber) + v.PrescribingNumberUnit,
535 538
 			DataSources:  "his处方",
536 539
 			People:       GetUserAdminName(v.People, orgid), //领药人!!!!!!!!!!!!!!!!!!!!!!
540
+			Quantity:     int64(v.PrescribingNumber),
541
+			Unit:         v.PrescribingNumberUnit,
537 542
 		})
538 543
 	}
539 544
 
@@ -554,6 +559,8 @@ func FindMedicationList(orgid, drug_id, stime, etime, is_medicine int64) (pp []*
554 559
 			Total:        config.ToString(v.PrescribingNumber) + v.PrescribingNumberUnit,
555 560
 			DataSources:  "临时医嘱",
556 561
 			People:       GetUserAdminName(v.People, orgid), //领药人
562
+			Quantity:     int64(v.PrescribingNumber),
563
+			Unit:         v.PrescribingNumberUnit,
557 564
 		})
558 565
 	}
559 566
 	return
@@ -980,7 +987,7 @@ func GetUserAdminName(id, orgID int64) string {
980 987
 	return tmp.UserName
981 988
 }
982 989
 
983
-//根据id查询是否已发药,true已发药,false未发药
990
+//根据id查询是否已发药,true已发药,false未发药gai
984 991
 func GiveTheMedicine(id int64) bool {
985 992
 	var xue models.PharmacyDoctorAdvice
986 993
 	XTReadDB().Model(&models.PharmacyDoctorAdvice{}).Where("id = ?", id).Find(&xue)
@@ -1302,3 +1309,585 @@ func ChangeHisPrescriptionid(id string) (err error) {
1302 1309
 	}
1303 1310
 	return
1304 1311
 }
1312
+
1313
+//获取药品规格
1314
+func ReplacementDrugs(orgid int64, special bool) (list []*models.ReplacementDrugs, err error) {
1315
+	var g errgroup.Group
1316
+	var lib []*models.BaseDrugLib
1317
+	var lock sync.Mutex
1318
+	if special {
1319
+		err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? and drug_status not like '%停用%' AND status = 1 and is_special_diseases = 1", orgid).Find(&lib).Error
1320
+	} else {
1321
+		err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? and drug_status not like '%停用%'  AND status = 1 ", orgid).Find(&lib).Error
1322
+	}
1323
+	if err != nil {
1324
+		return
1325
+	}
1326
+	for _, v := range lib {
1327
+		v := v
1328
+		g.Go(func() error {
1329
+			var tmp models.Manufacturer
1330
+			err := readDb.Model(&models.Manufacturer{}).Where("id = ?", v.Manufacturer).Find(&tmp).Error
1331
+			if err != nil {
1332
+				return err
1333
+			}
1334
+			lock.Lock()
1335
+			list = append(list, &models.ReplacementDrugs{
1336
+				Id:   v.ID,
1337
+				Name: v.DrugName + " " + v.Dose + v.DoseUnit + "*" + config.ToString(v.MinNumber) + v.MinUnit + "/" + v.MaxUnit + " " + tmp.ManufacturerName,
1338
+			})
1339
+			lock.Unlock()
1340
+			return err
1341
+		})
1342
+	}
1343
+	if errs := g.Wait(); errs != nil {
1344
+		err = errs
1345
+		return
1346
+	}
1347
+	return
1348
+}
1349
+
1350
+//获取药品规格,不考虑特殊病
1351
+func ReplacementDrugsT(orgid int64) (list []*models.ReplacementDrugs, err error) {
1352
+	var lib []*models.BaseDrugLib
1353
+	err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ?  AND status = 1 and drug_status not like '%停用%' ", orgid).Find(&lib).Error
1354
+	if err != nil {
1355
+		return
1356
+	}
1357
+	for _, v := range lib {
1358
+		var tmp models.Manufacturer
1359
+		err = readDb.Model(&models.Manufacturer{}).Where("id = ?", v.Manufacturer).Find(&tmp).Error
1360
+		if err != nil {
1361
+			return
1362
+		}
1363
+
1364
+		list = append(list, &models.ReplacementDrugs{
1365
+			Id:   v.ID,
1366
+			Name: v.DrugName + " " + v.Dose + v.DoseUnit + "*" + config.ToString(v.MinNumber) + v.MinUnit + "/" + v.PrescribingNumberUnit + " " + tmp.ManufacturerName,
1367
+		})
1368
+	}
1369
+	return
1370
+}
1371
+
1372
+//根据药品id获取药品名字
1373
+func IdToDrugName(id int64) (name string) {
1374
+	var lib models.BaseDrugLib
1375
+	readDb.Model(&models.BaseDrugLib{}).Where("id = ?", id).Find(&lib)
1376
+	return lib.DrugName
1377
+}
1378
+
1379
+//获取项目和耗材和套餐
1380
+func ProjectConsumables3(orgid int64) (list []*models.DropDownList, err error) {
1381
+
1382
+	var project []*models.XtHisProject
1383
+	project, err = GetHisProject(orgid)
1384
+	if err != nil {
1385
+		return
1386
+	}
1387
+	for _, v := range project {
1388
+		list = append(list, &models.DropDownList{
1389
+			Id:   "p" + config.ToString(v.ID),
1390
+			Name: v.ProjectName,
1391
+		})
1392
+	}
1393
+
1394
+	var good []*models.GoodInfo
1395
+	err = XTReadDB().Model(&models.GoodInfo{}).Where("org_id = ? and status = 1", orgid).Find(&good).Error
1396
+	if err != nil {
1397
+		return
1398
+	}
1399
+	for _, v := range good {
1400
+		list = append(list, &models.DropDownList{
1401
+			Id:   "i" + config.ToString(v.ID),
1402
+			Name: v.GoodName,
1403
+		})
1404
+	}
1405
+
1406
+	var team []*models.XtHisProjectTeam
1407
+	team, err = GetAllProjectTeam(orgid)
1408
+	if err != nil {
1409
+		return
1410
+	}
1411
+	for _, v := range team {
1412
+		list = append(list, &models.DropDownList{
1413
+			Id:   "h" + config.ToString(v.ID),
1414
+			Name: v.ProjectTeam,
1415
+		})
1416
+	}
1417
+
1418
+	return
1419
+}
1420
+
1421
+//获取项目和耗材
1422
+func ProjectConsumables2(orgid int64, special bool) (list []*models.DropDownList, err error) {
1423
+
1424
+	var project []*models.XtHisProject
1425
+	if special {
1426
+		err = XTReadDB().Model(&project).Where("user_org_id = ? and medical_status != 1 and status = 1 and disease_directory = 1", orgid).Find(&project).Error
1427
+	} else {
1428
+		err = XTReadDB().Model(&project).Where("user_org_id = ? and medical_status != 1 and status = 1", orgid).Find(&project).Error
1429
+	}
1430
+	if err != nil {
1431
+		return
1432
+	}
1433
+	for _, v := range project {
1434
+		list = append(list, &models.DropDownList{
1435
+			Id:   "p" + config.ToString(v.ID),
1436
+			Name: v.ProjectName,
1437
+		})
1438
+	}
1439
+
1440
+	var good []*models.GoodInfo
1441
+	if special {
1442
+		err = XTReadDB().Model(&models.GoodInfo{}).Where("org_id = ? and good_status not like '%停用%' and status = 1 and is_special_diseases = 1", orgid).Find(&good).Error
1443
+	} else {
1444
+		err = XTReadDB().Model(&models.GoodInfo{}).Where("org_id = ? and good_status not like '%停用%' and status = 1", orgid).Find(&good).Error
1445
+	}
1446
+	if err != nil {
1447
+		return
1448
+	}
1449
+	for _, v := range good {
1450
+		list = append(list, &models.DropDownList{
1451
+			Id:   "i" + config.ToString(v.ID),
1452
+			Name: v.GoodName + " " + v.SpecificationName,
1453
+		})
1454
+	}
1455
+
1456
+	return
1457
+}
1458
+
1459
+//获取项目和耗材不考虑特殊病
1460
+func ProjectConsumables2T(orgid int64) (list []*models.DropDownList, err error) {
1461
+
1462
+	var project []*models.XtHisProject
1463
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1 and medical_status != 1", orgid).Find(&project).Error
1464
+	if err != nil {
1465
+		return
1466
+	}
1467
+	for _, v := range project {
1468
+		list = append(list, &models.DropDownList{
1469
+			Id:   "p" + config.ToString(v.ID),
1470
+			Name: v.ProjectName,
1471
+		})
1472
+	}
1473
+
1474
+	var good []*models.GoodInfo
1475
+	err = XTReadDB().Model(&models.GoodInfo{}).Where("org_id = ? and status = 1 and good_status != 1", orgid).Find(&good).Error
1476
+	if err != nil {
1477
+		return
1478
+	}
1479
+	for _, v := range good {
1480
+		list = append(list, &models.DropDownList{
1481
+			Id:   "i" + config.ToString(v.ID),
1482
+			Name: v.GoodName + " " + v.SpecificationName,
1483
+		})
1484
+	}
1485
+
1486
+	return
1487
+}
1488
+
1489
+//查询药品
1490
+func FindPatientDrug(orgid, patient_id, drugid, mode int64) bool {
1491
+	var total int
1492
+	XTReadDB().Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? and patient_id = ? and drug_id = ? and status = 1 and "+
1493
+		"prescription_id in (select id from his_prescription_info_template where status = 1 and user_org_id = ? and type = 1 and p_template_id in ("+
1494
+		"select id from his_prescription_template where status= 1 and user_org_id = ? and mode = ?))", orgid, patient_id, drugid, orgid, orgid, mode).Count(&total)
1495
+	if total > 0 {
1496
+		return true
1497
+	}
1498
+	return false
1499
+}
1500
+
1501
+//查询项目
1502
+func FindPatientXiang(orgid, patient_id, drugid, mode int64) bool {
1503
+	var total int
1504
+	XTReadDB().Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and status = 1 and type = 2 and "+
1505
+		"prescription_id in (select id from his_prescription_info_template where status = 1 and user_org_id = ? and type = 2 and p_template_id in ("+
1506
+		"select id from his_prescription_template where status= 1 and user_org_id = ? and mode = ?))", orgid, patient_id, drugid, orgid, orgid, mode).Count(&total)
1507
+	if total > 0 {
1508
+		return true
1509
+	}
1510
+	return false
1511
+}
1512
+
1513
+//查询耗材
1514
+func FindPatientXiang2(orgid, patient_id, drugid, mode int64) bool {
1515
+	var total int
1516
+	XTReadDB().Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and status = 1 and type = 3 and "+
1517
+		"prescription_id in (select id from his_prescription_info_template where status = 1 and user_org_id = ? and type = 2 and p_template_id in ("+
1518
+		"select id from his_prescription_template where status= 1 and user_org_id = ? and mode = ?))", orgid, patient_id, drugid, orgid, orgid, mode).Count(&total)
1519
+	if total > 0 {
1520
+		return true
1521
+	}
1522
+	return false
1523
+}
1524
+
1525
+//types处方类型,1.药品 2.项目,model透析模式
1526
+func GetHisInfoTempalteId(model, orgid, types int64) (tp []int64) {
1527
+	type tmpid struct {
1528
+		Id int64
1529
+	}
1530
+	var tmp []*tmpid
1531
+	XTReadDB().Raw("select id from his_prescription_info_template where status = 1 and user_org_id = ? and type = ? and p_template_id in ("+
1532
+		"select id from his_prescription_template where status = 1 and user_org_id = ? and mode = ?)", orgid, types, orgid, model).Scan(&tmp)
1533
+	for _, v := range tmp {
1534
+		tp = append(tp, v.Id)
1535
+	}
1536
+	return
1537
+}
1538
+
1539
+//替换药品处方模板
1540
+func ReplaceDrugPrescriptionTemplate(orgid, patient_id, drugid int64, ids []int64, s models.HisPrescriptionAdviceTemplate, tx *gorm.DB) (err error) {
1541
+	err = tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? and patient_id = ? and drug_id = ? and "+
1542
+		"status = 1 and prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
1543
+		"drug_id":                 s.DrugId,
1544
+		"advice_name":             s.AdviceName,
1545
+		"single_dose":             s.SingleDose,
1546
+		"single_dose_unit":        s.SingleDoseUnit,
1547
+		"delivery_way":            s.DeliveryWay,
1548
+		"execution_frequency":     s.ExecutionFrequency,
1549
+		"day":                     s.Day,
1550
+		"prescribing_number":      s.PrescribingNumber,
1551
+		"prescribing_number_unit": s.PrescribingNumberUnit,
1552
+		"price":                   s.Price,
1553
+		"remark":                  s.Remark,
1554
+		"updated_time":            time.Now().Unix(),
1555
+	}).Error
1556
+	return err
1557
+}
1558
+
1559
+//替换项目模板
1560
+func ReplaceProjectPrescriptionTemplate(orgid, patient_id, drugid int64, ids []int64, s models.HisPrescriptionProjectTemplate, tx *gorm.DB) (err error) {
1561
+	err = tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and "+
1562
+		"status = 1 and prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
1563
+		"project_id":          s.ProjectId,
1564
+		"type":                s.Type,
1565
+		"frequency_type":      s.FrequencyType,
1566
+		"day_count":           s.DayCount,
1567
+		"week_day":            s.WeekDay,
1568
+		"price":               s.Price,
1569
+		"count":               s.Count,
1570
+		"single_dose":         s.SingleDose,
1571
+		"delivery_way":        s.DeliveryWay,
1572
+		"execution_frequency": s.ExecutionFrequency,
1573
+		"remark":              s.Remark,
1574
+		"day":                 s.Day,
1575
+		"unit":                s.Unit,
1576
+		"mtime":               time.Now().Unix(),
1577
+	}).Error
1578
+	return err
1579
+}
1580
+
1581
+//删除项目模板
1582
+func DeleteProjectTemplate(orgid, patient_id, drugid int64, ids []int64, tx *gorm.DB) (err error) {
1583
+	err = tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and "+
1584
+		"prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
1585
+		"status": 0,
1586
+		"mtime":  time.Now().Unix(),
1587
+	}).Error
1588
+	return err
1589
+}
1590
+
1591
+//删除处方模板
1592
+func DeletePrescriptionTemplate(orgid, patient_id, drugid int64, ids []int64, tx *gorm.DB) (err error) {
1593
+	err = tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? and patient_id = ? and drug_id = ? and "+
1594
+		"prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
1595
+		"status":       0,
1596
+		"updated_time": time.Now().Unix(),
1597
+	}).Error
1598
+	return err
1599
+}
1600
+
1601
+//根据透析模式和患者id获取该患者的处方内容
1602
+func PTemplateInformation(orgid, mode_id, patient_id int64) (tmp interface{}, err error) {
1603
+	//获取处方id
1604
+	var tt []*models.HisPrescriptionTemplate
1605
+	err = XTReadDB().Raw("select id from his_prescription_template where status = 1 and user_org_id = ? and mode = ? and patient_id = ?", orgid, mode_id, patient_id).Scan(&tt).Error
1606
+
1607
+	if len(tt) > 1 {
1608
+		err = fmt.Errorf("数据有误")
1609
+		return
1610
+	}
1611
+	x := make(map[int64]string, 0) //项目
1612
+	h := make(map[int64]string, 0) //耗材
1613
+	for _, v := range tt {
1614
+		var prescriptions []*models.HisPrescriptionInfoTemplateL
1615
+		prescriptions, err = GetHisPrescriptionTemplateL(v.ID, orgid)
1616
+		if err != nil {
1617
+			return
1618
+		}
1619
+		for i := 0; i < len(prescriptions); i++ {
1620
+			for j := 0; j < len(prescriptions[i].HisPrescriptionProjectTemplate); j++ {
1621
+				if prescriptions[i].HisPrescriptionProjectTemplate[j].Type == 2 {
1622
+					//项目
1623
+					if v, ok := x[prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.StatisticalClassification]; ok {
1624
+						prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.Translate = v
1625
+					} else {
1626
+						prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.Translate, err = TranslateZu(prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.StatisticalClassification, orgid, "统计分类")
1627
+						if err != nil {
1628
+							return
1629
+						}
1630
+						x[prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.StatisticalClassification] = prescriptions[i].HisPrescriptionProjectTemplate[j].XtHisProject.Translate
1631
+					}
1632
+
1633
+				}
1634
+				if prescriptions[i].HisPrescriptionProjectTemplate[j].Type == 3 {
1635
+					//耗材
1636
+					if v, ok := h[prescriptions[i].HisPrescriptionProjectTemplate[j].GoodInfo.GoodKind]; ok {
1637
+						prescriptions[i].HisPrescriptionProjectTemplate[j].GoodInfo.Translate = v
1638
+					} else {
1639
+						prescriptions[i].HisPrescriptionProjectTemplate[j].GoodInfo.Translate = "耗材"
1640
+						h[prescriptions[i].HisPrescriptionProjectTemplate[j].GoodInfo.GoodKind] = prescriptions[i].HisPrescriptionProjectTemplate[j].GoodInfo.Translate
1641
+					}
1642
+				}
1643
+			}
1644
+		}
1645
+		tmp = prescriptions
1646
+	}
1647
+	return
1648
+}
1649
+func DeleteOne(types, id int64) (err error) {
1650
+	if types == 1 {
1651
+		//药品
1652
+		err = XTWriteDB().Model(&models.HisPrescriptionAdviceTemplate{}).Where("id = ?", id).Updates(map[string]interface{}{
1653
+			"status":       0,
1654
+			"updated_time": time.Now().Unix(),
1655
+		}).Error
1656
+		if err != nil {
1657
+			return
1658
+		}
1659
+	} else if types == 2 {
1660
+		//项目
1661
+		err = XTWriteDB().Model(&models.HisPrescriptionProjectTemplateL{}).Where("id = ?", id).Updates(map[string]interface{}{
1662
+			"status": 0,
1663
+			"mtime":  time.Now().Unix(),
1664
+		}).Error
1665
+		if err != nil {
1666
+			return
1667
+		}
1668
+
1669
+	} else {
1670
+		err = fmt.Errorf("参数错误")
1671
+		return
1672
+	}
1673
+	return
1674
+
1675
+}
1676
+
1677
+//收尾工作
1678
+func Scavenger(orgid int64) (err error) {
1679
+	//开事务
1680
+	tx := XTWriteDB().Begin()
1681
+	defer func() {
1682
+		if err != nil {
1683
+			utils.ErrorLog("事务失败,原因为: %v", err)
1684
+			tx.Rollback()
1685
+		} else {
1686
+			tx.Commit()
1687
+		}
1688
+	}()
1689
+	//查询该机构的所有模板
1690
+	var tmp1 []*models.HisPrescriptionTemplate
1691
+	var tmp2 []*models.HisPrescriptionInfoTemplate
1692
+	deltmp1 := make([]int64, 0) //清除的数据
1693
+	deltmp2 := make([]int64, 0) //清除的数据
1694
+	err = tx.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? and status = 1", orgid).Find(&tmp1).Error
1695
+	if err != nil {
1696
+		return
1697
+	}
1698
+	for _, v := range tmp1 {
1699
+		var total1 int
1700
+		tx.Model(&models.HisPrescriptionInfoTemplate{}).Where("user_org_id = ? and p_template_id = ? and status = 1", orgid, v.ID).Count(&total1)
1701
+		if total1 == 0 {
1702
+			deltmp1 = append(deltmp1, v.ID)
1703
+		}
1704
+	}
1705
+	err = tx.Model(&models.HisPrescriptionInfoTemplate{}).Where("user_org_id = ? and status = 1", orgid).Find(&tmp2).Error
1706
+	if err != nil {
1707
+		return
1708
+	}
1709
+	for _, v := range tmp2 {
1710
+		if v.Type == 1 {
1711
+			var total2 int
1712
+			tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? and prescription_id = ? and status = 1", orgid, v.ID).Count(&total2)
1713
+			if total2 == 0 {
1714
+				deltmp2 = append(deltmp2, v.ID)
1715
+			}
1716
+		}
1717
+		if v.Type == 2 {
1718
+			var total3 int
1719
+			tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and prescription_id = ? and status = 1", orgid, v.ID).Count(&total3)
1720
+			if total3 == 0 {
1721
+				deltmp2 = append(deltmp2, v.ID)
1722
+			}
1723
+		}
1724
+	}
1725
+
1726
+	//清除1
1727
+	err = tx.Model(&models.HisPrescriptionTemplate{}).Where("id in (?)", deltmp1).Updates(map[string]interface{}{
1728
+		"status": 0,
1729
+		"mtime":  time.Now().Unix(),
1730
+	}).Error
1731
+	if err != nil {
1732
+		return
1733
+	}
1734
+	//清除1
1735
+	err = tx.Model(&models.HisPrescriptionInfoTemplate{}).Where("id in (?)", deltmp2).Updates(map[string]interface{}{
1736
+		"status": 0,
1737
+		"mtime":  time.Now().Unix(),
1738
+	}).Error
1739
+	if err != nil {
1740
+		return
1741
+	}
1742
+
1743
+	return
1744
+}
1745
+
1746
+//分区和收费(患者发药
1747
+func PartitionAndLayout(stime, etime, orgid, shift, partition int64, flist []*models.TmpPatient) (tmp []*models.TmpPatient, err error) {
1748
+	//获取排班
1749
+	var sch []*models.XtScheduleTwo
1750
+	ma := make(map[int64]int64)
1751
+	s := "user_org_id = ? and status = 1 and schedule_date >= ? and schedule_date <= ?"
1752
+	if shift != 0 {
1753
+		s = s + " and schedule_type = " + config.ToString(shift)
1754
+	}
1755
+	if partition != 0 {
1756
+		s = s + " and partition_id = " + config.ToString(partition)
1757
+	}
1758
+	if shift == 0 && partition == 0 {
1759
+		return flist, nil
1760
+	}
1761
+	err = XTWriteDB().Model(&models.XtScheduleTwo{}).Where(s, orgid, stime, etime).Find(&sch).Error
1762
+	if err != nil {
1763
+		return
1764
+	}
1765
+	for _, v := range sch {
1766
+		ma[v.PatientId] = v.PatientId
1767
+	}
1768
+	for _, v := range flist {
1769
+		if _, ok := ma[v.PatientID]; ok {
1770
+			tmp = append(tmp, v)
1771
+		}
1772
+	}
1773
+	return
1774
+}
1775
+
1776
+//分区和收费(药品发药
1777
+func PartitionAndLayoutDrug(deliveryway string, stime, etime, orgid, shift, partition int64, flist []*models.PatientInformation) (tmp []*models.PatientInformation, err error) {
1778
+	//获取排班
1779
+	var sch []*models.XtScheduleTwo
1780
+	ma := make(map[int64]int64)
1781
+	s := "user_org_id = ? and status = 1 and schedule_date >= ? and schedule_date <= ?"
1782
+	if shift != 0 {
1783
+		s = s + " and schedule_type = " + config.ToString(shift)
1784
+	}
1785
+	if partition != 0 {
1786
+		s = s + " and partition_id = " + config.ToString(partition)
1787
+	}
1788
+	if shift == 0 && partition == 0 {
1789
+		for _, v := range flist {
1790
+			ma[v.PatientId] = v.PatientId
1791
+		}
1792
+		for _, v := range flist {
1793
+			if _, ok := ma[v.PatientId]; ok && (v.Usage == deliveryway || deliveryway == "全部") {
1794
+				tmp = append(tmp, v)
1795
+			}
1796
+		}
1797
+		return tmp, nil
1798
+	}
1799
+	err = XTWriteDB().Model(&models.XtScheduleTwo{}).Where(s, orgid, stime, etime).Find(&sch).Error
1800
+	if err != nil {
1801
+		return
1802
+	}
1803
+	for _, v := range sch {
1804
+		ma[v.PatientId] = v.PatientId
1805
+	}
1806
+
1807
+	for _, v := range flist {
1808
+		if _, ok := ma[v.PatientId]; ok && (v.Usage == deliveryway || deliveryway == "全部") {
1809
+			tmp = append(tmp, v)
1810
+		}
1811
+	}
1812
+	return
1813
+}
1814
+
1815
+//给药途径
1816
+func Administration(deliveryway string, orgid int64, flist []*models.ListOfDrugs) (tmp []*models.ListOfDrugs, err error) {
1817
+	//查询药品
1818
+	var pp []*models.PharmacyBaseDrug
1819
+	s := "org_id = ? and status = 1"
1820
+	if deliveryway == "全部" {
1821
+		tmp = flist
1822
+		return
1823
+	} else {
1824
+		s = s + " and delivery_way = '" + deliveryway + "'"
1825
+	}
1826
+	err = XTReadDB().Model(&models.PharmacyBaseDrug{}).Where(s, orgid).Find(&pp).Error
1827
+	if err != nil {
1828
+		return
1829
+	}
1830
+	ma := make(map[int64]int64)
1831
+	for _, v := range pp {
1832
+		ma[v.ID] = v.ID
1833
+	}
1834
+	for _, v := range flist {
1835
+		if _, ok := ma[v.ID]; ok {
1836
+			tmp = append(tmp, v)
1837
+		}
1838
+	}
1839
+	return
1840
+}
1841
+
1842
+//计算总量
1843
+func CalculateTheTotalAmount(tmp []*models.PatientInformation, drug_id int64) (total string, err error) {
1844
+	//获取药品信息
1845
+	var t models.SpBaseDrug
1846
+	err = XTReadDB().Model(&models.SpBaseDrug{}).Where("id = ?", drug_id).Find(&t).Error
1847
+	if err != nil {
1848
+		return
1849
+	}
1850
+	terr, maxunit, minunit := int64(0), int64(0), int64(0) //terr异常的单位数量,maxunit包装单位数量,minunit拆零单位数量
1851
+	minmunber := t.MinNumber                               //拆零数量
1852
+	terrUnit := ""
1853
+	for _, v := range tmp {
1854
+		fmt.Println("v2332233232322323", v.Quantity)
1855
+		switch v.Unit {
1856
+		case t.MaxUnit:
1857
+			maxunit = maxunit + v.Quantity
1858
+		case t.MinUnit:
1859
+			minunit = minunit + v.Quantity
1860
+		default:
1861
+			terr = terr + v.Quantity
1862
+			terrUnit = v.Unit
1863
+		}
1864
+	}
1865
+	if minunit >= minmunber {
1866
+		if minmunber == 0 {
1867
+			err = fmt.Errorf("拆零数量不能为零")
1868
+			return
1869
+		}
1870
+		maxunit = maxunit + minunit/minmunber
1871
+		minunit = minunit % minmunber
1872
+
1873
+	}
1874
+	if terr > 0 {
1875
+		total = total + config.ToString(terr) + terrUnit
1876
+	}
1877
+	if maxunit > 0 {
1878
+		total = total + config.ToString(maxunit) + t.MaxUnit
1879
+	}
1880
+	if minunit > 0 {
1881
+		total = total + config.ToString(minunit) + t.MinUnit
1882
+	}
1883
+
1884
+	return
1885
+}
1886
+func GetAllValidDeviceZones02(orgID int64) ([]*models.DeviceZone, error) {
1887
+	var zones []*models.DeviceZone
1888
+	err := readDb.Model(&models.DeviceZone{}).Where("org_id = ? and status = 1", orgID).Find(&zones).Error
1889
+	if err != nil {
1890
+		return nil, err
1891
+	}
1892
+	return zones, nil
1893
+}

+ 4 - 4
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go 查看文件

@@ -226,7 +226,7 @@ type AssessmentBeforeDislysisVM struct {
226 226
 	AssessmentDate                 int64   `gorm:"column:assessment_date" json:"assessment_date"`
227 227
 	Temperature                    float64 `gorm:"column:temperature" json:"temperature"`
228 228
 	PulseFrequency                 float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
229
-	BreathingRate                  float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
229
+	BreathingRate                  string  `gorm:"column:breathing_rate" json:"breathing_rate"`
230 230
 	SystolicBloodPressure          float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
231 231
 	DiastolicBloodPressure         float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
232 232
 	BloodPressureType              int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
@@ -300,7 +300,7 @@ type AssessmentAfterDislysisVM struct {
300 300
 	AssessmentDate                  int64   `gorm:"column:assessment_date" json:"assessment_date"`
301 301
 	Temperature                     float64 `gorm:"column:temperature" json:"temperature"`
302 302
 	PulseFrequency                  float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
303
-	BreathingRate                   float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
303
+	BreathingRate                   string  `gorm:"column:breathing_rate" json:"breathing_rate"`
304 304
 	SystolicBloodPressure           float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
305 305
 	DiastolicBloodPressure          float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
306 306
 	BloodPressureType               int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
@@ -382,7 +382,7 @@ type XtAssessmentAfterDislysisVM struct {
382 382
 	AssessmentDate                  int64   `gorm:"column:assessment_date" json:"assessment_date"`
383 383
 	Temperature                     float64 `gorm:"column:temperature" json:"temperature"`
384 384
 	PulseFrequency                  float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
385
-	BreathingRate                   float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
385
+	BreathingRate                   string  `gorm:"column:breathing_rate" json:"breathing_rate"`
386 386
 	SystolicBloodPressure           float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
387 387
 	DiastolicBloodPressure          float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
388 388
 	BloodPressureType               int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
@@ -511,7 +511,7 @@ type MonitoringRecordVM struct {
511 511
 	MonitoringDate              int64   `gorm:"column:monitoring_date" json:"monitoring_date"`
512 512
 	OperateTime                 int64   `gorm:"column:operate_time" json:"operate_time"`
513 513
 	PulseFrequency              float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
514
-	BreathingRate               float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
514
+	BreathingRate               string  `gorm:"column:breathing_rate" json:"breathing_rate"`
515 515
 	SystolicBloodPressure       float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
516 516
 	DiastolicBloodPressure      float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
517 517
 	BloodPressureType           int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`

+ 57 - 2
service/statistics_service/index_evaluation_service.go 查看文件

@@ -1444,12 +1444,12 @@ func GetNurseWorkloadTableData(user_org_id int64, start_time int64, end_time int
1444 1444
 	userDb := service.UserReadDB()
1445 1445
 	db := service.XTReadDB()
1446 1446
 	//var tempConfig models.Dataconfig
1447
-	offset := (page - 1) * limit
1447
+	//offset := (page - 1) * limit
1448 1448
 
1449 1449
 	//db.Model(&models.Dataconfig{}).Where("name = '血管通路' AND module = 'hemodialysis' AND field_name = 'vascular_access_desc' AND parent_id = 0").First(&tempConfig)
1450 1450
 
1451 1451
 	if admin_user_id == 0 {
1452
-		userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where org_id = ?  AND user_type = 3 ", user_org_id).Offset(offset).Limit(limit).Scan(&datas)
1452
+		userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where org_id = ?  AND user_type = 3 ", user_org_id).Scan(&datas)
1453 1453
 	} else {
1454 1454
 		userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where org_id = ?  AND user_type = 3  AND admin_user_id = ?", user_org_id, admin_user_id).Scan(&datas)
1455 1455
 	}
@@ -1495,6 +1495,61 @@ func GetNurseWorkloadTableData(user_org_id int64, start_time int64, end_time int
1495 1495
 
1496 1496
 }
1497 1497
 
1498
+//func GetMobilNurseWorkloadTableData(user_org_id int64, start_time int64, end_time int64, admin_user_id int64, page int64, limit int64) (datas []*VMUserAdminRole, AdminTotal int64, err error) {
1499
+//	userDb := service.UserReadDB()
1500
+//	db := service.XTReadDB()
1501
+//	//var tempConfig models.Dataconfig
1502
+//	//offset := (page - 1) * limit
1503
+//
1504
+//	//db.Model(&models.Dataconfig{}).Where("name = '血管通路' AND module = 'hemodialysis' AND field_name = 'vascular_access_desc' AND parent_id = 0").First(&tempConfig)
1505
+//
1506
+//	if admin_user_id == 0 {
1507
+//		userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where org_id = ?  AND user_type = 3 ", user_org_id).Scan(&datas)
1508
+//	} else {
1509
+//		userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where org_id = ?  AND user_type = 3  AND admin_user_id = ?", user_org_id, admin_user_id).Scan(&datas)
1510
+//	}
1511
+//
1512
+//	for _, item := range datas {
1513
+//		var Total int64
1514
+//		var TotalTwo int64
1515
+//		var TotalThree int64
1516
+//		var TotalFour int64
1517
+//		var TotalFive int64
1518
+//		var TotalSix int64
1519
+//		var TotalSeven int64
1520
+//		var TotalEghit int64
1521
+//		var TotalNight int64
1522
+//		//db.Raw("select count(*) as total from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('内瘘',config.name) > 0 Where d.user_org_id = ? AND d.assessment_date >=? AND d.assessment_date <= ?  Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1523
+//		//db.Raw("select count(*) as total_one from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('导管',config.name) > 0 Where  d.user_org_id = ?  AND d.assessment_date >=? AND d.assessment_date <= ?  Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalOne)
1524
+//		db.Table("xt_monitoring_record as monitor ").Joins("join xt_schedule sch On sch.schedule_date = monitor.monitoring_date AND sch.patient_id = monitor.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("monitor.user_org_id = ? AND monitor.status = 1 AND monitor.monitoring_nurse = ? AND monitor.monitoring_date >= ? AND monitor.monitoring_date <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalTwo)
1525
+//		db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.puncture_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&Total)
1526
+//		db.Table("xt_treatment_summary as summary").Joins("join xt_schedule sch On sch.schedule_date = summary.assessment_date AND sch.patient_id = summary.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("summary.user_org_id = ? AND summary.status = 1 AND summary.creater = ? AND summary.assessment_date >= ? AND summary.assessment_date <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalThree)
1527
+//
1528
+//		db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.change_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&TotalFour)
1529
+//		db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.difficult_puncture_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&TotalFive)
1530
+//		db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.new_fistula_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&TotalSix)
1531
+//		db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.start_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&TotalSeven)
1532
+//		db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.finish_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&TotalEghit)
1533
+//		db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1  AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.washpipe_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&TotalNight)
1534
+//
1535
+//		item.PunctureCount = Total
1536
+//		item.CureCount = TotalTwo
1537
+//		item.MissionCount = TotalThree
1538
+//		item.ChangeNuserCount = TotalFour
1539
+//		item.DiffiCultPuntureNuserCount = TotalFive
1540
+//		item.NewNuserCount = TotalSix
1541
+//		item.StartNuserCount = TotalSeven
1542
+//		item.FinshNurserCount = TotalEghit
1543
+//		item.WashpipeNurserCount = TotalNight
1544
+//	}
1545
+//
1546
+//	if err != nil {
1547
+//		return nil, AdminTotal, err
1548
+//	}
1549
+//	return datas, AdminTotal, nil
1550
+//
1551
+//}
1552
+
1498 1553
 //工作量统计
1499 1554
 type AdminUser struct {
1500 1555
 	ID          int64  `gorm:"column:id" json:"id" form:"id"`

+ 1 - 1
service/statistics_service/index_models.go 查看文件

@@ -108,7 +108,7 @@ type VMMonitoringRecord struct {
108 108
 	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
109 109
 	OperateTime            int64   `gorm:"column:operate_time" json:"operate_time" form:"operate_time"`
110 110
 	PulseFrequency         float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
111
-	BreathingRate          float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
111
+	BreathingRate          string  `gorm:"column:breathing_rate" json:"breathing_rate"`
112 112
 	Temperature            float64 `gorm:"column:temperature" json:"temperature"`
113 113
 	BloodFlowVolume        float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
114 114
 	VenousPressure         float64 `gorm:"column:venous_pressure" json:"venous_pressure"`

+ 153 - 37
service/stock_service.go 查看文件

@@ -753,8 +753,13 @@ func UpdateDrugFlowTens(patientid int64, warehouse_out_number string, drug_id in
753 753
 }
754 754
 
755 755
 func CreateDrugFlowTwo(flow *models.DrugFlow) error {
756
-
757
-	err := XTWriteDB().Create(&flow).Error
756
+	tx := XTWriteDB().Begin()
757
+	err := tx.Create(&flow).Error
758
+	if err != nil {
759
+		tx.Rollback()
760
+		return err
761
+	}
762
+	tx.Commit()
758 763
 	return err
759 764
 }
760 765
 func FindLastWarehousingInfo(order string) (info models.WarehousingInfo, err error) {
@@ -4896,8 +4901,13 @@ func CreateStockFlow(warehousingInfo []*models.VmStockFlow) (err error) {
4896 4901
 }
4897 4902
 
4898 4903
 func CreateStockFlowOne(flow models.VmStockFlow) error {
4899
-
4900
-	err := XTWriteDB().Create(&flow).Error
4904
+	tx := XTWriteDB().Begin()
4905
+	err := tx.Create(&flow).Error
4906
+	if err != nil {
4907
+		tx.Rollback()
4908
+		return err
4909
+	}
4910
+	tx.Commit()
4901 4911
 	return err
4902 4912
 }
4903 4913
 
@@ -6564,8 +6574,13 @@ func ModifyGoodReduceInformationTwentyOne(good_id int64, waresing_count int64, s
6564 6574
 }
6565 6575
 
6566 6576
 func UpdateMedicalSumCount(drug_id int64, sum_count int64, sum_in_count int64, orgid int64) error {
6567
-
6568
-	err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drug_id, orgid).Update(map[string]interface{}{"sum_count": sum_count, "sum_in_count": sum_in_count}).Error
6577
+	tx := XTWriteDB().Begin()
6578
+	err := tx.Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drug_id, orgid).Update(map[string]interface{}{"sum_count": sum_count, "sum_in_count": sum_in_count}).Error
6579
+	if err != nil {
6580
+		tx.Rollback()
6581
+		return err
6582
+	}
6583
+	tx.Commit()
6569 6584
 	return err
6570 6585
 }
6571 6586
 
@@ -7080,8 +7095,13 @@ func UpdateWarehouseDetail(info *models.WarehousingInfo, id int64) error {
7080 7095
 }
7081 7096
 
7082 7097
 func UpdateCheckWarehouseInfo(id int64) error {
7083
-
7084
-	err := XTWriteDB().Model(&models.Warehousing{}).Where("id =? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7098
+	tx := XTWriteDB().Begin()
7099
+	err := tx.Model(&models.Warehousing{}).Where("id =? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7100
+	if err != nil {
7101
+		tx.Rollback()
7102
+		return err
7103
+	}
7104
+	tx.Commit()
7085 7105
 	return err
7086 7106
 }
7087 7107
 
@@ -7092,29 +7112,58 @@ func GetWarehouseInfoList(id int64, orgid int64) (info []*models.WarehousingInfo
7092 7112
 }
7093 7113
 
7094 7114
 func UpdateWarehouseInfoByIdList(count int64, id int64) error {
7095
-
7096
-	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
7097
-	err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7115
+	tx := XTWriteDB().Begin()
7116
+	err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
7117
+	if err != nil {
7118
+		tx.Rollback()
7119
+		return err
7120
+	}
7121
+	err = tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7122
+	if err != nil {
7123
+		tx.Rollback()
7124
+		return err
7125
+	}
7126
+	tx.Commit()
7098 7127
 	return err
7099 7128
 }
7100 7129
 
7101 7130
 func ReturnCheckWarehouseInfo(id int64) error {
7102
-
7103
-	err := XTWriteDB().Model(&models.Warehousing{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7104
-	err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("warehousing_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7131
+	tx := XTWriteDB().Begin()
7132
+	err := tx.Model(&models.Warehousing{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7133
+	if err != nil {
7134
+		tx.Rollback()
7135
+		return err
7136
+	}
7137
+	err = tx.Model(&models.WarehousingInfo{}).Where("warehousing_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7138
+	tx.Commit()
7105 7139
 	return err
7106 7140
 }
7107 7141
 
7108 7142
 func UpdateWarehouseInfoByIdListTwo(count int64, id int64) error {
7109
-
7110
-	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", count)).Error
7111
-	err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7143
+	tx := XTWriteDB().Begin()
7144
+	err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", count)).Error
7145
+	if err != nil {
7146
+		tx.Rollback()
7147
+		return err
7148
+	}
7149
+	err = tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7150
+	if err != nil {
7151
+		tx.Rollback()
7152
+		return err
7153
+	}
7154
+	tx.Commit()
7112 7155
 	return err
7113 7156
 }
7114 7157
 
7115 7158
 func UpdateWarehouseInfoFlow(id int64) error {
7159
+	tx := XTWriteDB().Begin()
7160
+	err := tx.Model(models.VmStockFlow{}).Where("warehousing_detail_id =  ?", id).Update(map[string]interface{}{"status": 0}).Error
7116 7161
 
7117
-	err := XTWriteDB().Model(models.VmStockFlow{}).Where("warehousing_detail_id =  ?", id).Update(map[string]interface{}{"status": 0}).Error
7162
+	if err != nil {
7163
+		tx.Rollback()
7164
+		return err
7165
+	}
7166
+	tx.Commit()
7118 7167
 	return err
7119 7168
 }
7120 7169
 
@@ -7158,8 +7207,13 @@ func UpdateWarehouseing(info *models.DrugWarehouseInfo) error {
7158 7207
 }
7159 7208
 
7160 7209
 func CheckWarehousingInfo(id int64, orgid int64) error {
7161
-
7162
-	err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("id = ? and org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7210
+	tx := XTWriteDB().Begin()
7211
+	err := tx.Model(&models.DrugWarehouse{}).Where("id = ? and org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7212
+	if err != nil {
7213
+		tx.Rollback()
7214
+		return err
7215
+	}
7216
+	tx.Commit()
7163 7217
 	return err
7164 7218
 }
7165 7219
 
@@ -7170,41 +7224,89 @@ func GetWarehousingInfoByList(id int64, orgid int64) (info []*models.DrugWarehou
7170 7224
 }
7171 7225
 
7172 7226
 func AddDrugWarehouseStockMaxNumber(count int64, id int64) error {
7173
-
7174
-	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
7175
-	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7227
+	tx := XTWriteDB().Begin()
7228
+	err := tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
7229
+	if err != nil {
7230
+		tx.Rollback()
7231
+		return err
7232
+	}
7233
+	err = tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7234
+	if err != nil {
7235
+		tx.Rollback()
7236
+		return err
7237
+	}
7238
+	tx.Commit()
7176 7239
 	return err
7177 7240
 }
7178 7241
 
7179 7242
 func UpdateWarehousingInfoFlow(id int64, orgid int64) error {
7180
-
7181
-	err := XTWriteDB().Model(&models.DrugFlow{}).Where("warehousing_detail_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"status": 0}).Error
7243
+	tx := XTWriteDB().Begin()
7244
+	err := tx.Model(&models.DrugFlow{}).Where("warehousing_detail_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"status": 0}).Error
7245
+	if err != nil {
7246
+		tx.Rollback()
7247
+		return err
7248
+	}
7249
+	tx.Commit()
7182 7250
 	return err
7183 7251
 }
7184 7252
 
7185 7253
 func AddDrugWarehouseStockMinNumber(count int64, id int64) error {
7186
-
7187
-	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
7254
+	tx := XTWriteDB().Begin()
7255
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
7256
+	if err != nil {
7257
+		tx.Rollback()
7258
+		return err
7259
+	}
7188 7260
 	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7261
+	tx.Commit()
7189 7262
 	return err
7190 7263
 }
7191 7264
 
7192 7265
 func ReturnCheckWarehouseingInfo(id int64, orgid int64) error {
7193
-
7266
+	tx := XTWriteDB().Begin()
7194 7267
 	err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("id = ? and status = 1 and org_id = ?", id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7268
+	if err != nil {
7269
+		tx.Rollback()
7270
+		return err
7271
+	}
7195 7272
 	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("warehousing_id = ? and status = 1 and org_id = ?", id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7273
+	if err != nil {
7274
+		tx.Rollback()
7275
+		return err
7276
+	}
7277
+	tx.Commit()
7196 7278
 	return err
7197 7279
 }
7198 7280
 
7199 7281
 func AddDrugReturnWarehouseStockMaxNumber(count int64, id int64) error {
7200
-	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
7201
-	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7282
+	tx := XTWriteDB().Begin()
7283
+	err := tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
7284
+	if err != nil {
7285
+		tx.Rollback()
7286
+		return err
7287
+	}
7288
+	err = tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7289
+	if err != nil {
7290
+		tx.Rollback()
7291
+		return err
7292
+	}
7293
+	tx.Commit()
7202 7294
 	return err
7203 7295
 }
7204 7296
 
7205 7297
 func AddDrugReturnWarehouseStockMinNumber(count int64, id int64) error {
7206
-	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number - ?", count)).Error
7207
-	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7298
+	tx := XTWriteDB().Begin()
7299
+	err := tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number - ?", count)).Error
7300
+	if err != nil {
7301
+		tx.Rollback()
7302
+		return err
7303
+	}
7304
+	err = tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7305
+	if err != nil {
7306
+		tx.Rollback()
7307
+		return err
7308
+	}
7309
+	tx.Commit()
7208 7310
 	return err
7209 7311
 }
7210 7312
 
@@ -7318,8 +7420,13 @@ func UpdateGoodInfoReduceSumCount(goodid int64, sum_count int64, orgid int64) er
7318 7420
 }
7319 7421
 
7320 7422
 func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64) error {
7321
-
7322
-	err := XTReadDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7423
+	tx := XTWriteDB().Begin()
7424
+	err := tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7425
+	if err != nil {
7426
+		tx.Rollback()
7427
+		return err
7428
+	}
7429
+	tx.Commit()
7323 7430
 	return err
7324 7431
 }
7325 7432
 
@@ -7424,9 +7531,18 @@ func GetDrugAllStockInfo(storehouse_id int64, orgid int64, drugid int64) (info [
7424 7531
 }
7425 7532
 
7426 7533
 func UpdateBaseDrugSumInfo(sum_count int64, drugid int64, orgid int64, sum_in_count int64) error {
7427
-
7428
-	err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7429
-	err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
7534
+	tx := XTWriteDB().Begin()
7535
+	err := tx.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7536
+	if err != nil {
7537
+		tx.Rollback()
7538
+		return err
7539
+	}
7540
+	err = tx.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
7541
+	if err != nil {
7542
+		tx.Rollback()
7543
+		return err
7544
+	}
7545
+	tx.Commit()
7430 7546
 	return err
7431 7547
 }
7432 7548
 

+ 8 - 2
service/warhouse_service.go 查看文件

@@ -680,6 +680,8 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
680 680
 		maxNumber = deliver_number / drup.MinNumber
681 681
 		minNumber = deliver_number % drup.MinNumber
682 682
 
683
+		fmt.Println("maxNumber2323233232323232323232", maxNumber)
684
+		fmt.Println("minNumber2323233232323232323232", minNumber)
683 685
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
684 686
 			minNumber = maxNumber
685 687
 		}
@@ -700,11 +702,15 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
700 702
 		}
701 703
 
702 704
 		warehouse.Mtime = time.Now().Unix()
703
-
705
+		//fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
706
+		//fmt.Println("minNumber", minNumber)
707
+		//fmt.Println("maxNumber", maxNumber)
704 708
 		if warehouse.StockMinNumber < minNumber {
705 709
 
706 710
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
707
-			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
711
+			if warehouse.MaxUnit != warehouse.MinUnit {
712
+				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
713
+			}
708 714
 		} else {
709 715
 
710 716
 			if minNumber > 0 {

+ 1 - 0
src/golang.org/x/sync

@@ -0,0 +1 @@
1
+Subproject commit f12130a5280420d36872ab0a7717d160c768df46