Browse Source

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

陈少旭 1 year ago
parent
commit
3b62ee66b1
34 changed files with 2038 additions and 645 deletions
  1. 1 1
      conf/app.conf
  2. 6 6
      controllers/base_api_controller.go
  3. 2 1
      controllers/dialysis_api_controller.go
  4. 10 0
      controllers/dialysis_record_api_controller.go
  5. 503 312
      controllers/his_api_controller.go
  6. 16 1
      controllers/his_charge_api_controller.go
  7. 112 77
      controllers/manage_api_controller.go
  8. 1 1
      controllers/mobile_api_controllers/check_weight_api_controller.go
  9. 85 16
      controllers/mobile_api_controllers/dialysis_api_controller.go
  10. 143 2
      controllers/mobile_api_controllers/patient_api_controller.go
  11. 114 2
      controllers/patient_api_controller.go
  12. 25 9
      controllers/pharmacy_controller.go
  13. 141 45
      controllers/public_api_controller.go
  14. 119 48
      controllers/self_drug_api_congtroller.go
  15. 31 29
      controllers/stock_in_api_controller.go
  16. 24 21
      models/device_models.go
  17. 1 0
      models/dialysis.go
  18. 19 0
      models/drug_stock.go
  19. 83 2
      models/his_models.go
  20. 9 9
      service/data.go
  21. 2 2
      service/dialysis_service.go
  22. 1 1
      service/dialysis_solution_service.go
  23. 7 0
      service/drug_pharmacy_management_service.go
  24. 26 2
      service/his_charge_service.go
  25. 4 0
      service/his_config_service.go
  26. 29 3
      service/his_service.go
  27. 1 1
      service/manage_service.go
  28. 7 0
      service/mobile_dialysis_service.go
  29. 371 37
      service/new_warehouse_service.go
  30. 17 17
      service/patient_schedule_template_service.go
  31. 11 0
      service/pharmacy_service.go
  32. 23 0
      service/self_drug_service.go
  33. 80 0
      service/stock_service.go
  34. 14 0
      service/warhouse_service.go

+ 1 - 1
conf/app.conf View File

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

+ 6 - 6
controllers/base_api_controller.go View File

@@ -82,7 +82,7 @@ func (this *BaseAuthAPIController) Prepare() {
82 82
 		userAdmin.ModifyTime = 1530786071
83 83
 		var subscibe models.ServeSubscibe
84 84
 		subscibe.ID = 11
85
-		subscibe.OrgId = 9671 //机构id
85
+		subscibe.OrgId = 10341 //机构id
86 86
 		subscibe.PeriodStart = 1547447814
87 87
 		subscibe.PeriodEnd = 1550039814
88 88
 		subscibe.State = 1
@@ -92,8 +92,8 @@ func (this *BaseAuthAPIController) Prepare() {
92 92
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93 93
 		subscibes[4] = &subscibe
94 94
 		var adminUserInfo service.AdminUserInfo
95
-		adminUserInfo.CurrentOrgId = 9671  //机构id小英9675或4
96
-		adminUserInfo.CurrentAppId = 15487 //4
95
+		adminUserInfo.CurrentOrgId = 10341 //机构id小英9675或4
96
+		adminUserInfo.CurrentAppId = 3295  //4
97 97
 		adminUserInfo.AdminUser = &userAdmin
98 98
 		adminUserInfo.Subscibes = subscibes
99 99
 		this.SetSession("admin_user_info", &adminUserInfo)
@@ -328,7 +328,7 @@ func (this *BaseServeAPIController) Prepare() {
328 328
 		userAdmin.ModifyTime = 1530786071
329 329
 		var subscibe models.ServeSubscibe
330 330
 		subscibe.ID = 11
331
-		subscibe.OrgId = 9671 //机构id小英9675或4
331
+		subscibe.OrgId = 10341 //机构id小英9675或4
332 332
 		subscibe.PeriodStart = 1538035409
333 333
 		subscibe.PeriodEnd = 1569571409
334 334
 		subscibe.State = 1
@@ -338,8 +338,8 @@ func (this *BaseServeAPIController) Prepare() {
338 338
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339 339
 		subscibes[4] = &subscibe
340 340
 		var adminUserInfo service.AdminUserInfo
341
-		adminUserInfo.CurrentOrgId = 9671  //机构id小英9675或4
342
-		adminUserInfo.CurrentAppId = 15487 //4
341
+		adminUserInfo.CurrentOrgId = 10341 //机构id小英9675或4
342
+		adminUserInfo.CurrentAppId = 3295  //4
343 343
 		adminUserInfo.AdminUser = &userAdmin
344 344
 		adminUserInfo.Subscibes = subscibes
345 345
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 2 - 1
controllers/dialysis_api_controller.go View File

@@ -603,6 +603,7 @@ func (c *DialysisApiController) PostPrescription() {
603 603
 		}
604 604
 
605 605
 		err := service.AddSigleRecord(&prescription)
606
+
606 607
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
607 608
 		redis := service.RedisClient()
608 609
 		//清空key 值
@@ -4915,7 +4916,7 @@ func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
4915 4916
 	goodType, _ := service.GetAllGoodType(orgId)
4916 4917
 	if config.IsOpen != 1 {
4917 4918
 		list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
4918
-		fmt.Println("list2232323223332323232", list)
4919
+
4919 4920
 		if err == nil {
4920 4921
 			this.ServeSuccessJSON(map[string]interface{}{
4921 4922
 				"list":     list,

+ 10 - 0
controllers/dialysis_record_api_controller.go View File

@@ -412,6 +412,12 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
412 412
 	lastDryWeightDislysis, getDryErr := service.GetLastDryWeight(adminInfo.CurrentOrgId, patientID)
413 413
 
414 414
 	lastOrder, _ := service.GetLastDilysisOrder(adminInfo.CurrentOrgId, patientID, date.Unix())
415
+
416
+	//统计表
417
+	dryWeightList, _ := service.GetPatientDryWeight(adminInfo.CurrentOrgId, patientID)
418
+
419
+	allDoctor, _ := service.GetAllDoctor(adminInfo.CurrentOrgId, adminInfo.CurrentAppId)
420
+
415 421
 	if getDryErr != nil {
416 422
 		this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
417 423
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -466,6 +472,8 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
466 472
 			"information":                 information,
467 473
 			"is_advice_open":              adviceConfig,
468 474
 			"lastOrder":                   lastOrder,
475
+			"dryWeightList":               dryWeightList,
476
+			"docList":                     allDoctor,
469 477
 		}
470 478
 		this.ServeSuccessJSON(returnData)
471 479
 
@@ -503,6 +511,8 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
503 511
 			"information":                 information,
504 512
 			"is_advice_open":              adviceConfig,
505 513
 			"lastOrder":                   lastOrder,
514
+			"dryWeightList":               dryWeightList,
515
+			"docList":                     allDoctor,
506 516
 		}
507 517
 		this.ServeSuccessJSON(returnData)
508 518
 	}

+ 503 - 312
controllers/his_api_controller.go View File

@@ -98,6 +98,318 @@ func HisManagerApiRegistRouters() {
98 98
 
99 99
 	beego.Router("/api/test/get", &HisApiController{}, "get:GetTestOrder")
100 100
 
101
+	beego.Router("/api/batch/settleaccount", &HisApiController{}, "get:GetBatchSettleAccounts")
102
+
103
+}
104
+
105
+func (c *HisApiController) GetBatchSettleAccounts() {
106
+	order_ids := c.GetString("order_ids")
107
+	admin_user_id, _ := c.GetInt64("admin_user_id")
108
+	adminUser := c.GetAdminUserInfo()
109
+	orders := strings.Split(order_ids, ",")
110
+	var newOrders []models.Orders
111
+	for _, item := range orders {
112
+		order, _ := service.GetHisOrderByIDTenOne(item)
113
+		his, _ := service.GetHisPatientByNumber(order.MdtrtId)
114
+		orderInfos, _ := service.GetHisOrderInfoByNumberOne(order.Number)
115
+		orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
116
+		orderInfos = append(orderInfos, orderInfos_two...)
117
+		his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
118
+		//diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
119
+		var diagnosis_ids []string
120
+		if his.ID > 0 {
121
+			diagnosis_ids = strings.Split(his.Diagnosis, ",")
122
+
123
+		} else {
124
+			diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
125
+
126
+		}
127
+		patient, _ := service.GetPatientByIDTenTwo(adminUser.CurrentOrgId, order.PatientId)
128
+		var dia_config []*models.HisXtDiagnoseConfig
129
+		var name string
130
+		for _, item := range diagnosis_ids {
131
+			id, _ := strconv.ParseInt(item, 10, 64)
132
+			diagnosisConfig, _ := service.FindDiagnoseById(id)
133
+			dia_config = append(dia_config, diagnosisConfig)
134
+			if len(name) == 0 {
135
+				name = diagnosisConfig.ClassName
136
+
137
+			} else {
138
+				name = name + "," + diagnosisConfig.ClassName
139
+			}
140
+		}
141
+
142
+		var bedCostTotal float64 = 0         //床位总费
143
+		var bedCostSelfTotal float64 = 0     //床位自费
144
+		var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
145
+		var bedSelfTotal float64 = 0         //床位部分项目自费
146
+		var bedInscpTotal float64 = 0        //床位部分项目自费
147
+
148
+		var operationCostTotal float64 = 0         //手术费
149
+		var operationCostSelfTotal float64 = 0     //手术费
150
+		var operationCostPartSelfTotal float64 = 0 //手术费
151
+		var operationSelfTotal float64 = 0         //床位部分项目自费
152
+		var operationInscpTotal float64 = 0        //床位部分项目自费
153
+
154
+		var otherCostTotal float64 = 0         //其他费用
155
+		var otherCostSelfTotal float64 = 0     //其他费用
156
+		var otherCostPartSelfTotal float64 = 0 //其他费用
157
+		var otherSelfTotal float64 = 0         //床位部分项目自费
158
+		var otherInscpTotal float64 = 0        //床位部分项目自费
159
+
160
+		var materialCostTotal float64 = 0         //材料费
161
+		var materialCostSelfTotal float64 = 0     //材料费
162
+		var materialCostPartSelfTotal float64 = 0 //材料费
163
+		var materialSelfTotal float64 = 0         //床位部分项目自费
164
+		var materialInscpTotal float64 = 0        //床位部分项目自费
165
+
166
+		var westernMedicineCostTotal float64 = 0         //西药费
167
+		var westernMedicineCostSelfTotal float64 = 0     //西药费
168
+		var westernMedicineCostPartSelfTotal float64 = 0 //西药费
169
+		var westernMedicineSelfTotal float64 = 0         //床位部分项目自费
170
+		var westernMedicineInscpTotal float64 = 0        //床位部分项目自费
171
+
172
+		var chineseTraditionalMedicineCostTotal float64 = 0         //中成药
173
+		var chineseTraditionalMedicineCostSelfTotal float64 = 0     //中成药
174
+		var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
175
+		var chineseTraditionalSelfTotal float64 = 0                 //床位部分项目自费
176
+		var chineseTraditionalInscpTotal float64 = 0                //床位部分项目自费
177
+
178
+		var checkCostTotal float64 = 0         //检查费
179
+		var checkCostSelfTotal float64 = 0     //检查费
180
+		var checkCostPartSelfTotal float64 = 0 //检查费
181
+		var checkSelfTotal float64 = 0         //床位部分项目自费
182
+		var checkInscpTotal float64 = 0        //床位部分项目自费
183
+
184
+		var laboratoryCostTotal float64 = 0         //化验费
185
+		var laboratoryCostSelfTotal float64 = 0     //化验费
186
+		var laboratoryCostPartSelfTotal float64 = 0 //化验费
187
+		var laboratorySelfTotal float64 = 0         //床位部分项目自费
188
+		var laboratoryInscpTotal float64 = 0        //床位部分项目自费
189
+
190
+		var treatCostTotal float64 = 0         //治疗费用
191
+		var treatCostSelfTotal float64 = 0     //治疗费用
192
+		var treatCostPartSelfTotal float64 = 0 //治疗费用
193
+		var treatSelfTotal float64 = 0         //床位部分项目自费
194
+		var treatInscpTotal float64 = 0        //床位部分项目自费
195
+
196
+		decimal.DivisionPrecision = 2
197
+
198
+		for _, item := range orderInfos {
199
+			if item.MedChrgitmType == "01" { //床位费
200
+				bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
201
+				bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
202
+				bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
203
+				bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
204
+				bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
205
+
206
+			}
207
+
208
+			if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
209
+				if item.MedChrgitmType == "03" { //检查费
210
+					laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
211
+					laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
212
+					laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
213
+					laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
214
+					laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
215
+
216
+				}
217
+			} else {
218
+
219
+				if item.MedChrgitmType == "03" { //检查费
220
+					checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
221
+					checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
222
+					checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
223
+					checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
224
+					checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
225
+
226
+				}
227
+
228
+			}
229
+
230
+			if item.MedChrgitmType == "04" { //化验费
231
+				laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
232
+				laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
233
+				laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
234
+				laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
235
+				laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
236
+
237
+			}
238
+
239
+			if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
240
+
241
+				treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
242
+				treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
243
+				treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
244
+				treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
245
+				treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
246
+
247
+			}
248
+
249
+			if item.MedChrgitmType == "06" { //手术费
250
+				operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
251
+				operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
252
+				operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
253
+				operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
254
+				operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
255
+
256
+			}
257
+
258
+			if item.MedChrgitmType == "08" { //材料费
259
+				materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
260
+				materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
261
+				materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
262
+				materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
263
+				materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
264
+
265
+			}
266
+
267
+			if item.MedChrgitmType == "09" { //西药费
268
+				westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
269
+				westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
270
+				westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
271
+				westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
272
+				westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
273
+
274
+			}
275
+
276
+			if item.MedChrgitmType == "11" { //中成费
277
+				chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
278
+				chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
279
+				chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
280
+				chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
281
+				chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
282
+
283
+			}
284
+
285
+			if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
286
+				otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
287
+				otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
288
+				otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
289
+				otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
290
+				otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
291
+
292
+			}
293
+		}
294
+
295
+		miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
296
+
297
+		printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
298
+		charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
299
+
300
+		doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
301
+
302
+		roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
303
+
304
+		var doctor_name string
305
+		if roles.ID == 0 {
306
+			doctor_name = "管理员"
307
+		} else {
308
+			doctor_name = roles.UserName
309
+		}
310
+
311
+		yiliao_leibie := ""
312
+
313
+		switch order.MedType {
314
+		case "11":
315
+			yiliao_leibie = "普通门诊"
316
+			break
317
+		case "12":
318
+			yiliao_leibie = "门诊挂号"
319
+			break
320
+		case "13":
321
+			yiliao_leibie = "急诊"
322
+			break
323
+		case "14":
324
+			yiliao_leibie = "门诊特殊病"
325
+			break
326
+		case "15":
327
+			yiliao_leibie = "门诊统筹"
328
+			break
329
+		case "16":
330
+			yiliao_leibie = "门诊慢性病"
331
+			break
332
+		case "21":
333
+			yiliao_leibie = "普通住院"
334
+			break
335
+		}
336
+		var newOrder models.Orders
337
+
338
+		newOrder.Diagnosis = name
339
+		newOrder.OrderInfos = orderInfos
340
+		newOrder.Number = order.MdtrtId
341
+		newOrder.Date = order.SettleAccountsDate
342
+		newOrder.ChargeAdmin = charge_admin
343
+		newOrder.PrintorAdmin = printor_admin
344
+		newOrder.Order = order
345
+		newOrder.BedCostTotal = bedCostTotal
346
+		newOrder.BedCostSelfTotal = bedCostSelfTotal
347
+		newOrder.BedCostPartSelfTotal = bedCostPartSelfTotal
348
+		newOrder.BedSelfTotal = bedSelfTotal
349
+		newOrder.BedInscpTotal = bedInscpTotal
350
+		newOrder.OperationCostTotal = operationCostTotal
351
+		newOrder.OperationCostSelfTotal = operationCostSelfTotal
352
+		newOrder.OperationCostPartSelfTotal = operationCostPartSelfTotal
353
+		newOrder.OperationSelfTotal = operationSelfTotal
354
+		newOrder.OperationInscpTotal = operationInscpTotal
355
+		newOrder.OtherCostTotal = otherCostTotal
356
+		newOrder.OtherCostSelfTotal = otherCostSelfTotal
357
+		newOrder.OtherCostPartSelfTotal = otherCostPartSelfTotal
358
+		newOrder.OtherSelfTotal = otherSelfTotal
359
+		newOrder.OtherInscpTotal = otherInscpTotal
360
+
361
+		newOrder.MaterialCostTotal = materialCostTotal
362
+		newOrder.MaterialCostSelfTotal = materialCostSelfTotal
363
+		newOrder.MaterialCostPartSelfTotal = materialCostPartSelfTotal
364
+		newOrder.MaterialSelfTotal = materialSelfTotal
365
+		newOrder.MaterialInscpTotal = materialInscpTotal
366
+
367
+		newOrder.WesternMedicineCostTotal = westernMedicineCostTotal
368
+		newOrder.WesternMedicineCostSelfTotal = westernMedicineCostSelfTotal
369
+		newOrder.WesternMedicineCostPartSelfTotal = westernMedicineCostPartSelfTotal
370
+		newOrder.WesternMedicineSelfTotal = westernMedicineSelfTotal
371
+		newOrder.WesternMedicineInscpTotal = westernMedicineInscpTotal
372
+
373
+		newOrder.ChineseTraditionalMedicineCostTotal = chineseTraditionalMedicineCostTotal
374
+		newOrder.ChineseTraditionalMedicineCostSelfTotal = chineseTraditionalMedicineCostSelfTotal
375
+		newOrder.ChineseTraditionalMedicineCostPartSelfTotal = chineseTraditionalMedicineCostPartSelfTotal
376
+		newOrder.ChineseTraditionalSelfTotal = chineseTraditionalSelfTotal
377
+		newOrder.ChineseTraditionalInscpTotal = chineseTraditionalInscpTotal
378
+
379
+		newOrder.CheckCostTotal = checkCostTotal
380
+		newOrder.CheckCostSelfTotal = checkCostSelfTotal
381
+		newOrder.CheckCostPartSelfTotal = checkCostPartSelfTotal
382
+		newOrder.CheckSelfTotal = checkSelfTotal
383
+		newOrder.CheckInscpTotal = checkInscpTotal
384
+
385
+		newOrder.LaboratoryCostTotal = laboratoryCostTotal
386
+		newOrder.LaboratoryCostSelfTotal = laboratoryCostSelfTotal
387
+		newOrder.LaboratoryCostPartSelfTotal = laboratoryCostPartSelfTotal
388
+		newOrder.LaboratorySelfTotal = laboratorySelfTotal
389
+		newOrder.LaboratoryInscpTotal = laboratoryInscpTotal
390
+
391
+		newOrder.TreatCostTotal = treatCostTotal
392
+		newOrder.TreatCostSelfTotal = treatCostSelfTotal
393
+		newOrder.TreatCostPartSelfTotal = treatCostPartSelfTotal
394
+		newOrder.TreatSelfTotal = treatSelfTotal
395
+		newOrder.TreatInscpTotal = treatInscpTotal
396
+
397
+		newOrder.DoctorInfo = doctor_info
398
+		newOrder.DoctorName = doctor_name
399
+		newOrder.HealthCardNo = order.PsnNo
400
+		newOrder.YiliaoLeibie = yiliao_leibie
401
+		newOrder.Patient = patient
402
+		newOrder.OrgName = miConfig.OrgName
403
+		newOrder.OrgCode = miConfig.Code
404
+		newOrder.OrderNumber = order.Number
405
+		newOrder.HisPatient = his
406
+		newOrder.DiaConfig = dia_config
407
+
408
+		newOrders = append(newOrders, newOrder)
409
+	}
410
+	c.ServeSuccessJSON(map[string]interface{}{
411
+		"orders": newOrders,
412
+	})
101 413
 }
102 414
 
103 415
 func (c *HisApiController) GetTestOrder() {
@@ -1328,7 +1640,6 @@ func (c *HisApiController) CreateHisPrescription() {
1328 1640
 
1329 1641
 	pharmacyConfig, _ := service.FindPharmacyConfig(adminInfo.CurrentOrgId)
1330 1642
 
1331
-	fmt.Println("0230032032032032032032023---------------", pharmacyConfig.IsOpen)
1332 1643
 	//药品发药出库
1333 1644
 	if pharmacyConfig.IsOpen == 1 {
1334 1645
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
@@ -2698,6 +3009,7 @@ func (c *HisApiController) CreateHisPrescription() {
2698 3009
 		if drugOutConfig.IsOpen == 1 {
2699 3010
 			for _, item := range hisdoctorlist {
2700 3011
 				drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, item.DrugId)
3012
+
2701 3013
 				// 查询该药品最后一次出库记录
2702 3014
 				druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(item.DrugId, patient_id, recordDateTime, item.ID)
2703 3015
 
@@ -5572,7 +5884,7 @@ func (c *HisApiController) setAdviceTemplateWithJSON(advice *models.HisPrescript
5572 5884
 		day := int64(json["day"].(float64))
5573 5885
 		advice.Day = day
5574 5886
 	}
5575
-
5887
+	advice.FrequencyType = 1
5576 5888
 	return 0
5577 5889
 }
5578 5890
 
@@ -5627,6 +5939,8 @@ func (c *HisApiController) setProjectTemplateWithJSON(project *models.HisPrescri
5627 5939
 		unit, _ := json["unit"].(string)
5628 5940
 		project.Unit = unit
5629 5941
 	}
5942
+	project.FrequencyType = 1
5943
+
5630 5944
 	return 0
5631 5945
 }
5632 5946
 
@@ -5640,6 +5954,8 @@ func (c *HisApiController) GetHisOrderList() {
5640 5954
 	p_type, _ := c.GetInt64("p_type", 0)
5641 5955
 	sort_type, _ := c.GetInt64("sort_type", 0)
5642 5956
 	charge_type, _ := c.GetInt64("charge_type", 0)
5957
+	sch_type, _ := c.GetInt64("sch_type", 0)
5958
+	zone_type, _ := c.GetInt64("zone_type", 0)
5643 5959
 
5644 5960
 	timeLayout := "2006-01-02"
5645 5961
 	loc, _ := time.LoadLocation("Local")
@@ -5666,7 +5982,7 @@ func (c *HisApiController) GetHisOrderList() {
5666 5982
 
5667 5983
 	adminUser := c.GetAdminUserInfo()
5668 5984
 	org_id := adminUser.CurrentOrgId
5669
-	order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type, start_time, end_time, charge_type)
5985
+	order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type, start_time, end_time, charge_type, sch_type, zone_type)
5670 5986
 
5671 5987
 	for _, item := range order {
5672 5988
 		info, _ := service.GetHisPrescriptionByPatientID(item.PatientId, item.UserOrgId)
@@ -6208,12 +6524,6 @@ func (c *HisApiController) GetUploadInfo() {
6208 6524
 	pay_way, _ := c.GetInt64("pay_way")
6209 6525
 	pay_ways := c.GetString("pay_ways")
6210 6526
 
6211
-	cash_pay := c.GetString("cash_pay")
6212
-	band_card_pay := c.GetString("band_card_pay")
6213
-	wechat_pay := c.GetString("wechat_pay")
6214
-	ali_pay := c.GetString("ali_pay")
6215
-	jifen_pay := c.GetString("jifen_pay")
6216
-
6217 6527
 	pay_price, _ := c.GetFloat("pay_price")
6218 6528
 	pay_card_no := c.GetString("pay_card_no")
6219 6529
 	discount_price, _ := c.GetFloat("discount_price")
@@ -6234,6 +6544,12 @@ func (c *HisApiController) GetUploadInfo() {
6234 6544
 	reg_type, _ := c.GetInt64("p_type")
6235 6545
 	order_id, _ := c.GetInt64("order_id")
6236 6546
 
6547
+	cash_pay := c.GetString("cash_pay")
6548
+	wechat_pay := c.GetString("wechat_pay")
6549
+	ali_pay := c.GetString("ali_pay")
6550
+	jifen_pay := c.GetString("jifen_pay")
6551
+	band_card_pay := c.GetString("band_card_pay")
6552
+
6237 6553
 	dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
6238 6554
 	tmp_decimal := c.GetString("tmp_decimal")
6239 6555
 	var decimal float64 //本次使用的押金
@@ -6261,10 +6577,7 @@ func (c *HisApiController) GetUploadInfo() {
6261 6577
 	}
6262 6578
 	tt, errs := strconv.ParseFloat(tmp_decimal, 64)
6263 6579
 	fmt.Println(errs)
6264
-	//if errs != nil {
6265
-	//	c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
6266
-	//	return
6267
-	//}
6580
+
6268 6581
 	decimal = tt
6269 6582
 
6270 6583
 	his, _ := service.GetHisPatientByIdThreeTX(his_patient_id, tx)
@@ -6831,232 +7144,8 @@ func (c *HisApiController) GetUploadInfo() {
6831 7144
 			})
6832 7145
 
6833 7146
 		}
6834
-	} else {
6835
-		if tempOrder.IsPre > 0 {
6836
-			allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
6837
-			totals, _ := strconv.ParseFloat(allTotal, 64)
6838
-			tempOrder.OrderStatus = 2
6839
-			tempOrder.PayWay = pay_way
6840
-			tempOrder.PayPrice = pay_price
6841
-			tempOrder.PayCardNo = pay_card_no
6842
-			tempOrder.DiscountPrice = discount_price
6843
-			tempOrder.PreferentialPrice = preferential_price
6844
-			tempOrder.RealityPrice = reality_price
6845
-			tempOrder.FoundPrice = found_price
6846
-			tempOrder.MedicalInsurancePrice = medical_insurance_price
6847
-			tempOrder.PrivatePrice = private_price
6848
-			tempOrder.FaPiaoCode = fapiao_code
6849
-			tempOrder.FaPiaoNumber = fapiao_number
6850
-			tempOrder.PType = 2
6851
-			tempOrder.MedfeeSumamt = totals
6852
-			tempOrder.Diagnosis = diagnosis_id
6853
-			err = service.SaveHisOrder(&tempOrder)
6854
-			err = service.UpdataOrderStatusTwo(tempOrder.Number, adminUser.CurrentOrgId)
6855
-			if err != nil {
6856
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
6857
-				return
6858
-			}
6859
-			if err == nil {
6860
-				houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
6861
-				var goods []*models.DialysisBeforePrepareGoods
6862
-				var newGoods []*models.NewDialysisBeforePrepareGoods
6863
-				var infos []*models.HisDoctorAdviceInfo
6864
-				var hisAdvice []*models.HisDoctorAdviceInfo
6865
-				var newGoodOne []*models.NewDialysisBeforePrepareGoods
6866
-				var infolist []*models.HisDoctorAdviceInfo
6867
-				var oldGoods []*models.OldDialysisBeforePrepareGoods
6868
-				for _, info := range prescriptions {
6869
-					if info.Type == 1 {
6870
-						infos = append(infos, info.HisDoctorAdviceInfo...)
6871
-					}
6872
-					if info.Type == 2 {
6873
-						for _, sumItem := range info.HisPrescriptionProject {
6874
-							if sumItem.Type == 3 {
6875
-								var good models.DialysisBeforePrepareGoods
6876
-								var newGood models.NewDialysisBeforePrepareGoods
6877
-								good.GoodId = sumItem.GoodInfo.ID
6878
-								good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6879
-								count, _ := strconv.Atoi(sumItem.Count)
6880
-								good.Count = int64(count)
6881
-								good.StorehouseId = houseConfig.StorehouseOutInfo
6882
-								good.ProjectId = sumItem.ID
6883
-								goods = append(goods, &good)
6884
-
6885
-								newGood.GoodId = sumItem.GoodInfo.ID
6886
-								newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6887
-								count2, _ := strconv.Atoi(sumItem.Count)
6888
-								newGood.Count = int64(count2)
6889
-								newGood.StorehouseId = houseConfig.StorehouseOutInfo
6890
-								newGood.ProjectId = sumItem.ID
6891
-								newGoods = append(newGoods, &newGood)
6892
-							}
6893
-
6894
-						}
6895
-
6896
-					}
6897
-				}
6898
-
6899
-				settConfig, _ := service.GetSettleOpenConfigByOrgId(adminUser.CurrentOrgId)
6900
-				if settConfig.IsOpen == 1 {
6901
-
6902
-					//判断库存的地方
6903
-					for _, info := range prescriptions {
6904
-						if info.Type == 1 {
6905
-							infolist = append(infolist, info.HisDoctorAdviceInfo...)
6906
-
6907
-						}
6908
-						if info.Type == 2 {
6909
-							for _, sumItem := range info.HisPrescriptionProject {
6910
-								if sumItem.Type == 3 {
6911
-									var good models.DialysisBeforePrepareGoods
6912
-									var newGood models.NewDialysisBeforePrepareGoods
6913
-									var oldGood models.OldDialysisBeforePrepareGoods
6914
-									good.GoodId = sumItem.GoodInfo.ID
6915
-									good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6916
-									count, _ := strconv.Atoi(sumItem.Count)
6917
-									good.Count = int64(count)
6918
-									good.StorehouseId = houseConfig.StorehouseOutInfo
6919
-									good.ProjectId = sumItem.ID
6920
-									goods = append(goods, &good)
6921
-
6922
-									newGood.GoodId = sumItem.GoodInfo.ID
6923
-									newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6924
-									count2, _ := strconv.Atoi(sumItem.Count)
6925
-									newGood.Count = int64(count2)
6926
-									newGood.StorehouseId = houseConfig.StorehouseOutInfo
6927
-									newGood.ProjectId = sumItem.ID
6928
-									newGoods = append(newGoods, &newGood)
6929
-
6930
-									oldGood.GoodId = sumItem.GoodInfo.ID
6931
-									oldGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6932
-									count3, _ := strconv.Atoi(sumItem.Count)
6933
-									oldGood.Count = int64(count3)
6934
-									oldGood.StorehouseId = houseConfig.StorehouseOutInfo
6935
-									oldGood.ProjectId = sumItem.ID
6936
-									oldGood.RecordDate = sumItem.RecordDate
6937
-
6938
-									oldGoods = append(oldGoods, &oldGood)
6939
-								}
6940
-							}
6941
-						}
6942
-					}
6943
-
6944
-					for _, info := range prescriptionsOne {
6945
-						if info.Type == 1 {
6946
-							hisAdvice = append(hisAdvice, info.HisDoctorAdviceInfo...)
6947
-						}
6948
-
6949
-						if info.Type == 2 {
6950
-							for _, sumItem := range info.HisPrescriptionProject {
6951
-								if sumItem.Type == 3 {
6952
-									var newGood models.NewDialysisBeforePrepareGoods
6953
-
6954
-									newGood.GoodId = sumItem.GoodInfo.ID
6955
-									newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6956
-									count2, _ := strconv.Atoi(sumItem.Count)
6957
-									newGood.Count = int64(count2)
6958
-									newGood.StorehouseId = houseConfig.StorehouseOutInfo
6959
-									newGood.ProjectId = sumItem.ID
6960
-									newGoodOne = append(newGoodOne, &newGood)
6961
-								}
6962
-							}
6963
-						}
6964
-					}
6965
-
6966
-					//判断
6967
-					for _, itemOne := range infos {
6968
-						for _, itemTwo := range hisAdvice {
6969
-							if itemOne.DrugId == itemTwo.DrugId {
6970
-								itemTwo.Child = append(itemTwo.ChildDoctorAdvice, itemOne)
6971
-							}
6972
-						}
6973
-					}
6974
-
6975
-					for _, itemTwo := range hisAdvice {
6976
-						medical, _ := service.GetBaseDrugMedical(itemTwo.DrugId)
6977
-						var sum_out_count int64
6978
-						for _, itemThree := range itemTwo.Child {
6979
-							var prescribing_number int64
6980
-							stringPrescribingNumber := strconv.FormatFloat(itemThree.PrescribingNumber, 'f', -1, 64)
6981
-							parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
6982
-							if itemThree.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6983
-								prescribing_number = parseIntPrescribingNumber * medical.MinNumber
6984
-							}
6985
-							if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
6986
-								prescribing_number = parseIntPrescribingNumber
6987
-							}
6988
-							if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
6989
-								prescribing_number = parseIntPrescribingNumber
6990
-							}
6991
-							sum_out_count += prescribing_number
6992
-						}
6993
-						houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
6994
-						drugStockOut, _ := service.GetDrugSumOutCountByDrugId(itemTwo.DrugId, adminUser.CurrentOrgId, houseConfig.DrugStorehouseOut)
6995
-
6996
-						if sum_out_count > drugStockOut.FlushCount {
6997
-							c.ServeSuccessJSON(map[string]interface{}{
6998
-								"msg":  "2",
6999
-								"drug": medical,
7000
-							})
7001
-							return
7002
-						}
7003
-					}
7004
-
7005
-					for _, itemOne := range newGoods {
7006
-						for _, item := range newGoodOne {
7007
-							if itemOne.ProjectId == item.ProjectId {
7008
-								item.ChildNewDialysisBeforePrepareGoods = append(item.ChildNewDialysisBeforePrepareGoods, item)
7009
-							}
7010
-						}
7011
-					}
7012
-
7013
-					for _, item := range newGoodOne {
7014
-						var sum_out_count_one int64
7015
-						good, _ := service.GetGoodInformationByGoodIdOne(item.GoodId)
7016
-
7017
-						for _, itemOne := range item.ChildNewDialysisBeforePrepareGoods {
7018
-							sum_out_count_one += itemOne.Count
7019
-						}
7020
-						list, _ := service.GetStockGoodList(item.GoodId, adminUser.CurrentOrgId, houseConfig.StorehouseOutInfo)
7021
-						fmt.Println("sum_out_count_one", sum_out_count_one)
7022
-						fmt.Println("list.FlushCount", list.FlushCount)
7023
-						if sum_out_count_one > list.FlushCount {
7024
-							c.ServeSuccessJSON(map[string]interface{}{
7025
-								"msg":  "3",
7026
-								"good": good,
7027
-							})
7028
-							return
7029
-						}
7030
-					}
7031
-					for _, item := range infolist {
7032
-						service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
7033
-					}
7034
-					for _, item := range oldGoods {
7035
-						dialyPrepareOne := models.DialysisBeforePrepare{
7036
-							GoodTypeId:   item.GoodTypeId,
7037
-							GoodId:       item.GoodId,
7038
-							PatientId:    item.PatientId,
7039
-							RecordDate:   item.RecordDate,
7040
-							UserOrgId:    item.UserOrgId,
7041
-							Count:        item.Count,
7042
-							Ctime:        time.Now().Unix(),
7043
-							Creater:      adminUser.AdminUser.Id,
7044
-							CommdityCode: item.CommdityCode,
7045
-							Status:       1,
7046
-							StorehouseId: houseConfig.StorehouseOutInfo,
7047
-						}
7048
-						err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
7049
-					}
7050
-
7051
-					service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
7052
-				}
7053
-
7054
-				c.ServeSuccessJSON(map[string]interface{}{
7055
-					"msg": "结算成功",
7056
-				})
7057
-			}
7058
-		}
7059 7147
 	}
7148
+
7060 7149
 }
7061 7150
 
7062 7151
 // 退款
@@ -9191,96 +9280,198 @@ func (c *HisApiController) CreateHisPrescriptionTemplate() {
9191 9280
 		return
9192 9281
 	}
9193 9282
 
9194
-	err = service.CreateHisPrescriptionTemplate(template)
9195
-	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
9196
-		prescriptions, _ := dataBody["prescriptions"].([]interface{})
9197
-		if len(prescriptions) > 0 {
9198
-			for _, item := range prescriptions {
9199
-				items := item.(map[string]interface{})
9200
-				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
9201
-					utils.ErrorLog("type")
9202
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9203
-					return
9204
-				}
9205
-				types := int64(items["type"].(float64))
9283
+	template_one, _ := service.GetHisPrescriptionTemplateByModeId(mode_id, patient_id, c.GetAdminUserInfo().CurrentOrgId)
9206 9284
 
9207
-				if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
9208
-					utils.ErrorLog("med_type")
9209
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9210
-					return
9211
-				}
9212
-				med_type := strconv.Itoa(int(items["med_type"].(float64)))
9285
+	//如果已经存在记录则删除处方
9286
+	if template_one.ID > 0 {
9287
+		ps, _ := service.GetHisPrescriptionInfoTemplates(template_one.ID, template_one.UserOrgId)
9288
+		for _, item := range ps {
9289
+			service.DelelteHisPrescriptionInfoTemplate(item.ID, item.UserOrgId)
9290
+		}
9291
+		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
9292
+			prescriptions, _ := dataBody["prescriptions"].([]interface{})
9293
+			if len(prescriptions) > 0 {
9294
+				for _, item := range prescriptions {
9295
+					items := item.(map[string]interface{})
9296
+					if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
9297
+						utils.ErrorLog("type")
9298
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9299
+						return
9300
+					}
9301
+					types := int64(items["type"].(float64))
9213 9302
 
9214
-				ctime := time.Now().Unix()
9215
-				prescription := &models.HisPrescriptionInfoTemplate{
9216
-					PatientId:   patient_id,
9217
-					UserOrgId:   adminInfo.CurrentOrgId,
9218
-					Ctime:       ctime,
9219
-					Mtime:       ctime,
9220
-					Type:        types,
9221
-					Modifier:    adminInfo.AdminUser.Id,
9222
-					Creator:     adminInfo.AdminUser.Id,
9223
-					Status:      1,
9224
-					PTemplateId: template.ID,
9225
-					MedType:     med_type,
9226
-				}
9227
-				service.CreateHisPrescriptionInfoTemplate(prescription)
9303
+					if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
9304
+						utils.ErrorLog("med_type")
9305
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9306
+						return
9307
+					}
9308
+					med_type := strconv.Itoa(int(items["med_type"].(float64)))
9228 9309
 
9229
-				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
9230
-					advices := items["advices"].([]interface{})
9231
-					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
9232 9310
 					ctime := time.Now().Unix()
9233
-					mtime := ctime
9234
-					if len(advices) > 0 {
9235
-						for _, advice := range advices {
9236
-							var s models.HisPrescriptionAdviceTemplate
9237
-							s.PrescriptionId = prescription.ID
9238
-							s.AdviceType = 2
9239
-							s.StopState = 2
9240
-							s.ExecutionState = 2
9241
-							s.Status = 1
9242
-							s.UserOrgId = adminInfo.CurrentOrgId
9243
-							s.CreatedTime = ctime
9244
-							s.UpdatedTime = mtime
9245
-							s.PatientId = patient_id
9246
-							errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
9247
-							if errcode > 0 {
9248
-								c.ServeFailJSONWithSGJErrorCode(errcode)
9249
-								return
9250
-							}
9311
+					prescription := &models.HisPrescriptionInfoTemplate{
9312
+						PatientId:   patient_id,
9313
+						UserOrgId:   adminInfo.CurrentOrgId,
9314
+						Ctime:       ctime,
9315
+						Mtime:       ctime,
9316
+						Type:        types,
9317
+						Modifier:    adminInfo.AdminUser.Id,
9318
+						Creator:     adminInfo.AdminUser.Id,
9319
+						Status:      1,
9320
+						PTemplateId: template_one.ID,
9321
+						MedType:     med_type,
9322
+					}
9323
+					service.CreateHisPrescriptionInfoTemplate(prescription)
9251 9324
 
9252
-							service.CreateHisPrescriptionAdviceTemplate(&s)
9325
+					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
9326
+						advices := items["advices"].([]interface{})
9327
+						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
9328
+						ctime := time.Now().Unix()
9329
+						mtime := ctime
9330
+						if len(advices) > 0 {
9331
+							for _, advice := range advices {
9332
+								var s models.HisPrescriptionAdviceTemplate
9333
+								s.PrescriptionId = prescription.ID
9334
+								s.AdviceType = 2
9335
+								s.StopState = 2
9336
+								s.ExecutionState = 2
9337
+								s.Status = 1
9338
+								s.UserOrgId = adminInfo.CurrentOrgId
9339
+								s.CreatedTime = ctime
9340
+								s.UpdatedTime = mtime
9341
+								s.PatientId = patient_id
9342
+								errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
9343
+								if errcode > 0 {
9344
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9345
+									return
9346
+								}
9347
+
9348
+								service.CreateHisPrescriptionAdviceTemplate(&s)
9253 9349
 
9350
+							}
9254 9351
 						}
9255 9352
 					}
9353
+					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
9354
+						projects := items["project"].([]interface{})
9355
+						if len(projects) > 0 {
9356
+							for _, project := range projects {
9357
+								var p models.HisPrescriptionProjectTemplate
9358
+								p.PrescriptionId = prescription.ID
9359
+								p.Ctime = time.Now().Unix()
9360
+								p.Mtime = time.Now().Unix()
9361
+								p.PatientId = patient_id
9362
+								p.UserOrgId = adminInfo.CurrentOrgId
9363
+								p.Status = 1
9364
+								errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
9365
+								if errcode > 0 {
9366
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9367
+									return
9368
+								}
9369
+								service.CreateHisPrescriptionProjectTemplate(&p)
9370
+
9371
+							}
9372
+						}
9373
+					}
9374
+
9256 9375
 				}
9257
-				if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
9258
-					projects := items["project"].([]interface{})
9259
-					if len(projects) > 0 {
9260
-						for _, project := range projects {
9261
-							var p models.HisPrescriptionProjectTemplate
9262
-							p.PrescriptionId = prescription.ID
9263
-							p.Ctime = time.Now().Unix()
9264
-							p.Mtime = time.Now().Unix()
9265
-							p.PatientId = patient_id
9266
-							p.UserOrgId = adminInfo.CurrentOrgId
9267
-							p.Status = 1
9268
-							errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
9269
-							if errcode > 0 {
9270
-								c.ServeFailJSONWithSGJErrorCode(errcode)
9271
-								return
9376
+
9377
+				c.ServeSuccessJSON(map[string]interface{}{
9378
+					"msg": "创建成功",
9379
+				})
9380
+			}
9381
+		}
9382
+
9383
+	} else {
9384
+		err = service.CreateHisPrescriptionTemplate(template)
9385
+		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
9386
+			prescriptions, _ := dataBody["prescriptions"].([]interface{})
9387
+			if len(prescriptions) > 0 {
9388
+				for _, item := range prescriptions {
9389
+					items := item.(map[string]interface{})
9390
+					if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
9391
+						utils.ErrorLog("type")
9392
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9393
+						return
9394
+					}
9395
+					types := int64(items["type"].(float64))
9396
+
9397
+					if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
9398
+						utils.ErrorLog("med_type")
9399
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9400
+						return
9401
+					}
9402
+					med_type := strconv.Itoa(int(items["med_type"].(float64)))
9403
+
9404
+					ctime := time.Now().Unix()
9405
+					prescription := &models.HisPrescriptionInfoTemplate{
9406
+						PatientId:   patient_id,
9407
+						UserOrgId:   adminInfo.CurrentOrgId,
9408
+						Ctime:       ctime,
9409
+						Mtime:       ctime,
9410
+						Type:        types,
9411
+						Modifier:    adminInfo.AdminUser.Id,
9412
+						Creator:     adminInfo.AdminUser.Id,
9413
+						Status:      1,
9414
+						PTemplateId: template.ID,
9415
+						MedType:     med_type,
9416
+					}
9417
+					service.CreateHisPrescriptionInfoTemplate(prescription)
9418
+
9419
+					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
9420
+						advices := items["advices"].([]interface{})
9421
+						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
9422
+						ctime := time.Now().Unix()
9423
+						mtime := ctime
9424
+						if len(advices) > 0 {
9425
+							for _, advice := range advices {
9426
+								var s models.HisPrescriptionAdviceTemplate
9427
+								s.PrescriptionId = prescription.ID
9428
+								s.AdviceType = 2
9429
+								s.StopState = 2
9430
+								s.ExecutionState = 2
9431
+								s.Status = 1
9432
+								s.UserOrgId = adminInfo.CurrentOrgId
9433
+								s.CreatedTime = ctime
9434
+								s.UpdatedTime = mtime
9435
+								s.PatientId = patient_id
9436
+								errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
9437
+								if errcode > 0 {
9438
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9439
+									return
9440
+								}
9441
+
9442
+								service.CreateHisPrescriptionAdviceTemplate(&s)
9443
+
9272 9444
 							}
9273
-							service.CreateHisPrescriptionProjectTemplate(&p)
9445
+						}
9446
+					}
9447
+					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
9448
+						projects := items["project"].([]interface{})
9449
+						if len(projects) > 0 {
9450
+							for _, project := range projects {
9451
+								var p models.HisPrescriptionProjectTemplate
9452
+								p.PrescriptionId = prescription.ID
9453
+								p.Ctime = time.Now().Unix()
9454
+								p.Mtime = time.Now().Unix()
9455
+								p.PatientId = patient_id
9456
+								p.UserOrgId = adminInfo.CurrentOrgId
9457
+								p.Status = 1
9458
+								errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
9459
+								if errcode > 0 {
9460
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9461
+									return
9462
+								}
9463
+								service.CreateHisPrescriptionProjectTemplate(&p)
9274 9464
 
9465
+							}
9275 9466
 						}
9276 9467
 					}
9468
+
9277 9469
 				}
9278 9470
 
9471
+				c.ServeSuccessJSON(map[string]interface{}{
9472
+					"msg": "创建成功",
9473
+				})
9279 9474
 			}
9280
-
9281
-			c.ServeSuccessJSON(map[string]interface{}{
9282
-				"msg": "创建成功",
9283
-			})
9284 9475
 		}
9285 9476
 	}
9286 9477
 

+ 16 - 1
controllers/his_charge_api_controller.go View File

@@ -299,6 +299,7 @@ func (c *HisChargeApiController) GetHisInspectionList() {
299 299
 	is_print, _ := c.GetInt64("is_print")
300 300
 	page, _ := c.GetInt64("page")
301 301
 	limit, _ := c.GetInt64("limit")
302
+	tube_color, _ := c.GetInt64("tube_color")
302 303
 
303 304
 	adminUser := c.GetAdminUserInfo()
304 305
 
@@ -309,7 +310,21 @@ func (c *HisChargeApiController) GetHisInspectionList() {
309 310
 
310 311
 	}
311 312
 	record_time := startTime.Unix()
312
-	labels, total, err := service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword)
313
+	var labels []*models.HisLabelPrintInfo
314
+	var labels_two []*models.HisLabelPrintInfo
315
+
316
+	var total int64
317
+	var total_two int64
318
+	//var err error
319
+	if tube_color == 0 {
320
+		labels, total, err = service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
321
+	} else {
322
+		labels, total, err = service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
323
+		labels_two, total_two, err = service.GetLabelPrintListTwo(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
324
+		total = total + total_two
325
+		labels = append(labels, labels_two...)
326
+	}
327
+
313 328
 	if err == nil {
314 329
 
315 330
 		c.ServeSuccessJSON(map[string]interface{}{

+ 112 - 77
controllers/manage_api_controller.go View File

@@ -993,9 +993,19 @@ func (this *MachineApiController) SaveInformation() {
993 993
 	contagion := dataBody["contagion"].(string)
994 994
 	dialysis_mode := int64(dataBody["dialysis_mode"].(float64))
995 995
 	startDateStr := dataBody["start_time"].(string)
996
-	startDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
996
+	var startDataUnix int64
997
+	if len(startDateStr) > 0 {
998
+		startDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
999
+		startDataUnix = startDate.Unix()
1000
+	}
1001
+
997 1002
 	endDateStr := dataBody["end_time"].(string)
998
-	endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", endDateStr)
1003
+	var endDateUnix int64
1004
+	if len(endDateStr) > 0 {
1005
+		endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", endDateStr)
1006
+		endDateUnix = endDate.Unix()
1007
+	}
1008
+
999 1009
 	dialysis_time := dataBody["dialysis_time"].(string)
1000 1010
 	hyperfiletration := dataBody["hyperfiltratio"].(float64)
1001 1011
 	weight_loss := dataBody["weight_loss"].(float64)
@@ -1018,9 +1028,19 @@ func (this *MachineApiController) SaveInformation() {
1018 1028
 	disinfection_residue := int64(dataBody["disinfection_residue"].(float64))
1019 1029
 	longtime := dataBody["longtime"].(string)
1020 1030
 	start_DateStr := dataBody["starttime"].(string)
1021
-	start_Date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", start_DateStr)
1031
+	var start_DateStr_Unix int64
1032
+	if len(start_DateStr) > 0 {
1033
+		start_Date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", start_DateStr)
1034
+		start_DateStr_Unix = start_Date.Unix()
1035
+	}
1036
+
1022 1037
 	end_DateStr := dataBody["endtime"].(string)
1023
-	end_Date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", end_DateStr)
1038
+	var end_DateStr_Unix int64
1039
+	if len(end_DateStr) > 0 {
1040
+		end_Date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", end_DateStr)
1041
+		end_DateStr_Unix = end_Date.Unix()
1042
+	}
1043
+
1024 1044
 	dialysis_checked := int64(dataBody["dialysis_checked"].(float64))
1025 1045
 
1026 1046
 	dialysis_name := int64(dataBody["dialysis_name"].(float64))
@@ -1040,7 +1060,7 @@ func (this *MachineApiController) SaveInformation() {
1040 1060
 	sign_name := int64(dataBody["sign_name"].(float64))
1041 1061
 
1042 1062
 	information, errinfor := service.GetInformation(eid, startdate, orgid, classtype)
1043
-	fmt.Print("errinfor", errinfor)
1063
+
1044 1064
 	fmt.Print("information", information)
1045 1065
 
1046 1066
 	//获取该机器最后一次的透析次数
@@ -1061,8 +1081,8 @@ func (this *MachineApiController) SaveInformation() {
1061 1081
 				PatientId:             patient_time,
1062 1082
 				Contagion:             contagion,
1063 1083
 				DialysisMode:          dialysis_mode,
1064
-				StartTime:             startDate.Unix(),
1065
-				EndTime:               endDate.Unix(),
1084
+				StartTime:             startDataUnix,
1085
+				EndTime:               endDateUnix,
1066 1086
 				DialysisHour:          dialysis_time,
1067 1087
 				Hyperfiltratio:        hyperfiletration,
1068 1088
 				WeightLoss:            weight_loss,
@@ -1081,8 +1101,8 @@ func (this *MachineApiController) SaveInformation() {
1081 1101
 				DisinfectionStatus:    disinfection_status,
1082 1102
 				DisinfectionResidue:   disinfection_residue,
1083 1103
 				LongTime:              longtime,
1084
-				DisinfecStartime:      start_Date.Unix(),
1085
-				DisinfecEndtime:       end_Date.Unix(),
1104
+				DisinfecStartime:      start_DateStr_Unix,
1105
+				DisinfecEndtime:       end_DateStr_Unix,
1086 1106
 				DialysisChecked:       dialysis_checked,
1087 1107
 				DialysisName:          dialysis_name,
1088 1108
 				Norms:                 norms,
@@ -1116,8 +1136,8 @@ func (this *MachineApiController) SaveInformation() {
1116 1136
 				PatientId:             patient_time,
1117 1137
 				Contagion:             contagion,
1118 1138
 				DialysisMode:          dialysis_mode,
1119
-				StartTime:             startDate.Unix(),
1120
-				EndTime:               endDate.Unix(),
1139
+				StartTime:             startDataUnix,
1140
+				EndTime:               endDateUnix,
1121 1141
 				DialysisHour:          dialysis_time,
1122 1142
 				Hyperfiltratio:        hyperfiletration,
1123 1143
 				WeightLoss:            weight_loss,
@@ -1136,8 +1156,8 @@ func (this *MachineApiController) SaveInformation() {
1136 1156
 				DisinfectionStatus:    disinfection_status,
1137 1157
 				DisinfectionResidue:   disinfection_residue,
1138 1158
 				LongTime:              longtime,
1139
-				DisinfecStartime:      start_Date.Unix(),
1140
-				DisinfecEndtime:       end_Date.Unix(),
1159
+				DisinfecStartime:      start_DateStr_Unix,
1160
+				DisinfecEndtime:       end_DateStr_Unix,
1141 1161
 				DialysisChecked:       dialysis_checked,
1142 1162
 				DialysisName:          dialysis_name,
1143 1163
 				Norms:                 norms,
@@ -1178,8 +1198,8 @@ func (this *MachineApiController) SaveInformation() {
1178 1198
 				PatientId:             patient_time,
1179 1199
 				Contagion:             contagion,
1180 1200
 				DialysisMode:          dialysis_mode,
1181
-				StartTime:             startDate.Unix(),
1182
-				EndTime:               endDate.Unix(),
1201
+				StartTime:             startDataUnix,
1202
+				EndTime:               endDateUnix,
1183 1203
 				DialysisHour:          dialysis_time,
1184 1204
 				Hyperfiltratio:        hyperfiletration,
1185 1205
 				WeightLoss:            weight_loss,
@@ -1198,8 +1218,8 @@ func (this *MachineApiController) SaveInformation() {
1198 1218
 				DisinfectionStatus:    disinfection_status,
1199 1219
 				DisinfectionResidue:   disinfection_residue,
1200 1220
 				LongTime:              longtime,
1201
-				DisinfecStartime:      start_Date.Unix(),
1202
-				DisinfecEndtime:       end_Date.Unix(),
1221
+				DisinfecStartime:      start_DateStr_Unix,
1222
+				DisinfecEndtime:       end_DateStr_Unix,
1203 1223
 				DialysisChecked:       dialysis_checked,
1204 1224
 				DialysisName:          dialysis_name,
1205 1225
 				Norms:                 norms,
@@ -1233,8 +1253,8 @@ func (this *MachineApiController) SaveInformation() {
1233 1253
 				PatientId:             patient_time,
1234 1254
 				Contagion:             contagion,
1235 1255
 				DialysisMode:          dialysis_mode,
1236
-				StartTime:             startDate.Unix(),
1237
-				EndTime:               endDate.Unix(),
1256
+				StartTime:             startDataUnix,
1257
+				EndTime:               endDateUnix,
1238 1258
 				DialysisHour:          dialysis_time,
1239 1259
 				Hyperfiltratio:        hyperfiletration,
1240 1260
 				WeightLoss:            weight_loss,
@@ -1253,8 +1273,8 @@ func (this *MachineApiController) SaveInformation() {
1253 1273
 				DisinfectionStatus:    disinfection_status,
1254 1274
 				DisinfectionResidue:   disinfection_residue,
1255 1275
 				LongTime:              longtime,
1256
-				DisinfecStartime:      start_Date.Unix(),
1257
-				DisinfecEndtime:       end_Date.Unix(),
1276
+				DisinfecStartime:      start_DateStr_Unix,
1277
+				DisinfecEndtime:       end_DateStr_Unix,
1258 1278
 				DialysisChecked:       dialysis_checked,
1259 1279
 				DialysisName:          dialysis_name,
1260 1280
 				Norms:                 norms,
@@ -2018,83 +2038,78 @@ func (this *MachineApiController) SaveRepair() {
2018 2038
 	loc, _ := time.LoadLocation("Local")
2019 2039
 	adminUserInfo := this.GetAdminUserInfo()
2020 2040
 	id, _ := this.GetInt64("id")
2021
-	fmt.Println("id", id)
2041
+
2022 2042
 	addmacher, _ := service.GetBedId(id)
2023 2043
 	OrgID := adminUserInfo.CurrentOrgId
2024
-	fmt.Println("orgid", OrgID)
2044
+
2025 2045
 	dataBody := make(map[string]interface{}, 0)
2026 2046
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
2027 2047
 	fmt.Println("err", err)
2028 2048
 	gua_date := dataBody["guarantee_date"].(string)
2029
-	fmt.Println("保修日期", gua_date)
2049
+
2030 2050
 	inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", gua_date+" 00:00:00", loc)
2031 2051
 	guaDate := inLocation.Unix()
2032
-	fmt.Println("保修日期", guaDate)
2033 2052
 
2034 2053
 	startDateStr := dataBody["start_time"].(string)
2035
-	fmt.Println("出发时间", startDateStr)
2054
+
2036 2055
 	startDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
2037
-	fmt.Println("触发事件", startDate.Unix())
2038 2056
 
2039 2057
 	arriveDateStr := dataBody["arrive_time"].(string)
2040
-	fmt.Println("到达时间", arriveDateStr)
2058
+
2041 2059
 	arriveDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", arriveDateStr)
2042
-	fmt.Println("到达时间", arriveDate.Unix())
2043 2060
 
2044 2061
 	finishDateStr := dataBody["finish_time"].(string)
2045
-	fmt.Println("完成时间", finishDateStr)
2062
+
2046 2063
 	finishDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", finishDateStr)
2047
-	fmt.Println("完成时间", finishDate.Unix())
2048 2064
 
2049 2065
 	totaldistance := dataBody["total_distance"].(string)
2050
-	fmt.Println("总公里输", totaldistance)
2051 2066
 
2052 2067
 	failurestate := int64(dataBody["failure_stage"].(float64))
2053
-	fmt.Println("故事范式阶段", failurestate)
2054 2068
 
2055 2069
 	codeInformation := dataBody["code_information"].(string)
2056
-	fmt.Println("故事提示信息及代码", codeInformation)
2057 2070
 
2058 2071
 	faultdescription := dataBody["fault_description"].(string)
2059
-	fmt.Println("故障描述", faultdescription)
2060 2072
 
2061 2073
 	causeAnalysis := dataBody["cause_analysis"].(string)
2062
-	fmt.Println("原因分析", causeAnalysis)
2063 2074
 
2064 2075
 	treatmentprocess := dataBody["treatment_process"].(string)
2065
-	fmt.Println("处理过程", treatmentprocess)
2066 2076
 
2067 2077
 	images := dataBody["images"].(string)
2068
-	fmt.Println("上传图片", images)
2069 2078
 
2070 2079
 	exclude := int64(dataBody["exclude"].(float64))
2071
-	fmt.Println("故障是否排除", exclude)
2072 2080
 
2073 2081
 	reason := dataBody["reason"].(string)
2074
-	fmt.Println("原因", reason)
2075 2082
 
2076 2083
 	imageName := dataBody["imageName"].(string)
2077 2084
 
2085
+	function_accessories_inspection := dataBody["function_accessories_inspection"].(string)
2086
+
2087
+	other_information := dataBody["other_information"].(string)
2088
+
2089
+	admin_user_id := int64(dataBody["admin_user_id"].(float64))
2078 2090
 	repair := models.DeviceRepair{
2079
-		BedId:            addmacher.BedId,
2080
-		EquitmentId:      id,
2081
-		GuaranteeDate:    guaDate,
2082
-		StartTime:        startDate.Unix(),
2083
-		ArriveTime:       arriveDate.Unix(),
2084
-		FinishTime:       finishDate.Unix(),
2085
-		TotalDistance:    totaldistance,
2086
-		FailureStage:     failurestate,
2087
-		FaultDescription: faultdescription,
2088
-		CauseAnalysis:    causeAnalysis,
2089
-		TreatmentProcess: treatmentprocess,
2090
-		Images:           images,
2091
-		Exclude:          exclude,
2092
-		Reason:           reason,
2093
-		Status:           1,
2094
-		UserOrgId:        OrgID,
2095
-		Ctime:            time.Now().Unix(),
2096
-		CodeInformation:  codeInformation,
2097
-		ImageName:        imageName,
2091
+		BedId:                         addmacher.BedId,
2092
+		EquitmentId:                   id,
2093
+		GuaranteeDate:                 guaDate,
2094
+		StartTime:                     startDate.Unix(),
2095
+		ArriveTime:                    arriveDate.Unix(),
2096
+		FinishTime:                    finishDate.Unix(),
2097
+		TotalDistance:                 totaldistance,
2098
+		FailureStage:                  failurestate,
2099
+		FaultDescription:              faultdescription,
2100
+		CauseAnalysis:                 causeAnalysis,
2101
+		TreatmentProcess:              treatmentprocess,
2102
+		Images:                        images,
2103
+		Exclude:                       exclude,
2104
+		Reason:                        reason,
2105
+		Status:                        1,
2106
+		UserOrgId:                     OrgID,
2107
+		Ctime:                         time.Now().Unix(),
2108
+		CodeInformation:               codeInformation,
2109
+		ImageName:                     imageName,
2110
+		FunctionAccessoriesInspection: function_accessories_inspection,
2111
+		OtherInformation:              other_information,
2112
+		AdminUserId:                   admin_user_id,
2098 2113
 	}
2099 2114
 	err = service.CreateRepair(&repair)
2100 2115
 	if err != nil {
@@ -2111,27 +2126,38 @@ func (this *MachineApiController) GetAllRepair() {
2111 2126
 	page, _ := this.GetInt64("page")
2112 2127
 	adminUser := this.GetAdminUserInfo()
2113 2128
 	orgID := adminUser.CurrentOrgId
2129
+	appId := adminUser.CurrentAppId
2114 2130
 	repair, total, err := service.GetAllRepair(orgID, limit, page)
2131
+
2132
+	addmacher, _ := service.GetAllMachineByOrgId(orgID)
2133
+
2134
+	docList, _ := service.GetAllDoctor(orgID, appId)
2115 2135
 	if err != nil {
2116 2136
 		this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
2117 2137
 		return
2118 2138
 	}
2119 2139
 	this.ServeSuccessJSON(map[string]interface{}{
2120
-		"repair": repair,
2121
-		"total":  total,
2140
+		"repair":     repair,
2141
+		"total":      total,
2142
+		"macherList": addmacher,
2143
+		"docList":    docList,
2122 2144
 	})
2123 2145
 }
2124 2146
 
2125 2147
 func (this *MachineApiController) EditRepair() {
2126 2148
 	id, _ := this.GetInt64("id")
2127
-	fmt.Println("id", id)
2149
+
2150
+	appId := this.GetAdminUserInfo().CurrentAppId
2151
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2128 2152
 	repair, err := service.EditRepair(id)
2153
+	docList, _ := service.GetAllDoctor(orgId, appId)
2129 2154
 	if err != nil {
2130 2155
 		this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
2131 2156
 		return
2132 2157
 	}
2133 2158
 	this.ServeSuccessJSON(map[string]interface{}{
2134
-		"repair": repair,
2159
+		"repair":  repair,
2160
+		"docList": docList,
2135 2161
 	})
2136 2162
 }
2137 2163
 
@@ -2194,21 +2220,30 @@ func (this *MachineApiController) UpdateRepair() {
2194 2220
 	fmt.Println("原因", reason)
2195 2221
 
2196 2222
 	imageName := dataBody["image_name"].(string)
2223
+
2224
+	function_accessories_inspection := dataBody["function_accessories_inspection"].(string)
2225
+
2226
+	other_information := dataBody["other_information"].(string)
2227
+
2228
+	admin_user_id := int64(dataBody["admin_user_id"].(float64))
2197 2229
 	deviceRepair := models.DeviceRepair{
2198
-		GuaranteeDate:    guaDate,
2199
-		StartTime:        startDate.Unix(),
2200
-		ArriveTime:       arriveDate.Unix(),
2201
-		FinishTime:       finishDate.Unix(),
2202
-		TotalDistance:    totaldistance,
2203
-		FailureStage:     failurestate,
2204
-		FaultDescription: faultdescription,
2205
-		CauseAnalysis:    causeAnalysis,
2206
-		TreatmentProcess: treatmentprocess,
2207
-		Images:           images,
2208
-		Exclude:          exclude,
2209
-		Reason:           reason,
2210
-		CodeInformation:  codeInformation,
2211
-		ImageName:        imageName,
2230
+		GuaranteeDate:                 guaDate,
2231
+		StartTime:                     startDate.Unix(),
2232
+		ArriveTime:                    arriveDate.Unix(),
2233
+		FinishTime:                    finishDate.Unix(),
2234
+		TotalDistance:                 totaldistance,
2235
+		FailureStage:                  failurestate,
2236
+		FaultDescription:              faultdescription,
2237
+		CauseAnalysis:                 causeAnalysis,
2238
+		TreatmentProcess:              treatmentprocess,
2239
+		Images:                        images,
2240
+		Exclude:                       exclude,
2241
+		Reason:                        reason,
2242
+		CodeInformation:               codeInformation,
2243
+		ImageName:                     imageName,
2244
+		FunctionAccessoriesInspection: function_accessories_inspection,
2245
+		OtherInformation:              other_information,
2246
+		AdminUserId:                   admin_user_id,
2212 2247
 	}
2213 2248
 	err = service.UpdateRepair(id, OrgID, &deviceRepair)
2214 2249
 	if err != nil {

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -674,7 +674,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
674 674
 				evaluation.Phinholing = lastPredialysisEvaluation.Phinholing                   //针眼
675 675
 				evaluation.Remark = lastPredialysisEvaluation.Remark
676 676
 				if adminUserInfo.Org.Id == 10318 {
677
-					evaluation.Remark = "患者已确认无发热,无流行病学接触史"
677
+					evaluation.Remark = ""
678 678
 				}
679 679
 				if adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10447 {
680 680
 					evaluation.BreathingRate = "20"

+ 85 - 16
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -1772,7 +1772,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1772 1772
 				}
1773 1773
 
1774 1774
 				if schedulePatient.ScheduleType == 2 {
1775
-					advice.StartTime = recordDate.Unix() + 11*60*60
1775
+					advice.StartTime = recordDate.Unix() + 10*60*60
1776 1776
 				}
1777 1777
 			}
1778 1778
 			// 抗凝剂名称
@@ -2804,9 +2804,12 @@ func (this *DialysisAPIController) StartDialysis() {
2804 2804
 
2805 2805
 			//针对肇庆三鹤血液透析中心
2806 2806
 
2807
-			if template.TemplateId == 43 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10441 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 {
2807
+			if template.TemplateId == 43 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10441 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10440 {
2808 2808
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2809
+			}
2809 2810
 
2811
+			if adminUserInfo.Org.Id == 10469 {
2812
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 60 / float64(totalMin))
2810 2813
 			}
2811 2814
 
2812 2815
 			if template.TemplateId == 20 || template.TemplateId == 22 { //adminUserInfo.Org.Id == 9538
@@ -2819,9 +2822,11 @@ func (this *DialysisAPIController) StartDialysis() {
2819 2822
 				ultrafiltration_rate = value
2820 2823
 			}
2821 2824
 
2822
-			//针对医师汇
2823
-			if adminUserInfo.Org.Id == 10471 {
2824
-				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration*60/float64(totalMin)*1000) / 1000
2825
+			//针对
2826
+			if adminUserInfo.Org.Id == 10471 || adminUserInfo.Org.Id == 3877 {
2827
+
2828
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2829
+				ultrafiltration_rate = ultrafiltration_rate / 1000
2825 2830
 			}
2826 2831
 		}
2827 2832
 	}
@@ -3407,7 +3412,7 @@ func (c *DialysisAPIController) PostSolution() {
3407 3412
 			}
3408 3413
 
3409 3414
 			if schedulePatient.ScheduleType == 2 {
3410
-				advice.StartTime = recordDate.Unix() + 11*60*60
3415
+				advice.StartTime = recordDate.Unix() + 10*60*60
3411 3416
 			}
3412 3417
 		}
3413 3418
 		// 抗凝剂名称
@@ -3644,6 +3649,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
3644 3649
 
3645 3650
 	_, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, theAssessmentDateTime, adminInfo.Org.Id)
3646 3651
 	fmt.Println(evaluation)
3652
+
3647 3653
 	if prescription.ID > 0 {
3648 3654
 
3649 3655
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
@@ -3688,21 +3694,25 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
3688 3694
 				record.UltrafiltrationRate = ultrafiltration_rate
3689 3695
 			}
3690 3696
 
3691
-			if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 9829 || adminInfo.Org.Id == 10440 || adminInfo.Org.Id == 10469 {
3697
+			if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 9829 || adminInfo.Org.Id == 10440 {
3692 3698
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
3693 3699
 
3694 3700
 				record.UltrafiltrationRate = ultrafiltration_rate
3695 3701
 			}
3696 3702
 
3697
-			if adminInfo.Org.Id == 10471 {
3698
-				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
3703
+			if adminInfo.Org.Id == 10469 {
3704
+
3705
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 60 / 1000 / float64(totalMin) * 1000)
3706
+
3707
+				record.UltrafiltrationRate = ultrafiltration_rate
3699 3708
 
3700
-				record.UltrafiltrationRate = ultrafiltration_rate / 1000
3701 3709
 			}
3702 3710
 
3703 3711
 			if adminInfo.Org.Id == 10471 {
3704
-				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
3712
+
3713
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3705 3714
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
3715
+
3706 3716
 			}
3707 3717
 			//if template.TemplateId == 47 {
3708 3718
 			//	ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
@@ -4289,9 +4299,9 @@ func (c *DialysisAPIController) GetLongAdviceOne() {
4289 4299
 		var advice_three []*models.DoctorAdvice
4290 4300
 
4291 4301
 		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.Org.Id, patient_id, theStartTime)
4292
-		fmt.Println("advices++++++++++++++++", advices)
4302
+
4293 4303
 		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.Org.Id, patient_id, theStartTime)
4294
-		fmt.Println("advices_two------------------------", advices_two)
4304
+
4295 4305
 		for _, advice := range advices {
4296 4306
 			if advice.FrequencyType == 3 {
4297 4307
 				t := time.Now()
@@ -5733,6 +5743,7 @@ func (c *DialysisAPIController) EditConsumables() {
5733 5743
 					count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
5734 5744
 
5735 5745
 					commdity_code := items["commdity_code"].(string)
5746
+
5736 5747
 					fmt.Println(commdity_code)
5737 5748
 
5738 5749
 					prepareGoods := &models.DialysisBeforePrepareGoods{
@@ -6081,11 +6092,10 @@ func (c *DialysisAPIController) EditConsumables() {
6081 6092
 					}
6082 6093
 				}
6083 6094
 
6084
-				fmt.Println("lnet---------------------------", len(outbefor))
6085 6095
 				if len(outbefor) > 0 {
6086 6096
 					//出库
6087 6097
 					for _, item := range outbefor {
6088
-						fmt.Println("出库ID", item.GoodId)
6098
+
6089 6099
 						var last_total int64
6090 6100
 						//1.查看该患者该耗材型号最后一次出库数量
6091 6101
 						goodInfoOne, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
@@ -6142,7 +6152,6 @@ func (c *DialysisAPIController) EditConsumables() {
6142 6152
 							//1.查看该患者该耗材型号最后一次出库数量
6143 6153
 							goodInfoTwo, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
6144 6154
 
6145
-							fmt.Println("count2323323222323wi", item.Count)
6146 6155
 							prepare := models.DialysisBeforePrepare{
6147 6156
 								UserOrgId:    adminInfo.Org.Id,
6148 6157
 								PatientId:    patient_id,
@@ -6200,6 +6209,7 @@ func (c *DialysisAPIController) EditConsumables() {
6200 6209
 						Creater:      adminInfo.AdminUser.Id,
6201 6210
 						Status:       1,
6202 6211
 						StorehouseId: houseConfig.StorehouseOutInfo,
6212
+						ProjectId:    it.ProjectId,
6203 6213
 					}
6204 6214
 					//删除准备表数据
6205 6215
 					service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, it.GoodId, it.GoodTypeId)
@@ -7936,9 +7946,68 @@ func (this *DialysisAPIController) ExectionMobileAdvice() {
7936 7946
 							if config.IsOpen != 1 {
7937 7947
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
7938 7948
 									service.HisDrugsDelivery(orgId, creater, &advice)
7949
+									if orgId == 3877 || orgId == 10265 {
7950
+										//查询该药品是否有出库记录
7951
+										flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
7952
+										if len(flowMap) == 0 {
7953
+											errs := service.UpdateHisAdviceById(advice.ID)
7954
+											if errs != nil {
7955
+												drugError := models.XtDrugError{
7956
+													UserOrgId:             orgId,
7957
+													DrugId:                item.DrugId,
7958
+													RecordDate:            item.AdviceDate,
7959
+													PatientId:             item.PatientId,
7960
+													Remark:                "透析医嘱页面出库记录为空,更新执行人失败",
7961
+													Status:                1,
7962
+													Ctime:                 time.Now().Unix(),
7963
+													Mtime:                 0,
7964
+													SumCount:              0,
7965
+													Prescribingnumber:     advice.PrescribingNumber,
7966
+													PrescribingNumberUnit: advice.PrescribingNumberUnit,
7967
+												}
7968
+												service.CreateDrugError(drugError)
7969
+											}
7970
+											this.ServeSuccessJSON(map[string]interface{}{
7971
+												"msg":  "2",
7972
+												"drug": medical,
7973
+												"ids":  ids,
7974
+											})
7975
+											return
7976
+
7977
+										}
7978
+									}
7939 7979
 								}
7940 7980
 								if pharmacyConfig.IsOpen != 1 {
7941 7981
 									service.HisDrugsDelivery(orgId, creater, &advice)
7982
+									if orgId == 3877 || orgId == 10265 {
7983
+										//查询该药品是否有出库记录
7984
+										flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
7985
+										if len(flowMap) == 0 {
7986
+											errs := service.UpdateHisAdviceById(advice.ID)
7987
+											if errs != nil {
7988
+												drugError := models.XtDrugError{
7989
+													UserOrgId:             orgId,
7990
+													DrugId:                item.DrugId,
7991
+													RecordDate:            item.AdviceDate,
7992
+													PatientId:             item.PatientId,
7993
+													Remark:                "透析医嘱页面出库记录为空,更新执行人失败",
7994
+													Status:                1,
7995
+													Ctime:                 time.Now().Unix(),
7996
+													Mtime:                 0,
7997
+													SumCount:              0,
7998
+													Prescribingnumber:     advice.PrescribingNumber,
7999
+													PrescribingNumberUnit: advice.PrescribingNumberUnit,
8000
+												}
8001
+												service.CreateDrugError(drugError)
8002
+											}
8003
+											this.ServeSuccessJSON(map[string]interface{}{
8004
+												"msg":  "2",
8005
+												"drug": medical,
8006
+												"ids":  ids,
8007
+											})
8008
+											return
8009
+										}
8010
+									}
7942 8011
 								}
7943 8012
 
7944 8013
 								//更新字典里面的库存

+ 143 - 2
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -685,7 +685,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
685 685
 		privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.Org.Id)
686 686
 
687 687
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
688
-		fmt.Println("drugStockConfig.IsOpen32232323232", drugStockConfig.IsOpen)
688
+
689 689
 		if drugStockConfig.IsOpen == 1 {
690 690
 			if groupno > 0 {
691 691
 				advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
@@ -701,7 +701,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
701 701
 				if isHasWay {
702 702
 					var total int64
703 703
 					var prescribing_number_total int64
704
-					fmt.Println("advicesssssssssssssssss", len(advices))
704
+
705 705
 					for _, item := range advices {
706 706
 						if item.Way == 1 {
707 707
 							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
@@ -1075,6 +1075,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1075 1075
 			item.ExecutionState = 1
1076 1076
 			item.ExecutionStaff = adminInfo.AdminUser.Id
1077 1077
 			item.ExecutionTime = theTime.Unix()
1078
+			item.IsMobile = 1
1078 1079
 			err = service.SaveHisDoctorAdvice(item)
1079 1080
 			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
1080 1081
 			redis := service.RedisClient()
@@ -1104,6 +1105,39 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1104 1105
 				for _, item := range advices {
1105 1106
 					//查询改药品信息
1106 1107
 					medical, _ := service.GetBaseDrugMedical(item.DrugId)
1108
+
1109
+					//判断单位是否合格
1110
+					if item.PrescribingNumberUnit != medical.MaxUnit && item.PrescribingNumberUnit != medical.MinUnit {
1111
+						//查询该药品是否有出库记录
1112
+						flowMap, _ := service.GetDrugFLowByAdviceById(item.DrugId, item.PatientId, item.UserOrgId, item.AdviceDate)
1113
+						if len(flowMap) == 0 {
1114
+							errs := service.UpdateHisAdviceById(item.ID)
1115
+							if errs != nil {
1116
+								drugError := models.XtDrugError{
1117
+									UserOrgId:             adminInfo.Org.Id,
1118
+									DrugId:                item.DrugId,
1119
+									RecordDate:            item.AdviceDate,
1120
+									PatientId:             item.PatientId,
1121
+									Remark:                "单位不统一,执行失败",
1122
+									Status:                1,
1123
+									Ctime:                 time.Now().Unix(),
1124
+									Mtime:                 0,
1125
+									SumCount:              0,
1126
+									Prescribingnumber:     item.PrescribingNumber,
1127
+									PrescribingNumberUnit: item.PrescribingNumberUnit,
1128
+								}
1129
+								service.CreateDrugError(drugError)
1130
+							}
1131
+						}
1132
+						advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
1133
+						c.ServeSuccessJSON(map[string]interface{}{
1134
+							"msg":    "7",
1135
+							"advice": advice,
1136
+							"ids":    ids,
1137
+						})
1138
+						return
1139
+					}
1140
+
1107 1141
 					//查询这个患者这个患者这个药已经出库的所有数量
1108 1142
 					advicelist, _ := service.GetAllHisDoctorAdviceById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
1109 1143
 					drugoutlist, _ := service.GetAllDrugFlowById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
@@ -1132,6 +1166,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1132 1166
 						}
1133 1167
 					}
1134 1168
 					if total_count == drug_count {
1169
+
1135 1170
 						advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
1136 1171
 						c.ServeSuccessJSON(map[string]interface{}{
1137 1172
 							"msg":    "1",
@@ -1172,6 +1207,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1172 1207
 						if medical.IsUse == 1 {
1173 1208
 
1174 1209
 							if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1210
+								drugError := models.XtDrugError{
1211
+									UserOrgId:             adminInfo.Org.Id,
1212
+									DrugId:                item.DrugId,
1213
+									RecordDate:            item.AdviceDate,
1214
+									PatientId:             item.PatientId,
1215
+									Remark:                "零用药品库存不足",
1216
+									Status:                1,
1217
+									Ctime:                 time.Now().Unix(),
1218
+									Mtime:                 0,
1219
+									SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
1220
+									Prescribingnumber:     advice.PrescribingNumber,
1221
+									PrescribingNumberUnit: advice.PrescribingNumberUnit,
1222
+								}
1223
+								service.CreateDrugError(drugError)
1175 1224
 								c.ServeSuccessJSON(map[string]interface{}{
1176 1225
 									"msg":    "1",
1177 1226
 									"advice": advice,
@@ -1181,7 +1230,22 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1181 1230
 							}
1182 1231
 						}
1183 1232
 						if medical.IsUse != 1 {
1233
+
1184 1234
 							if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1235
+								drugError := models.XtDrugError{
1236
+									UserOrgId:             adminInfo.Org.Id,
1237
+									DrugId:                item.DrugId,
1238
+									RecordDate:            item.AdviceDate,
1239
+									PatientId:             item.PatientId,
1240
+									Remark:                "药品库存不足",
1241
+									Status:                1,
1242
+									Ctime:                 time.Now().Unix(),
1243
+									Mtime:                 0,
1244
+									SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
1245
+									Prescribingnumber:     advice.PrescribingNumber,
1246
+									PrescribingNumberUnit: advice.PrescribingNumberUnit,
1247
+								}
1248
+								service.CreateDrugError(drugError)
1185 1249
 								c.ServeSuccessJSON(map[string]interface{}{
1186 1250
 									"msg":    "3",
1187 1251
 									"advice": advice,
@@ -1190,6 +1254,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1190 1254
 								return
1191 1255
 							}
1192 1256
 							if prescribing_number_total > total {
1257
+								drugError := models.XtDrugError{
1258
+									UserOrgId:             adminInfo.Org.Id,
1259
+									DrugId:                item.DrugId,
1260
+									RecordDate:            item.AdviceDate,
1261
+									PatientId:             item.PatientId,
1262
+									Remark:                "出库数量大于库存",
1263
+									Status:                1,
1264
+									Ctime:                 time.Now().Unix(),
1265
+									Mtime:                 0,
1266
+									SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
1267
+									Prescribingnumber:     advice.PrescribingNumber,
1268
+									PrescribingNumberUnit: advice.PrescribingNumberUnit,
1269
+								}
1270
+								service.CreateDrugError(drugError)
1193 1271
 								c.ServeSuccessJSON(map[string]interface{}{
1194 1272
 									"msg":    "2",
1195 1273
 									"advice": advice,
@@ -1208,9 +1286,71 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1208 1286
 								if config.IsOpen != 1 {
1209 1287
 									if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
1210 1288
 										service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1289
+
1290
+										if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
1291
+											//查询该药品是否有出库记录
1292
+											flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
1293
+											if len(flowMap) == 0 {
1294
+												errs := service.UpdateHisAdviceById(advice.ID)
1295
+												if errs != nil {
1296
+													drugError := models.XtDrugError{
1297
+														UserOrgId:             adminInfo.Org.Id,
1298
+														DrugId:                item.DrugId,
1299
+														RecordDate:            item.AdviceDate,
1300
+														PatientId:             item.PatientId,
1301
+														Remark:                "出库记录为空,更新执行人失败",
1302
+														Status:                1,
1303
+														Ctime:                 time.Now().Unix(),
1304
+														Mtime:                 0,
1305
+														SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
1306
+														Prescribingnumber:     advice.PrescribingNumber,
1307
+														PrescribingNumberUnit: advice.PrescribingNumberUnit,
1308
+													}
1309
+													service.CreateDrugError(drugError)
1310
+												}
1311
+												c.ServeSuccessJSON(map[string]interface{}{
1312
+													"msg":    "6",
1313
+													"advice": advice,
1314
+													"ids":    ids,
1315
+												})
1316
+												return
1317
+											}
1318
+										}
1211 1319
 									}
1212 1320
 									if pharmacyConfig.IsOpen != 1 {
1321
+
1213 1322
 										service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1323
+										if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
1324
+											//查询该药品是否有出库记录
1325
+											flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
1326
+
1327
+											if len(flowMap) == 0 {
1328
+
1329
+												errs := service.UpdateHisAdviceById(advice.ID)
1330
+												if errs != nil {
1331
+													drugError := models.XtDrugError{
1332
+														UserOrgId:             adminInfo.Org.Id,
1333
+														DrugId:                item.DrugId,
1334
+														RecordDate:            item.AdviceDate,
1335
+														PatientId:             item.PatientId,
1336
+														Remark:                "出库记录为空,更新执行人失败",
1337
+														Status:                1,
1338
+														Ctime:                 time.Now().Unix(),
1339
+														Mtime:                 0,
1340
+														SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
1341
+														Prescribingnumber:     advice.PrescribingNumber,
1342
+														PrescribingNumberUnit: advice.PrescribingNumberUnit,
1343
+													}
1344
+													service.CreateDrugError(drugError)
1345
+												}
1346
+												c.ServeSuccessJSON(map[string]interface{}{
1347
+													"msg":    "6",
1348
+													"advice": advice,
1349
+													"ids":    ids,
1350
+												})
1351
+												return
1352
+											}
1353
+										}
1214 1354
 									}
1215 1355
 
1216 1356
 									//更新字典里面的库存
@@ -1230,6 +1370,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1230 1370
 							}
1231 1371
 						}
1232 1372
 					}
1373
+
1233 1374
 					//
1234 1375
 					//if config.IsOpen == 1 && item.UserOrgId == 10088 {
1235 1376
 					//

+ 114 - 2
controllers/patient_api_controller.go View File

@@ -1323,7 +1323,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
1323 1323
 			return
1324 1324
 		}
1325 1325
 		adviceName, _ := adviceNameM["advice_name"].(string)
1326
-		fmt.Println("adviceceNMAE--------------------------------", adviceName)
1326
+
1327 1327
 		if len(adviceName) == 0 {
1328 1328
 			utils.ErrorLog("len(advice_name) == 0")
1329 1329
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1418,9 +1418,22 @@ func (c *PatientApiController) CreateGroupAdvice() {
1418 1418
 		}
1419 1419
 
1420 1420
 		remark, _ := adviceNameM["remark"].(string)
1421
-		fmt.Println("哦哦撒搜哦搜搜哦remark-----------------------------------", remark)
1421
+
1422 1422
 		advice.Remark = remark
1423 1423
 
1424
+		if adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10340 || adminUserInfo.CurrentOrgId == 9671 {
1425
+			if advice.PrescribingNumber == 0 {
1426
+				advice.PrescribingNumber = 1
1427
+			}
1428
+			//查询该患者今日有没有双人核对
1429
+			check, _ := service.MobileGetDoubleCheckSix(adminUserInfo.CurrentOrgId, patientInfo.ID, advice.AdviceDate)
1430
+			fmt.Println("chek", check)
1431
+			if check.ID > 0 {
1432
+				advice.Checker = check.Modifier
1433
+				advice.CheckState = 1
1434
+				advice.CheckTime = time.Now().Unix()
1435
+			}
1436
+		}
1424 1437
 		if adviceType == 1 {
1425 1438
 
1426 1439
 			if adviceNameM["frequency_type"] != nil || reflect.TypeOf(adviceNameM["frequency_type"]).String() == "float64" {
@@ -1448,6 +1461,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
1448 1461
 				}
1449 1462
 				advice.PushStartTime = startTime
1450 1463
 			}
1464
+
1451 1465
 		}
1452 1466
 
1453 1467
 		if adviceNameM["children"] != nil && reflect.TypeOf(adviceNameM["children"]).String() == "string" {
@@ -2368,6 +2382,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2368 2382
 					}
2369 2383
 
2370 2384
 					if medical.IsUse == 1 {
2385
+						drugError := models.XtDrugError{
2386
+							UserOrgId:             item.UserOrgId,
2387
+							DrugId:                item.DrugId,
2388
+							RecordDate:            item.AdviceDate,
2389
+							PatientId:             item.PatientId,
2390
+							Remark:                "电脑端零用药品",
2391
+							Status:                1,
2392
+							Ctime:                 time.Now().Unix(),
2393
+							Mtime:                 0,
2394
+							SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
2395
+							Prescribingnumber:     item.PrescribingNumber,
2396
+							PrescribingNumberUnit: item.PrescribingNumberUnit,
2397
+						}
2398
+						service.CreateDrugError(drugError)
2371 2399
 						c.ServeSuccessJSON(map[string]interface{}{
2372 2400
 							"msg":    "1",
2373 2401
 							"advice": advice,
@@ -2376,6 +2404,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2376 2404
 					}
2377 2405
 					if medical.IsUse != 1 {
2378 2406
 						if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
2407
+							drugError := models.XtDrugError{
2408
+								UserOrgId:             item.UserOrgId,
2409
+								DrugId:                item.DrugId,
2410
+								RecordDate:            item.AdviceDate,
2411
+								PatientId:             item.PatientId,
2412
+								Remark:                "电脑端药品库存不足",
2413
+								Status:                1,
2414
+								Ctime:                 time.Now().Unix(),
2415
+								Mtime:                 0,
2416
+								SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
2417
+								Prescribingnumber:     item.PrescribingNumber,
2418
+								PrescribingNumberUnit: item.PrescribingNumberUnit,
2419
+							}
2420
+							service.CreateDrugError(drugError)
2379 2421
 							c.ServeSuccessJSON(map[string]interface{}{
2380 2422
 								"msg":    "3",
2381 2423
 								"advice": advice,
@@ -2384,6 +2426,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2384 2426
 						}
2385 2427
 
2386 2428
 						if prescribing_number_total > total {
2429
+							drugError := models.XtDrugError{
2430
+								UserOrgId:             item.UserOrgId,
2431
+								DrugId:                item.DrugId,
2432
+								RecordDate:            item.AdviceDate,
2433
+								PatientId:             item.PatientId,
2434
+								Remark:                "电脑端出库数量大于总库存",
2435
+								Status:                1,
2436
+								Ctime:                 time.Now().Unix(),
2437
+								Mtime:                 0,
2438
+								SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
2439
+								Prescribingnumber:     item.PrescribingNumber,
2440
+								PrescribingNumberUnit: item.PrescribingNumberUnit,
2441
+							}
2442
+							service.CreateDrugError(drugError)
2387 2443
 							c.ServeSuccessJSON(map[string]interface{}{
2388 2444
 								"msg":    "2",
2389 2445
 								"advice": advice,
@@ -2400,10 +2456,66 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2400 2456
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
2401 2457
 									service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2402 2458
 
2459
+									if item.UserOrgId == 3877 || item.UserOrgId == 10265 {
2460
+										//查询该药品是否有出库记录
2461
+										flowMap, _ := service.GetDrugFLowByAdviceById(item.DrugId, item.PatientId, item.UserOrgId, item.AdviceDate)
2462
+										if len(flowMap) == 0 {
2463
+											errs := service.UpdateHisAdviceById(item.ID)
2464
+											if errs != nil {
2465
+												drugError := models.XtDrugError{
2466
+													UserOrgId:             item.UserOrgId,
2467
+													DrugId:                item.DrugId,
2468
+													RecordDate:            item.AdviceDate,
2469
+													PatientId:             item.PatientId,
2470
+													Remark:                "出库记录为空,更新执行人失败",
2471
+													Status:                1,
2472
+													Ctime:                 time.Now().Unix(),
2473
+													Mtime:                 0,
2474
+													SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
2475
+													Prescribingnumber:     item.PrescribingNumber,
2476
+													PrescribingNumberUnit: item.PrescribingNumberUnit,
2477
+												}
2478
+												service.CreateDrugError(drugError)
2479
+											}
2480
+											c.ServeSuccessJSON(map[string]interface{}{
2481
+												"msg":    "6",
2482
+												"advice": advice,
2483
+											})
2484
+											return
2485
+										}
2486
+									}
2403 2487
 								}
2404 2488
 								//不通过药房发药
2405 2489
 								if pharmacyConfig.IsOpen != 1 {
2406 2490
 									service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2491
+									if item.UserOrgId == 3877 || item.UserOrgId == 10265 {
2492
+										//查询该药品是否有出库记录
2493
+										flowMap, _ := service.GetDrugFLowByAdviceById(item.DrugId, item.PatientId, item.UserOrgId, item.AdviceDate)
2494
+										if len(flowMap) == 0 {
2495
+											errs := service.UpdateHisAdviceById(item.ID)
2496
+											if errs != nil {
2497
+												drugError := models.XtDrugError{
2498
+													UserOrgId:             item.UserOrgId,
2499
+													DrugId:                item.DrugId,
2500
+													RecordDate:            item.AdviceDate,
2501
+													PatientId:             item.PatientId,
2502
+													Remark:                "出库记录为空,更新执行人失败",
2503
+													Status:                1,
2504
+													Ctime:                 time.Now().Unix(),
2505
+													Mtime:                 0,
2506
+													SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
2507
+													Prescribingnumber:     item.PrescribingNumber,
2508
+													PrescribingNumberUnit: item.PrescribingNumberUnit,
2509
+												}
2510
+												service.CreateDrugError(drugError)
2511
+											}
2512
+											c.ServeSuccessJSON(map[string]interface{}{
2513
+												"msg":    "6",
2514
+												"advice": advice,
2515
+											})
2516
+											return
2517
+										}
2518
+									}
2407 2519
 								}
2408 2520
 								//查询默认仓库
2409 2521
 								storeHouseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)

+ 25 - 9
controllers/pharmacy_controller.go View File

@@ -90,7 +90,7 @@ func (this *PharmacyController) TodayNumber() {
90 90
 		etime = stime + 86399
91 91
 	}
92 92
 
93
-	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 && orgid != 10215 && orgid != 10387 {
93
+	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 {
94 94
 		//查询表里当天的数据
95 95
 		var wtotal int
96 96
 		wtotal, err = service.GetTodayPharmacy(stime, etime, orgid, 1)
@@ -116,7 +116,7 @@ func (this *PharmacyController) TodayNumber() {
116 116
 		return
117 117
 	}
118 118
 
119
-	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 || orgid == 10215 || orgid == 10387 {
119
+	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 {
120 120
 		var wtotal int
121 121
 		var itotal int
122 122
 		//查找出库数量
@@ -165,7 +165,7 @@ func (this *PharmacyController) IssuedDrug() {
165 165
 		etime = stime + 86399
166 166
 	}
167 167
 
168
-	if orgid == 10164 || orgid == 3877 || orgid == 10188 || orgid == 10217 || orgid == 9671 || orgid == 10387 || orgid == 10215 {
168
+	if orgid == 10164 || orgid == 3877 || orgid == 10188 || orgid == 10217 || orgid == 9671 || orgid == 10387 {
169 169
 
170 170
 		//获取排班班次
171 171
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
@@ -189,7 +189,7 @@ func (this *PharmacyController) IssuedDrug() {
189 189
 		})
190 190
 	}
191 191
 
192
-	if orgid != 10164 && orgid == 3877 && orgid != 10188 && orgid != 10217 && orgid != 9671 && orgid != 10387 && orgid != 10215 {
192
+	if orgid != 10164 && orgid == 3877 && orgid != 10188 && orgid != 10217 && orgid != 9671 && orgid != 10387 {
193 193
 		//查询表里当天的数据
194 194
 		var flist []*models.TmpPatient
195 195
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 1, keyword)
@@ -245,7 +245,7 @@ func (this *PharmacyController) WaitingDrug() {
245 245
 		etime = stime + 86399
246 246
 	}
247 247
 
248
-	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 && orgid != 10387 && orgid != 10215 {
248
+	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 && orgid != 10387 {
249 249
 		//查询表里当天的数据
250 250
 		var flist []*models.TmpPatient
251 251
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 0, keyword)
@@ -269,7 +269,7 @@ func (this *PharmacyController) WaitingDrug() {
269 269
 	}
270 270
 
271 271
 	//当天已发药的人数
272
-	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 || orgid == 10387 || orgid == 10215 {
272
+	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 || orgid == 10387 {
273 273
 
274 274
 		//获取排班班次
275 275
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
@@ -370,7 +370,6 @@ func (this *PharmacyController) DispensingMedicine() {
370 370
 		for _, item := range advicelist {
371 371
 			//查询改药品信息
372 372
 			medical, _ := service.GetBaseDrugMedical(item.DrugId)
373
-			//通过药房发药
374 373
 			if medical.IsPharmacy == 1 {
375 374
 				houseConfig, _ := service.GetAllStoreHouseConfig(orgid)
376 375
 				//查询该药品是否有库存
@@ -390,8 +389,7 @@ func (this *PharmacyController) DispensingMedicine() {
390 389
 					total = list.Count*medical.MinNumber + list.StockMinNumber
391 390
 					prescribing_number_total = count
392 391
 				}
393
-				fmt.Println("总库存", total)
394
-				fmt.Println("出库数量", prescribing_number_total)
392
+
395 393
 				if medical.IsUse != 1 {
396 394
 					//如果出库数量大于库存数量
397 395
 					if prescribing_number_total > total {
@@ -409,11 +407,29 @@ func (this *PharmacyController) DispensingMedicine() {
409 407
 	}
410 408
 
411 409
 	err = service.DispensingMedicine(orgid, patient_id, stime, etime, creater)
410
+
411
+	if orgid == 10387 || orgid == 3877 {
412
+		advicelist, _ := service.FindeHisAdviceDocAdvice(orgid, patient_id, stime, etime)
413
+		if len(advicelist) > 0 {
414
+			for _, item := range advicelist {
415
+				//查询改药品信息
416
+				medical, _ := service.GetBaseDrugMedical(item.DrugId)
417
+				if medical.IsPharmacy == 1 {
418
+					flow, _ := service.GetFlow(item.DrugId, item.AdviceDate, orgid, item.PatientId)
419
+					if len(flow) > 0 {
420
+						service.UpdateAdviceFlow(item.ID)
421
+					}
422
+				}
423
+			}
424
+
425
+		}
426
+	}
412 427
 	if err != nil {
413 428
 		utils.ErrorLog(err.Error())
414 429
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
415 430
 		return
416 431
 	}
432
+
417 433
 	this.ServeSuccessJSON(map[string]interface{}{
418 434
 		"list": "操作成功",
419 435
 	})

+ 141 - 45
controllers/public_api_controller.go View File

@@ -62,35 +62,35 @@ func PublicApiRegistRouters() {
62 62
 	beego.Router("/api/public/handlestockdata", &PublicApiController{}, "get:HandleStockData")
63 63
 	beego.Router("/api/public/handlecomdata", &PublicApiController{}, "get:HandleComData")
64 64
 	beego.Router("/hello", &PublicApiController{}, "get:HandleComData")
65
-
66 65
 	beego.Router("/handel", &PublicApiController{}, "get:HandleHIS")
67
-
68 66
 	beego.Router("/groupno", &PublicApiController{}, "get:HandleGroupNo")
69
-
70 67
 	beego.Router("/handle10215", &PublicApiController{}, "get:Handle10215")
71
-
72 68
 	beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
73
-
74 69
 	beego.Router("/handelHis", &PublicApiController{}, "get:HandleHisTwo")
75
-
76 70
 	beego.Router("/handelProject", &PublicApiController{}, "get:HandleProject")
77
-
78 71
 	beego.Router("/handelsettledata", &PublicApiController{}, "get:HandleSettleData")
79
-
80 72
 	beego.Router("/handelhispatient", &PublicApiController{}, "get:HandleHisPatient")
81
-
82 73
 	//beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
83
-
84 74
 	beego.Router("/handleExportData", &PublicApiController{}, "get:HandleExportAllData")
85
-
86 75
 	beego.Router("/handleExportData10138", &PublicApiController{}, "get:HandleExportData10138")
87 76
 
88 77
 	beego.Router("/handleData10265", &PublicApiController{}, "get:HandleData10265")
89 78
 
90 79
 	beego.Router("/handleData10106", &PublicApiController{}, "get:HandleData10106")
80
+	beego.Router("/handleData10318", &PublicApiController{}, "get:HandleData10318")
81
+
82
+	beego.Router("/handleOne", &PublicApiController{}, "get:HandleOne")
91 83
 
92 84
 	beego.Router("/handelschedule", &PublicApiController{}, "get:HandleSchedule")
93
-	beego.Router("/handelscheduleTwo", &PublicApiController{}, "get:HandleScheduleTwo")
85
+	//beego.Router("/handelscheduleTwo", &PublicApiController{}, "get:HandleScheduleTwo")
86
+	//
87
+	//
88
+	//
89
+	//beego.Router("/handelhispatienttwo", &PublicApiController{}, "get:HandleHisPatientTwo")
90
+
91
+	//beego.Router("/handleorderinfo", &PublicApiController{}, "get:HandleOrderInfoData")
92
+	//
93
+	//beego.Router("/hande10138", &PublicApiController{}, "get:HandleOrderInfoData10138")
94 94
 
95 95
 }
96 96
 
@@ -113,41 +113,61 @@ func (c *PublicApiController) HandleSchedule() {
113 113
 
114 114
 }
115 115
 
116
-func (c *PublicApiController) HandleScheduleTwo() {
117
-	models, _ := service.GetAllSchMode()
118
-	for _, item := range models {
119
-		if item.Mode == 1 {
120
-			templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
121
-			thisTime := time.Now()
122
-			_, theWeek := thisTime.ISOWeek()
123
-			templates[0].Week = theWeek
124
-			service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
125
-		} else if item.Mode == 2 {
126
-			templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
127
-			now := time.Now()
128
-			nextSecWeek := now.AddDate(0, 0, 14)
129
-			nextWeek := now.AddDate(0, 0, 7)
130
-			if item.ExecuteTimes%2 == 0 { //下第二周生成的是
131
-				templates[0].Week = service.GetWeeks(nextWeek.Format("2006-01-02 15:04:05"))
132
-				templates[1].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
133
-				service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
134
-				service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
135
-
136
-			} else if item.ExecuteTimes%2 == 1 {
137
-				templates[0].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
138
-				templates[1].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
139
-				service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
140
-				service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
141
-
142
-			}
116
+func (c *PublicApiController) HandleOne() {
117
+	//fmt.Println("~~~~~~")
118
+	start_time := c.GetString("start_time")
119
+	end_time := c.GetString("end_time")
143 120
 
144
-		}
121
+	timeLayout := "2006-01-02"
122
+	loc, _ := time.LoadLocation("Local")
123
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
124
+	if err != nil {
145 125
 	}
146
-
126
+	startRecordDateTime := startTime.Unix()
127
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
128
+	if err != nil {
129
+	}
130
+	endRecordDateTime := endTime.Unix()
131
+	orders, _ := service.GetHisOrderDetailOne(startRecordDateTime, endRecordDateTime)
132
+	c.ServeSuccessJSON(map[string]interface{}{
133
+		"order": orders,
134
+	})
147 135
 }
148 136
 
149
-func (c *PublicApiController) HandleHisPatient() {
137
+//func (c *PublicApiController) HandleScheduleTwo() {
138
+//	models, _ := service.GetAllSchMode()
139
+//	for _, item := range models {
140
+//		if item.Mode == 1 {
141
+//			templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
142
+//			thisTime := time.Now()
143
+//			_, theWeek := thisTime.ISOWeek()
144
+//			templates[0].Week = theWeek
145
+//			service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
146
+//		} else if item.Mode == 2 {
147
+//			templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
148
+//			now := time.Now()
149
+//			nextSecWeek := now.AddDate(0, 0, 14)
150
+//			nextWeek := now.AddDate(0, 0, 7)
151
+//			if item.ExecuteTimes%2 == 0 { //下第二周生成的是
152
+//				templates[0].Week = service.GetWeeks(nextWeek.Format("2006-01-02 15:04:05"))
153
+//				templates[1].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
154
+//				service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
155
+//				service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
156
+//
157
+//			} else if item.ExecuteTimes%2 == 1 {
158
+//				templates[0].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
159
+//				templates[1].Week = service.GetWeeks(nextWeek.Format("2006-01-02 15:04:05"))
160
+//				service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
161
+//				service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
162
+//
163
+//			}
164
+//
165
+//		}
166
+//	}
167
+//
168
+//}
150 169
 
170
+func (c *PublicApiController) HandleHisPatient() {
151 171
 	ps, _ := service.GetHisPatient11111(10215)
152 172
 	for _, item := range ps {
153 173
 		var rf []*ResultFiveT
@@ -193,7 +213,7 @@ func (c *PublicApiController) HandleHisPatient() {
193 213
 		}
194 214
 
195 215
 		if len(insutypes) == 0 {
196
-			insutype = "310"
216
+			insutype = "390"
197 217
 		}
198 218
 		for _, item := range rf {
199 219
 			if item.Insutype == insutype {
@@ -206,6 +226,24 @@ func (c *PublicApiController) HandleHisPatient() {
206 226
 	}
207 227
 }
208 228
 
229
+//func (c *PublicApiController) HandleHisPatientTwo() {
230
+//
231
+//	ps, _ := service.GetHisPatient2222(10188)
232
+//	for _, item := range ps {
233
+//		var rf []*ResultFiveT
234
+//		json.Unmarshal([]byte(item.Iinfo), &rf)
235
+//		var insuplc_admdvs string
236
+//
237
+//		for _, subItem := range rf {
238
+//			if subItem.Insutype == item.Insutype {
239
+//				insuplc_admdvs = subItem.InsuplcAdmdvs
240
+//			}
241
+//		}
242
+//		item.InsuplcAdmdvs = insuplc_admdvs
243
+//		service.SaveHPtWO(item)
244
+//	}
245
+//}
246
+
209 247
 func (c *PublicApiController) HandleSettleData() {
210 248
 	orders, _ := service.GetHisOrderDetailThree()
211 249
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -243,8 +281,6 @@ func (c *PublicApiController) HandleData10106() {
243 281
 	start_time := c.GetString("start_time")
244 282
 	end_time := c.GetString("end_time")
245 283
 
246
-	start_time = "2022-11-01"
247
-	end_time = "2022-11-30"
248 284
 	timeLayout := "2006-01-02"
249 285
 	loc, _ := time.LoadLocation("Local")
250 286
 	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
@@ -266,6 +302,31 @@ func (c *PublicApiController) HandleData10106() {
266 302
 	})
267 303
 }
268 304
 
305
+func (c *PublicApiController) HandleData10318() {
306
+	start_time := c.GetString("start_time")
307
+	end_time := c.GetString("end_time")
308
+
309
+	timeLayout := "2006-01-02"
310
+	loc, _ := time.LoadLocation("Local")
311
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
312
+	if err != nil {
313
+
314
+	}
315
+	startRecordDateTime := startTime.Unix()
316
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
317
+	if err != nil {
318
+
319
+	}
320
+	endRecordDateTime := endTime.Unix()
321
+	fmt.Println(startRecordDateTime)
322
+	fmt.Println(endRecordDateTime)
323
+
324
+	orders, _ := service.GetHisOrderDetail10318(startRecordDateTime, endRecordDateTime)
325
+	c.ServeSuccessJSON(map[string]interface{}{
326
+		"order": orders,
327
+	})
328
+}
329
+
269 330
 func (c *PublicApiController) HandleProject() {
270 331
 	prescriptions := service.GetAllProjectPrescription()
271 332
 	for _, item := range prescriptions {
@@ -2316,3 +2377,38 @@ func (c *PublicApiController) HandleData10265() {
2316 2377
 	}
2317 2378
 
2318 2379
 }
2380
+
2381
+//func (c *PublicApiController) HandleOrderInfoData() {
2382
+//	orders, _ := service.GetHisOrderInfoDetail()
2383
+//	c.ServeSuccessJSON(map[string]interface{}{
2384
+//		"info": orders,
2385
+//	})
2386
+//}
2387
+//
2388
+//func (c *PublicApiController)HandleOrderInfoData10138(){
2389
+//	start_time := c.GetString("start_time")
2390
+//	end_time := c.GetString("end_time")
2391
+//	timeLayout := "2006-01-02"
2392
+//	loc, _ := time.LoadLocation("Local")
2393
+//	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2394
+//	if err != nil {
2395
+//
2396
+//	}
2397
+//	startRecordDateTime := startTime.Unix()
2398
+//	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2399
+//	if err != nil {
2400
+//
2401
+//	}
2402
+//	endRecordDateTime := endTime.Unix()
2403
+//	orders, _ := service.GetHisAllPatientOrder(startRecordDateTime,endRecordDateTime)
2404
+//	for _, item := range orders{
2405
+//		for _, subItem := range item.HisOrder10138{
2406
+//			info, _ := service.GetHisOrderInfoDetail10138(subItem.Number)
2407
+//			subItem.VmHisOrderInfo9504 = info
2408
+//		}
2409
+//	}
2410
+//	c.ServeSuccessJSON(map[string]interface{}{
2411
+//		"info": orders,
2412
+//	})
2413
+//
2414
+//}

+ 119 - 48
controllers/self_drug_api_congtroller.go View File

@@ -3664,70 +3664,141 @@ func (this *SelfDrugApiController) GetGoodNewPurchaseStockQuery() {
3664 3664
 		ids = append(ids, it.ID)
3665 3665
 	}
3666 3666
 	manufacturerList, _ := service.GetNewAllManufacturerList(orgId)
3667
-	list, total, err := service.GetGoodNewPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
3668 3667
 
3669
-	for _, item := range list {
3668
+	if orgId == 10265 {
3669
+		list, total, err := service.GetGoodNewPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
3670 3670
 
3671
-		//获取期初结余
3672
-		low, _ := service.GetStartLastFLow(item.ID, orgId, startTime)
3671
+		for _, item := range list {
3673 3672
 
3674
-		item.GoodStartFlowInfo = low
3673
+			//获取期初结余
3674
+			low, _ := service.GetStartLastFLow(item.ID, orgId, startTime)
3675 3675
 
3676
-		//获取期末结余
3677
-		flow, _ := service.GetEndLastFlow(item.ID, orgId, endTime)
3676
+			item.GoodStartFlowInfo = low
3678 3677
 
3679
-		item.GoodEndFlowInfo = flow
3678
+			//获取期末结余
3679
+			flow, _ := service.GetEndLastFlow(item.ID, orgId, endTime)
3680 3680
 
3681
-		//获取期间增加
3682
-		goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime)
3683
-		for _, it := range goodWarehouseInfoList {
3684
-			item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
3685
-		}
3681
+			item.GoodEndFlowInfo = flow
3686 3682
 
3687
-		//获取本期增加
3688
-		WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime)
3689
-		for _, it := range WarehouseInfoFlowList {
3690
-			item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
3691
-		}
3692
-		//获取本期减少
3693
-		reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime)
3694
-		for _, it := range reduceWarehouseInfoList {
3695
-			item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
3696
-		}
3683
+			//获取期间增加
3684
+			goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime)
3685
+			for _, it := range goodWarehouseInfoList {
3686
+				item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
3687
+			}
3697 3688
 
3698
-		//获取期中减少退库
3699
-		lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime)
3700
-		for _, it := range lowInfo {
3701
-			item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
3689
+			//获取本期增加
3690
+			WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime)
3691
+			for _, it := range WarehouseInfoFlowList {
3692
+				item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
3693
+			}
3694
+			//获取本期减少
3695
+			reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime)
3696
+			for _, it := range reduceWarehouseInfoList {
3697
+				item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
3698
+			}
3699
+
3700
+			//获取期中减少退库
3701
+			lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime)
3702
+			for _, it := range lowInfo {
3703
+				item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
3704
+			}
3705
+			//
3706
+			outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime)
3707
+			for _, it := range outInfo {
3708
+				item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3709
+			}
3710
+
3711
+			//期中盘盈
3712
+			profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime)
3713
+			for _, it := range profit {
3714
+				item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3715
+			}
3716
+			//期中盘亏
3717
+			losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime)
3718
+			for _, it := range losses {
3719
+				item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3720
+			}
3702 3721
 		}
3703
-		//
3704
-		outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime)
3705
-		for _, it := range outInfo {
3706
-			item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3722
+
3723
+		if err != nil {
3724
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
3725
+			return
3707 3726
 		}
3708 3727
 
3709
-		//期中盘盈
3710
-		profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime)
3711
-		for _, it := range profit {
3712
-			item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3728
+		this.ServeSuccessJSON(map[string]interface{}{
3729
+			"list":             list,
3730
+			"manufacturerList": manufacturerList,
3731
+			"total":            total,
3732
+		})
3733
+	}
3734
+
3735
+	if orgId != 10265 {
3736
+		list, total, err := service.GetGoodNewPurchaseStockQueryOne(good_type, keyword, page, limit, orgId, ids, goodIds)
3737
+
3738
+		for _, item := range list {
3739
+
3740
+			//获取期初结余
3741
+			low, _ := service.GetStartLastFLow(item.ID, orgId, startTime)
3742
+
3743
+			item.GoodStartFlowInfo = low
3744
+
3745
+			//获取期末结余
3746
+			flow, _ := service.GetEndLastFlow(item.ID, orgId, endTime)
3747
+
3748
+			item.GoodEndFlowInfo = flow
3749
+
3750
+			//获取期间增加
3751
+			goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime)
3752
+			for _, it := range goodWarehouseInfoList {
3753
+				item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
3754
+			}
3755
+
3756
+			//获取本期增加
3757
+			WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime)
3758
+			for _, it := range WarehouseInfoFlowList {
3759
+				item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
3760
+			}
3761
+			//获取本期减少
3762
+			reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime)
3763
+			for _, it := range reduceWarehouseInfoList {
3764
+				item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
3765
+			}
3766
+
3767
+			//获取期中减少退库
3768
+			lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime)
3769
+			for _, it := range lowInfo {
3770
+				item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
3771
+			}
3772
+			//
3773
+			outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime)
3774
+			for _, it := range outInfo {
3775
+				item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3776
+			}
3777
+
3778
+			//期中盘盈
3779
+			profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime)
3780
+			for _, it := range profit {
3781
+				item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3782
+			}
3783
+			//期中盘亏
3784
+			losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime)
3785
+			for _, it := range losses {
3786
+				item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3787
+			}
3713 3788
 		}
3714
-		//期中盘亏
3715
-		losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime)
3716
-		for _, it := range losses {
3717
-			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3789
+
3790
+		if err != nil {
3791
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
3792
+			return
3718 3793
 		}
3719
-	}
3720 3794
 
3721
-	if err != nil {
3722
-		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
3723
-		return
3795
+		this.ServeSuccessJSON(map[string]interface{}{
3796
+			"list":             list,
3797
+			"manufacturerList": manufacturerList,
3798
+			"total":            total,
3799
+		})
3724 3800
 	}
3725 3801
 
3726
-	this.ServeSuccessJSON(map[string]interface{}{
3727
-		"list":             list,
3728
-		"manufacturerList": manufacturerList,
3729
-		"total":            total,
3730
-	})
3731 3802
 }
3732 3803
 
3733 3804
 func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {

+ 31 - 29
controllers/stock_in_api_controller.go View File

@@ -7546,36 +7546,38 @@ func (this *StockManagerApiController) ReturnCheckWarehouseInfo() {
7546 7546
 			return
7547 7547
 		}
7548 7548
 	}
7549
-	for _, item := range list {
7550
-
7551
-		//扣减数量
7552
-		service.UpdateWarehouseInfoByIdListTwo(item.WarehousingCount, item.ID)
7553
-
7554
-		//删除流水
7555
-		service.UpdateWarehouseInfoFlow(item.ID)
7556
-
7557
-		goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7558
-		var flush_count int64
7559
-		for _, it := range goodList {
7560
-			flush_count += it.StockCount
7561
-		}
7562
-
7563
-		//扣减数量
7564
-		service.UpdateGoodInCount(item.WarehousingCount, item.OrgId, item.GoodId, item.StorehouseId, flush_count)
7549
+	//for _, item := range list {
7550
+	//
7551
+	//	//扣减数量
7552
+	//	service.UpdateWarehouseInfoByIdListTwo(item.WarehousingCount, item.ID)
7553
+	//
7554
+	//	//删除流水
7555
+	//	service.UpdateWarehouseInfoFlow(item.ID)
7556
+	//
7557
+	//	goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7558
+	//	var flush_count int64
7559
+	//	for _, it := range goodList {
7560
+	//		flush_count += it.StockCount
7561
+	//	}
7562
+	//
7563
+	//	//扣减数量
7564
+	//	service.UpdateGoodInCount(item.WarehousingCount, item.OrgId, item.GoodId, item.StorehouseId, flush_count)
7565
+	//
7566
+	//	//查询默认仓库
7567
+	//	storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7568
+	//	//查询该耗材剩余多少库存
7569
+	//	stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7570
+	//	var sum_count int64
7571
+	//	var sum_in_count int64
7572
+	//	for _, it := range stockList {
7573
+	//		sum_count += it.StockCount
7574
+	//		sum_in_count += it.WarehousingCount
7575
+	//	}
7576
+	//	service.UpdateGoodInfoAddSumCount(item.GoodId, sum_count, orgId, sum_in_count)
7577
+	//}
7578
+	//err := service.ReturnCheckWarehouseInfo(warehousing_info_id)
7565 7579
 
7566
-		//查询默认仓库
7567
-		storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7568
-		//查询该耗材剩余多少库存
7569
-		stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7570
-		var sum_count int64
7571
-		var sum_in_count int64
7572
-		for _, it := range stockList {
7573
-			sum_count += it.StockCount
7574
-			sum_in_count += it.WarehousingCount
7575
-		}
7576
-		service.UpdateGoodInfoAddSumCount(item.GoodId, sum_count, orgId, sum_in_count)
7577
-	}
7578
-	err := service.ReturnCheckWarehouseInfo(warehousing_info_id)
7580
+	err := service.UpdateWarehouseInfoMap(list, warehousing_info_id, orgId)
7579 7581
 	if err == nil {
7580 7582
 		this.ServeSuccessJSON(map[string]interface{}{
7581 7583
 			"msg": "反审核成功!",

+ 24 - 21
models/device_models.go View File

@@ -871,27 +871,30 @@ type DeviceRepairs struct {
871 871
 }
872 872
 
873 873
 type DeviceRepair struct {
874
-	ID               int64  `gorm:"column:id" json:"id" form:"id"`
875
-	GuaranteeDate    int64  `gorm:"column:guarantee_date" json:"guarantee_date" form:"guarantee_date"`
876
-	StartTime        int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
877
-	ArriveTime       int64  `gorm:"column:arrive_time" json:"arrive_time" form:"arrive_time"`
878
-	FinishTime       int64  `gorm:"column:finish_time" json:"finish_time" form:"finish_time"`
879
-	TotalDistance    string `gorm:"column:total_distance" json:"total_distance" form:"total_distance"`
880
-	FailureStage     int64  `gorm:"column:failure_stage" json:"failure_stage" form:"failure_stage"`
881
-	FaultDescription string `gorm:"column:fault_description" json:"fault_description" form:"fault_description"`
882
-	CauseAnalysis    string `gorm:"column:cause_analysis" json:"cause_analysis" form:"cause_analysis"`
883
-	TreatmentProcess string `gorm:"column:treatment_process" json:"treatment_process" form:"treatment_process"`
884
-	Images           string `gorm:"column:images" json:"images" form:"images"`
885
-	Exclude          int64  `gorm:"column:exclude" json:"exclude" form:"exclude"`
886
-	Reason           string `gorm:"column:reason" json:"reason" form:"reason"`
887
-	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
888
-	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
889
-	Status           int64  `gorm:"column:status" json:"status" form:"status"`
890
-	UserOrgId        int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
891
-	BedId            int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
892
-	EquitmentId      int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
893
-	CodeInformation  string `gorm:"column:code_information" json:"code_information" form:"code_information"`
894
-	ImageName        string `gorm:"column:image_name" json:"image_name" form:"image_name"`
874
+	ID                            int64  `gorm:"column:id" json:"id" form:"id"`
875
+	GuaranteeDate                 int64  `gorm:"column:guarantee_date" json:"guarantee_date" form:"guarantee_date"`
876
+	StartTime                     int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
877
+	ArriveTime                    int64  `gorm:"column:arrive_time" json:"arrive_time" form:"arrive_time"`
878
+	FinishTime                    int64  `gorm:"column:finish_time" json:"finish_time" form:"finish_time"`
879
+	TotalDistance                 string `gorm:"column:total_distance" json:"total_distance" form:"total_distance"`
880
+	FailureStage                  int64  `gorm:"column:failure_stage" json:"failure_stage" form:"failure_stage"`
881
+	FaultDescription              string `gorm:"column:fault_description" json:"fault_description" form:"fault_description"`
882
+	CauseAnalysis                 string `gorm:"column:cause_analysis" json:"cause_analysis" form:"cause_analysis"`
883
+	TreatmentProcess              string `gorm:"column:treatment_process" json:"treatment_process" form:"treatment_process"`
884
+	Images                        string `gorm:"column:images" json:"images" form:"images"`
885
+	Exclude                       int64  `gorm:"column:exclude" json:"exclude" form:"exclude"`
886
+	Reason                        string `gorm:"column:reason" json:"reason" form:"reason"`
887
+	Ctime                         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
888
+	Mtime                         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
889
+	Status                        int64  `gorm:"column:status" json:"status" form:"status"`
890
+	UserOrgId                     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
891
+	BedId                         int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
892
+	EquitmentId                   int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
893
+	CodeInformation               string `gorm:"column:code_information" json:"code_information" form:"code_information"`
894
+	ImageName                     string `gorm:"column:image_name" json:"image_name" form:"image_name"`
895
+	FunctionAccessoriesInspection string `gorm:"column:function_accessories_inspection" json:"function_accessories_inspection" form:"function_accessories_inspection"`
896
+	OtherInformation              string `gorm:"column:other_information" json:"other_information" form:"other_information"`
897
+	AdminUserId                   int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
895 898
 }
896 899
 
897 900
 func (DeviceRepair) TableName() string {

+ 1 - 0
models/dialysis.go View File

@@ -1241,6 +1241,7 @@ type HisDoctorAdvice struct {
1241 1241
 	DrugId                int64              `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1242 1242
 	DrugNameId            int64              `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
1243 1243
 	ExecutionFrequencyId  int64              `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
1244
+	IsMobile              int64              `gorm:"column:is_mobile" json:"is_mobile" form:"is_mobile"`
1244 1245
 }
1245 1246
 
1246 1247
 func (HisDoctorAdvice) TableName() string {

+ 19 - 0
models/drug_stock.go View File

@@ -709,3 +709,22 @@ type DrugWarehouseOutInfoNight struct {
709 709
 func (DrugWarehouseOutInfoNight) TableName() string {
710 710
 	return "xt_drug_warehouse_out_info"
711 711
 }
712
+
713
+type XtDrugError struct {
714
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
715
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
716
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
717
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
718
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
719
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
720
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
721
+	Ctime                 int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
722
+	Mtime                 int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
723
+	Prescribingnumber     float64 `gorm:"column:prescribingnumber" json:"prescribingnumber" form:"prescribingnumber"`
724
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
725
+	SumCount              int64   `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
726
+}
727
+
728
+func (XtDrugError) TableName() string {
729
+	return "xt_drug_error"
730
+}

+ 83 - 2
models/his_models.go View File

@@ -261,6 +261,7 @@ type HisDoctorAdviceInfo struct {
261 261
 	ExecutionFrequencyId  int64                  `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
262 262
 	Child                 []*HisDoctorAdviceInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" json:"child"`
263 263
 	IsSettle              int64                  `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
264
+	IsMobile              int64                  `gorm:"column:is_mobile" json:"is_mobile" form:"is_mobile"`
264 265
 }
265 266
 
266 267
 func (HisDoctorAdviceInfo) TableName() string {
@@ -1064,8 +1065,7 @@ type HisOrder struct {
1064 1065
 	Patients               Patients               `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1065 1066
 	HisPatient             HisPatient             `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
1066 1067
 	HisHospitalCheckRecord HisHospitalCheckRecord `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_hospital_patient"`
1067
-
1068
-	HisPrescriptionInfo HisPrescriptionInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"p_info"`
1068
+	HisPrescriptionInfo    HisPrescriptionInfo    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"p_info"`
1069 1069
 
1070 1070
 	HisFundSettleListResult HisFundSettleListResult `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"result"`
1071 1071
 	IsPre                   int64                   `gorm:"column:is_pre" json:"is_pre" form:"is_pre"`
@@ -2576,3 +2576,84 @@ type ExportHisPrescription struct {
2576 2576
 func (ExportHisPrescription) TableName() string {
2577 2577
 	return "his_prescription"
2578 2578
 }
2579
+
2580
+type Orders struct {
2581
+	BedCostPartSelfTotal                        float64                `json:"bedCostPartSelfTotal"`
2582
+	BedCostSelfTotal                            float64                `json:"bedCostSelfTotal"`
2583
+	BedCostTotal                                float64                `json:"bedCostTotal"`
2584
+	BedInscpTotal                               float64                `json:"bedInscpTotal"`
2585
+	BedSelfTotal                                float64                `json:"bedSelfTotal"`
2586
+	ChargeAdmin                                 UserAdminRole          `json:"charge_admin"`
2587
+	CheckCostPartSelfTotal                      float64                `json:"checkCostPartSelfTotal"`
2588
+	CheckCostSelfTotal                          float64                `json:"checkCostSelfTotal"`
2589
+	CheckCostTotal                              float64                `json:"checkCostTotal"`
2590
+	CheckInscpTotal                             float64                `json:"checkInscpTotal"`
2591
+	CheckSelfTotal                              float64                `json:"checkSelfTotal"`
2592
+	ChineseTraditionalInscpTotal                float64                `json:"chineseTraditionalInscpTotal"`
2593
+	ChineseTraditionalMedicineCostPartSelfTotal float64                `json:"chineseTraditionalMedicineCostPartSelfTotal"`
2594
+	ChineseTraditionalMedicineCostSelfTotal     float64                `json:"chineseTraditionalMedicineCostSelfTotal"`
2595
+	ChineseTraditionalMedicineCostTotal         float64                `json:"chineseTraditionalMedicineCostTotal"`
2596
+	ChineseTraditionalSelfTotal                 float64                `json:"chineseTraditionalSelfTotal"`
2597
+	Date                                        int64                  `json:"date"`
2598
+	DiaConfig                                   []*HisXtDiagnoseConfig `json:"dia_config"`
2599
+	Diagnosis                                   string                 `json:"diagnosis"`
2600
+	DoctorInfo                                  UserAdminRole          `json:"doctor_info"`
2601
+	DoctorName                                  string                 `json:"doctor_name"`
2602
+	HealthCardNo                                string                 `json:"health_card_no"`
2603
+
2604
+	LaboratoryCostPartSelfTotal      float64            `json:"laboratoryCostPartSelfTotal"`
2605
+	LaboratoryCostSelfTotal          float64            `json:"laboratoryCostSelfTotal"`
2606
+	LaboratoryCostTotal              float64            `json:"laboratoryCostTotal"`
2607
+	LaboratoryInscpTotal             float64            `json:"laboratoryInscpTotal"`
2608
+	LaboratorySelfTotal              float64            `json:"laboratorySelfTotal"`
2609
+	MaterialCostPartSelfTotal        float64            `json:"materialCostPartSelfTotal"`
2610
+	MaterialCostSelfTotal            float64            `json:"materialCostSelfTotal"`
2611
+	MaterialCostTotal                float64            `json:"materialCostTotal"`
2612
+	MaterialInscpTotal               float64            `json:"materialInscpTotal"`
2613
+	MaterialSelfTotal                float64            `json:"materialSelfTotal"`
2614
+	Number                           string             `json:"number"`
2615
+	OperationCostPartSelfTotal       float64            `json:"operationCostPartSelfTotal"`
2616
+	OperationCostSelfTotal           float64            `json:"operationCostSelfTotal"`
2617
+	OperationCostTotal               float64            `json:"operationCostTotal"`
2618
+	OperationInscpTotal              float64            `json:"operationInscpTotal"`
2619
+	OperationSelfTotal               float64            `json:"operationSelfTotal"`
2620
+	Order                            HisOrder           `json:"order"`
2621
+	OrderInfos                       []*HisOrderInfoTwo `json:"order_infos"`
2622
+	OrderNumber                      string             `json:"order_number"`
2623
+	OrgCode                          string             `json:"org_code"`
2624
+	OrgName                          string             `json:"org_name"`
2625
+	OtherCostPartSelfTotal           float64            `json:"otherCostPartSelfTotal"`
2626
+	OtherCostSelfTotal               float64            `json:"otherCostSelfTotal"`
2627
+	OtherCostTotal                   float64            `json:"otherCostTotal"`
2628
+	OtherInscpTotal                  float64            `json:"otherInscpTotal"`
2629
+	OtherSelfTotal                   float64            `json:"otherSelfTotal"`
2630
+	Patient                          PatientTwos        `json:"patient"`
2631
+	PrintorAdmin                     UserAdminRole      `json:"printor_admin"`
2632
+	TreatCostPartSelfTotal           float64            `json:"treatCostPartSelfTotal"`
2633
+	TreatCostSelfTotal               float64            `json:"treatCostSelfTotal"`
2634
+	TreatCostTotal                   float64            `json:"treatCostTotal"`
2635
+	TreatInscpTotal                  float64            `json:"treatInscpTotal"`
2636
+	TreatSelfTotal                   float64            `json:"treatSelfTotal"`
2637
+	WesternMedicineCostPartSelfTotal float64            `json:"westernMedicineCostPartSelfTotal"`
2638
+	WesternMedicineCostSelfTotal     float64            `json:"westernMedicineCostSelfTotal"`
2639
+	WesternMedicineCostTotal         float64            `json:"westernMedicineCostTotal"`
2640
+	WesternMedicineInscpTotal        float64            `json:"westernMedicineInscpTotal"`
2641
+	WesternMedicineSelfTotal         float64            `json:"westernMedicineSelfTotal"`
2642
+	YiliaoLeibie                     string             `json:"yiliao_leibie"`
2643
+	HisPatient                       HisPatient         `json:"his"`
2644
+}
2645
+
2646
+type PatientTwos struct {
2647
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
2648
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2649
+	Name         string `gorm:"column:name" json:"name" form:"name"`
2650
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
2651
+	IdCardNo     string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
2652
+	ScheduleType int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
2653
+	Phone        int64  `gorm:"column:phone" json:"phone" form:"phone"`
2654
+	Gender       int64  `gorm:"column:gender" json:"gender" form:"gender"`
2655
+}
2656
+
2657
+func (PatientTwos) TableName() string {
2658
+	return "xt_patients"
2659
+}

+ 9 - 9
service/data.go View File

@@ -8,7 +8,7 @@ import (
8 8
 	"time"
9 9
 )
10 10
 
11
-//GetPatientList 返回患者的列表
11
+// GetPatientList 返回患者的列表
12 12
 func GetConfigList(orgID int64) (dataconfig interface{}, err error) {
13 13
 	var configList []*models.Dataconfig
14 14
 
@@ -296,45 +296,45 @@ func FindeInspectionByOrgId(orgid int64) (xtquality []*models.XtCheckConfigurati
296 296
 }
297 297
 
298 298
 func BatchInsertFiledConfig(org_id int64) (err error) {
299
-	err = readDb.Exec("INSERT  INTO sgj_xt.xt_filed_config  ( org_id,  module,  filed_name,  filed_name_cn,  is_show ) SELECT ?,  module,  filed_name,  filed_name_cn,  is_show FROM sgj_xt.xt_filed_config  WHERE org_id = 0 AND is_show = 1", org_id).Error
299
+	err = XTWriteDB().Exec("INSERT  INTO sgj_xt.xt_filed_config  ( org_id,  module,  filed_name,  filed_name_cn,  is_show ) SELECT ?,  module,  filed_name,  filed_name_cn,  is_show FROM sgj_xt.xt_filed_config  WHERE org_id = 0 AND is_show = 1", org_id).Error
300 300
 	return
301 301
 }
302 302
 
303 303
 func BatchInsertQualityControl(org_id int64) (err error) {
304 304
 
305
-	err = readDb.Exec("INSERT INTO xt_quality_control_standard(user_org_id,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status,range_type,range_value,is_status) SELECT ?,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status,range_type,range_value,is_status FROM xt_quality_control_standard where user_org_id = 0 and is_status = 1", org_id).Error
305
+	err = XTWriteDB().Exec("INSERT INTO xt_quality_control_standard(user_org_id,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status,range_type,range_value,is_status) SELECT ?,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status,range_type,range_value,is_status FROM xt_quality_control_standard where user_org_id = 0 and is_status = 1", org_id).Error
306 306
 	return
307 307
 }
308 308
 
309 309
 func BathInsertQualityControlTwo(org_id int64) (err error) {
310
-	err = readDb.Exec("INSERT INTO xt_quality_control_standard(user_org_id,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status,range_type,range_value,is_status) SELECT ?,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status,range_type,range_value,is_status FROM xt_quality_control_standard where user_org_id = 0 and is_status = 0", org_id).Error
310
+	err = XTWriteDB().Exec("INSERT INTO xt_quality_control_standard(user_org_id,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status,range_type,range_value,is_status) SELECT ?,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status,range_type,range_value,is_status FROM xt_quality_control_standard where user_org_id = 0 and is_status = 0", org_id).Error
311 311
 	return
312 312
 }
313 313
 
314 314
 func BatchInspectionConfiguration(orgid int64) (err error) {
315 315
 
316
-	err = readDb.Exec("INSERT INTO xt_check_configuration(user_org_id,inspection_major,inspection_frequency,sort,created_time,status) SELECT ?,inspection_major,inspection_frequency,sort,created_time,status FROM xt_check_configuration where user_org_id = 0", orgid).Error
316
+	err = XTWriteDB().Exec("INSERT INTO xt_check_configuration(user_org_id,inspection_major,inspection_frequency,sort,created_time,status) SELECT ?,inspection_major,inspection_frequency,sort,created_time,status FROM xt_check_configuration where user_org_id = 0", orgid).Error
317 317
 	return
318 318
 }
319 319
 
320 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
321
+	err = XTWriteDB().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
 
325 325
 func FindSysDialysisFiledByOrgId() (filedConfig []*models.FiledConfig, err error) {
326
-	err = readDb.Model(&models.FiledConfig{}).Where("org_id =? AND id in (11250,11251,11252,11253,11254,11255,11256,11257,11258,11259,11260,11261,11262)", 0).Find(&filedConfig).Error
326
+	err = XTWriteDB().Model(&models.FiledConfig{}).Where("org_id =? AND id in (11250,11251,11252,11253,11254,11255,11256,11257,11258,11259,11260,11261,11262)", 0).Find(&filedConfig).Error
327 327
 	return
328 328
 }
329 329
 
330 330
 func BatchInsertFiledSystemConfig(org_id int64) (err error) {
331
-	err = readDb.Exec("INSERT  INTO sgj_xt.xt_filed_config  ( org_id,  module,  filed_name,  filed_name_cn,  is_show ) SELECT ?,  module,  filed_name,  filed_name_cn,  is_show FROM sgj_xt.xt_filed_config  WHERE org_id = 9442", org_id).Error
331
+	err = XTWriteDB().Exec("INSERT  INTO sgj_xt.xt_filed_config  ( org_id,  module,  filed_name,  filed_name_cn,  is_show ) SELECT ?,  module,  filed_name,  filed_name_cn,  is_show FROM sgj_xt.xt_filed_config  WHERE org_id = 9442", org_id).Error
332 332
 	return
333 333
 }
334 334
 
335 335
 func BatchInsertDoctorSchedule(orgid int64) (err error) {
336 336
 
337
-	err = readDb.Exec("INSERT INTO sgj_xt.xt_doctor_schedules(user_org_id,class_name,class_attributes,timeone_start,timeone_type,timeone_end,timetwo_start,timetwo_type,timetwo_end,work_time,remarks,status,ctime,minute) SELECT ?, class_name,class_attributes,timeone_start,timeone_type,timeone_end,timetwo_start,timetwo_type,timetwo_end,work_time,remarks,status,ctime,minute FROM xt_doctor_schedules WHERE user_org_id = 0", orgid).Error
337
+	err = XTWriteDB().Exec("INSERT INTO sgj_xt.xt_doctor_schedules(user_org_id,class_name,class_attributes,timeone_start,timeone_type,timeone_end,timetwo_start,timetwo_type,timetwo_end,work_time,remarks,status,ctime,minute) SELECT ?, class_name,class_attributes,timeone_start,timeone_type,timeone_end,timetwo_start,timetwo_type,timetwo_end,work_time,remarks,status,ctime,minute FROM xt_doctor_schedules WHERE user_org_id = 0", orgid).Error
338 338
 	return
339 339
 }
340 340
 

+ 2 - 2
service/dialysis_service.go View File

@@ -357,7 +357,7 @@ func ExecBatchDoctorAdvice(patient_id int64, orgid int64, ids []string, creater
357 357
 }
358 358
 
359 359
 func ExceHidDoctorAdviceById(m *models.HisDoctorAdviceInfo, id int64, patientId int64) error {
360
-	err := writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND (id = ? Or parent_id=?)  AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1}).Error
360
+	err := writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND (id = ? Or parent_id=?)  AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1, "is_mobile": 2}).Error
361 361
 	return err
362 362
 }
363 363
 
@@ -1988,7 +1988,7 @@ func GetHisMobileAdviceList(orgid int64, ids []string) (advice []*models.HisDoct
1988 1988
 func ExectionMobileAdvice(orgid int64, ids []string, execution_time int64, execution_staff int64) error {
1989 1989
 
1990 1990
 	advice := models.HisDoctorAdvice{}
1991
-	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Updates(map[string]interface{}{"execution_time": execution_time, "execution_staff": execution_staff, "execution_state": 1}).Error
1991
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Updates(map[string]interface{}{"execution_time": execution_time, "execution_staff": execution_staff, "execution_state": 1, "is_mobile": 3}).Error
1992 1992
 	return err
1993 1993
 }
1994 1994
 

+ 1 - 1
service/dialysis_solution_service.go View File

@@ -94,7 +94,7 @@ func GetDialysisAdviceTemplateList(keywords string, limit int64, page int64, par
94 94
 	if orgID > 0 {
95 95
 		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
96 96
 	}
97
-	fmt.Println("idArray23233223323232233232", len(idArray))
97
+
98 98
 	if len(idArray) >= 1 {
99 99
 		db = db.Where("xt_schedule.id in(?)", idArray)
100 100
 	}

+ 7 - 0
service/drug_pharmacy_management_service.go View File

@@ -1647,3 +1647,10 @@ func GetPharmacyConfig(orgid int64) (models.PharmacyConfig, error) {
1647 1647
 
1648 1648
 	return config, err
1649 1649
 }
1650
+
1651
+func CreateDrugError(drugError models.XtDrugError) error {
1652
+
1653
+	err := XTWriteDB().Create(&drugError).Error
1654
+
1655
+	return err
1656
+}

+ 26 - 2
service/his_charge_service.go View File

@@ -240,7 +240,7 @@ func GetAllPatientChargeSettle(org_id int64, start_time int64, end_time int64, k
240 240
 	return
241 241
 }
242 242
 
243
-func GetLabelPrintList(page int64, limit int64, user_org_id int64, record_time int64, is_print int64, keywors string) (labels []*models.HisLabelPrintInfo, total int64, err error) {
243
+func GetLabelPrintList(page int64, limit int64, user_org_id int64, record_time int64, is_print int64, keywors string, tube_color int64) (labels []*models.HisLabelPrintInfo, total int64, err error) {
244 244
 	offset := (page - 1) * limit
245 245
 	db := readDb.Model(&models.HisLabelPrintInfo{})
246 246
 	if is_print > 0 {
@@ -251,7 +251,31 @@ func GetLabelPrintList(page int64, limit int64, user_org_id int64, record_time i
251 251
 		db = db.Where("patient_name Like ?", keywors)
252 252
 
253 253
 	}
254
-	err = db.Where("user_org_id = ? AND record_date = ? AND status = 1 ", user_org_id, record_time).Count(&total).Offset(offset).Limit(limit).Find(&labels).Error
254
+	if tube_color > 0 {
255
+		db = db.Joins("Right join xt_his_project_team as team on team.id = his_label_print_info.item_id AND his_label_print_info.item_id <> 0 and team.status = 1 and team.tube_color = ?", tube_color)
256
+		//db = db.Joins("Right join xt_his_project as pro on pro.id = his_label_print_info.project_id AND his_label_print_info.item_id = 0 and  his_label_print_info.project_id > 0 and pro.status = 1 and pro.tube_color = ?",tube_color)
257
+	}
258
+
259
+	err = db.Where("his_label_print_info.user_org_id = ? AND his_label_print_info.record_date = ? AND his_label_print_info.status = 1 ", user_org_id, record_time).Count(&total).Offset(offset).Limit(limit).Find(&labels).Error
260
+	return
261
+}
262
+func GetLabelPrintListTwo(page int64, limit int64, user_org_id int64, record_time int64, is_print int64, keywors string, tube_color int64) (labels []*models.HisLabelPrintInfo, total int64, err error) {
263
+	offset := (page - 1) * limit
264
+	db := readDb.Model(&models.HisLabelPrintInfo{})
265
+	if is_print > 0 {
266
+		db = db.Where("is_print = ?", is_print)
267
+	}
268
+	if len(keywors) > 0 {
269
+		keywors = "%" + keywors + "%"
270
+		db = db.Where("patient_name Like ?", keywors)
271
+
272
+	}
273
+	if tube_color > 0 {
274
+		//db = db.Joins("Right join xt_his_project_team as team on team.id = his_label_print_info.item_id AND his_label_print_info.item_id <> 0 and team.status = 1 and team.tube_color = ?",tube_color)
275
+		db = db.Joins("Right join xt_his_project as pro on pro.id = his_label_print_info.project_id AND his_label_print_info.item_id = 0 and  his_label_print_info.project_id > 0 and pro.status = 1 and pro.tube_color = ?", tube_color)
276
+	}
277
+
278
+	err = db.Where("his_label_print_info.user_org_id = ? AND his_label_print_info.record_date = ? AND his_label_print_info.status = 1 ", user_org_id, record_time).Count(&total).Offset(offset).Limit(limit).Find(&labels).Error
255 279
 	return
256 280
 }
257 281
 

+ 4 - 0
service/his_config_service.go View File

@@ -40,6 +40,10 @@ func SaveHisPrescriptionTemplate(template *models.HisPrescriptionTemplate) (err
40 40
 	return
41 41
 
42 42
 }
43
+func GetHisPrescriptionInfoTemplates(p_id int64, user_org_id int64) (p []*models.HisPrescriptionInfoTemplate, err error) {
44
+	err = writeDb.Model(&models.HisPrescriptionInfoTemplate{}).Where("user_org_id = ? AND p_template_id = ?", user_org_id, p_id).Find(&p).Error
45
+	return
46
+}
43 47
 
44 48
 func DelelteHisPrescriptionInfoTemplate(id int64, user_org_id int64) (err error) {
45 49
 	err = writeDb.Model(&models.HisPrescriptionInfoTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error

+ 29 - 3
service/his_service.go View File

@@ -968,7 +968,7 @@ func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
968 968
 	return
969 969
 }
970 970
 
971
-func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64, doctor_id int64, keywords string, p_type int64, sort_type int64, start_time string, end_time string, charge_type int64) (order []*models.HisOrder, err error, total int64) {
971
+func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64, doctor_id int64, keywords string, p_type int64, sort_type int64, start_time string, end_time string, charge_type int64, sch_type int64, zone_type int64) (order []*models.HisOrder, err error, total int64) {
972 972
 	offset := (page - 1) * limit
973 973
 	db := readDb.Model(&models.HisOrder{})
974 974
 
@@ -981,6 +981,19 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_time
981 981
 		db = db.Joins("join xt_patients as patient on patient.id = his_order.patient_id  AND patient.name like ? AND patient.user_org_id = ?", keywords, user_org_id)
982 982
 
983 983
 	}
984
+	if sch_type > 0 && zone_type > 0 {
985
+		db = db.Joins("join xt_schedule sch on sch.schedule_date = his_order.settle_accounts_date AND sch.patient_id = his_order.patient_id AND sch.schedule_type = ? AND sch.schedule_date >= ? AND sch.schedule_date <= ? AND sch.partition_id = ? AND sch.status  = 1", sch_type, start_time_timestamp, end_time_timestamp, zone_type)
986
+	}
987
+	if sch_type > 0 && zone_type == 0 {
988
+		db = db.Joins("join xt_schedule sch on sch.schedule_date = his_order.settle_accounts_date AND sch.patient_id = his_order.patient_id AND sch.schedule_type = ? AND sch.schedule_date >= ? AND sch.schedule_date <= ? AND sch.status = 1", sch_type, start_time_timestamp, end_time_timestamp)
989
+	}
990
+	if sch_type == 0 && zone_type > 0 {
991
+		db = db.Joins("join xt_schedule sch on sch.schedule_date = his_order.settle_accounts_date AND sch.patient_id = his_order.patient_id  AND sch.schedule_date >= ? AND sch.schedule_date <= ? AND sch.partition_id = ? AND sch.status = 1", start_time_timestamp, end_time_timestamp, zone_type)
992
+	}
993
+
994
+	//if zone_type > 0 {
995
+	//	db = db.Joins("join xt_schedule sch_two on sch_two.schedule_date = his_order.settle_accounts_date AND sch_two.patient_id = his_order.patient_id AND sch_two.partition_id = ?", zone_type)
996
+	//}
984 997
 
985 998
 	if sort_type == 1 {
986 999
 		if start_time_timestamp != 0 {
@@ -990,7 +1003,6 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_time
990 1003
 			db = db.Where("his_order.settle_accounts_date<=?", end_time_timestamp)
991 1004
 		}
992 1005
 	} else {
993
-
994 1006
 		if len(start_time) != 0 {
995 1007
 			db = db.Where("his_order.setl_time>=?", start_time+" 00:00:00")
996 1008
 		}
@@ -1534,7 +1546,10 @@ func GetMobileCallHisPrescriptions(start_time int64, end_time int64, org_id int6
1534 1546
 
1535 1547
 	return
1536 1548
 }
1537
-
1549
+func GetHisPatientByNumber(number string) (his models.HisPatient, err error) {
1550
+	err = readDb.Model(&models.HisPatient{}).Where("number = ? AND status = 1", number).First(&his).Error
1551
+	return
1552
+}
1538 1553
 func GetHisOrderByID(order_id int64) (order models.HisOrder, err error) {
1539 1554
 	err = readDb.Model(&models.HisOrder{}).Where("id = ? AND status = 1", order_id).First(&order).Error
1540 1555
 	return
@@ -1607,6 +1622,12 @@ func GetPatientByIDTwo(orgID int64, patientID int64) (Patients, error) {
1607 1622
 	return patient, err
1608 1623
 }
1609 1624
 
1625
+func GetPatientByIDTenTwo(orgID int64, patientID int64) (models.PatientTwos, error) {
1626
+	var patient models.PatientTwos
1627
+	err := readDb.Model(&models.PatientTwos{}).Where("id = ? and user_org_id=? and status=1", patientID, orgID).First(&patient).Error
1628
+	return patient, err
1629
+}
1630
+
1610 1631
 func GetHisPrescriptionByPatientID(patientID int64, orgID int64) (info models.HisPrescriptionInfo, err error) {
1611 1632
 	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND patient_id = ? AND status = 1", orgID, patientID).Preload("XtHisDepartment", "status = 1").Last(&info).Error
1612 1633
 	return
@@ -2726,3 +2747,8 @@ func UpdatePatientDialysisOrder(patient_id int64, url string) error {
2726 2747
 	err := XTWriteDB().Model(&models.XtPatients{}).Where("id =? and status=1", patient_id).Updates(map[string]interface{}{"url": url}).Error
2727 2748
 	return err
2728 2749
 }
2750
+
2751
+func GetHisOrderByIDTenOne(order_id string) (order models.HisOrder, err error) {
2752
+	err = readDb.Model(&models.HisOrder{}).Where("id = ? AND status = 1", order_id).First(&order).Error
2753
+	return
2754
+}

+ 1 - 1
service/manage_service.go View File

@@ -647,7 +647,7 @@ func EditRepair(id int64) (models.DeviceRepair, error) {
647 647
 
648 648
 func UpdateRepair(id int64, orgid int64, repair *models.DeviceRepair) error {
649 649
 
650
-	err := writeUserDb.Model(&repair).Where("id=? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"guarantee_date": repair.GuaranteeDate, "start_time": repair.StartTime, "arrive_time": repair.ArriveTime, "finish_time": repair.FinishTime, "total_distance": repair.TotalDistance, "failure_stage": repair.FailureStage, "fault_description": repair.FaultDescription, "cause_analysis": repair.CauseAnalysis, "treatment_process": repair.TreatmentProcess, "images": repair.Images, "exclude": repair.Exclude, "reason": repair.Reason, "code_information": repair.CodeInformation, "image_name": repair.ImageName, "mtime": time.Now().Unix()}).Error
650
+	err := writeUserDb.Model(&repair).Where("id=? AND user_org_id = ? AND status = 1", id, orgid).Updates(map[string]interface{}{"guarantee_date": repair.GuaranteeDate, "start_time": repair.StartTime, "arrive_time": repair.ArriveTime, "finish_time": repair.FinishTime, "total_distance": repair.TotalDistance, "failure_stage": repair.FailureStage, "fault_description": repair.FaultDescription, "cause_analysis": repair.CauseAnalysis, "treatment_process": repair.TreatmentProcess, "images": repair.Images, "exclude": repair.Exclude, "reason": repair.Reason, "code_information": repair.CodeInformation, "image_name": repair.ImageName, "mtime": time.Now().Unix(), "function_accessories_inspection": repair.FunctionAccessoriesInspection, "other_information": repair.OtherInformation, "admin_user_id": repair.AdminUserId}).Error
651 651
 	return err
652 652
 }
653 653
 

+ 7 - 0
service/mobile_dialysis_service.go View File

@@ -7236,3 +7236,10 @@ func GetHisDoctorAdvicesTwentyOne(orgID int64, scheduleDate int64, deliverWay st
7236 7236
 
7237 7237
 	return vms, err
7238 7238
 }
7239
+
7240
+func GetPatientDryWeight(org_id int64, patient_id int64) (weight []*models.SgjPatientDryweight, err error) {
7241
+
7242
+	err = XTReadDB().Where("user_org_id = ? and patient_id = ? and status =1", org_id, patient_id).Order("id asc").Limit(6).Find(&weight).Error
7243
+
7244
+	return weight, err
7245
+}

+ 371 - 37
service/new_warehouse_service.go View File

@@ -1261,6 +1261,20 @@ func BloodDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *
1261 1261
 // 药品自动出库 递归方式
1262 1262
 func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo) (err error) {
1263 1263
 
1264
+	drugError := models.XtDrugError{
1265
+		UserOrgId:             orgID,
1266
+		DrugId:                advice.DrugId,
1267
+		RecordDate:            advice.AdviceDate,
1268
+		PatientId:             advice.PatientId,
1269
+		Remark:                "进入出库页面",
1270
+		Status:                1,
1271
+		Ctime:                 time.Now().Unix(),
1272
+		Mtime:                 0,
1273
+		SumCount:              0,
1274
+		Prescribingnumber:     advice.PrescribingNumber,
1275
+		PrescribingNumberUnit: advice.PrescribingNumberUnit,
1276
+	}
1277
+	CreateDrugError(drugError)
1264 1278
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
1265 1279
 	var deliver_number int64 = 0
1266 1280
 	var stock_number int64 = 0
@@ -1306,28 +1320,39 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1306 1320
 	warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId, storeConfig.DrugStorehouseOut)
1307 1321
 
1308 1322
 	if err != nil {
1309
-
1323
+		drugError := models.XtDrugError{
1324
+			UserOrgId:             orgID,
1325
+			DrugId:                advice.DrugId,
1326
+			RecordDate:            advice.AdviceDate,
1327
+			PatientId:             advice.PatientId,
1328
+			Remark:                "查询库存报错",
1329
+			Status:                1,
1330
+			Ctime:                 time.Now().Unix(),
1331
+			Mtime:                 0,
1332
+			SumCount:              0,
1333
+			Prescribingnumber:     advice.PrescribingNumber,
1334
+			PrescribingNumberUnit: advice.PrescribingNumberUnit,
1335
+		}
1336
+		CreateDrugError(drugError)
1310 1337
 		return err
1311 1338
 	}
1312
-	// 将该批次的剩余库存数量转换为拆零数量
1339
+
1313 1340
 	// 将该批次的剩余库存数量转换为拆零数量
1314 1341
 	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
1315
-		//fmt.Println("进来1")
1342
+
1316 1343
 		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
1317
-		//fmt.Println("剩余库存1", stock_number)
1344
+
1318 1345
 	}
1319 1346
 	if warehouse.MaxUnit == drup.MinUnit && drup.MaxUnit != drup.MinUnit {
1320
-		//fmt.Println("进来2")
1347
+
1321 1348
 		stock_number = warehouse.StockMaxNumber + warehouse.StockMinNumber
1322
-		//fmt.Println("剩余库存2", stock_number)
1349
+
1323 1350
 	}
1324 1351
 	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit == drup.MinUnit {
1325
-		//fmt.Println("进来3")
1352
+
1326 1353
 		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
1327
-		//fmt.Println("剩余库存3", stock_number)
1354
+
1328 1355
 	}
1329
-	//fmt.Println("剩余库存23333333333333333333333333333wo", stock_number)
1330
-	//fmt.Println("出库数量2333333333333333333333333333333333333wo", deliver_number)
1331 1356
 
1332 1357
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1333 1358
 	if stock_number >= deliver_number {
@@ -1367,10 +1392,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1367 1392
 
1368 1393
 		warehouse.Mtime = time.Now().Unix()
1369 1394
 
1370
-		fmt.Println("minnU目标而332322323323233223323223我", minNumber)
1371
-		fmt.Println("max_number232232332232322wo", maxNumber)
1372
-		fmt.Println(" warehouse.StockMinNumber", warehouse.StockMinNumber)
1373
-
1374 1395
 		if warehouse.StockMinNumber < minNumber {
1375 1396
 
1376 1397
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
@@ -1416,6 +1437,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1416 1437
 		//扣减库存数据
1417 1438
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
1418 1439
 		if errThree != nil {
1440
+			drugError := models.XtDrugError{
1441
+				UserOrgId:             orgID,
1442
+				DrugId:                advice.DrugId,
1443
+				RecordDate:            advice.AdviceDate,
1444
+				PatientId:             advice.PatientId,
1445
+				Remark:                "扣减库存失败",
1446
+				Status:                1,
1447
+				Ctime:                 time.Now().Unix(),
1448
+				Mtime:                 0,
1449
+				SumCount:              0,
1450
+				Prescribingnumber:     advice.PrescribingNumber,
1451
+				PrescribingNumberUnit: advice.PrescribingNumberUnit,
1452
+			}
1453
+			CreateDrugError(drugError)
1419 1454
 			return errThree
1420 1455
 		}
1421 1456
 
@@ -1464,6 +1499,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1464 1499
 		if lastDrugOutInfo.ID == 0 {
1465 1500
 			errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1466 1501
 			if errOne != nil {
1502
+				drugError := models.XtDrugError{
1503
+					UserOrgId:             orgID,
1504
+					DrugId:                advice.DrugId,
1505
+					RecordDate:            advice.AdviceDate,
1506
+					PatientId:             advice.PatientId,
1507
+					Remark:                "创建出库单失败",
1508
+					Status:                1,
1509
+					Ctime:                 time.Now().Unix(),
1510
+					Mtime:                 0,
1511
+					SumCount:              0,
1512
+					Prescribingnumber:     advice.PrescribingNumber,
1513
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
1514
+				}
1515
+				CreateDrugError(drugError)
1467 1516
 				return errOne
1468 1517
 			}
1469 1518
 		}
@@ -1478,6 +1527,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1478 1527
 			if deliver_number != his_count {
1479 1528
 				errThree := UpdateSigleDrugWarehouseOutInfo(lastDrugOutInfo.ID, warehouseOutInfo)
1480 1529
 				if errThree != nil {
1530
+					drugError := models.XtDrugError{
1531
+						UserOrgId:             orgID,
1532
+						DrugId:                advice.DrugId,
1533
+						RecordDate:            advice.AdviceDate,
1534
+						PatientId:             advice.PatientId,
1535
+						Remark:                "更新出库单失败",
1536
+						Status:                1,
1537
+						Ctime:                 time.Now().Unix(),
1538
+						Mtime:                 0,
1539
+						SumCount:              0,
1540
+						Prescribingnumber:     advice.PrescribingNumber,
1541
+						PrescribingNumberUnit: advice.PrescribingNumberUnit,
1542
+					}
1543
+					CreateDrugError(drugError)
1481 1544
 					return errThree
1482 1545
 				}
1483 1546
 			}
@@ -1497,12 +1560,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1497 1560
 			cancel_count += item.Count
1498 1561
 		}
1499 1562
 
1500
-		//fmt.Println("deliver_number", deliver_number)
1501
-		//fmt.Println("out_count", out_count)
1502
-		//fmt.Println("cancel_count", cancel_count)
1503
-		//
1504
-		//fmt.Println("出库数据", deliver_number)
1505
-		//fmt.Println("出库流水---------------------", out_count, cancel_count)
1506 1563
 		//如果本次出库数据大于历史出库数据 新增1条流水
1507 1564
 		if deliver_number >= (out_count - cancel_count) {
1508 1565
 			drugflow := models.DrugFlow{
@@ -1536,9 +1593,43 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1536 1593
 				LastPrice:               warehouse.Price,
1537 1594
 			}
1538 1595
 
1539
-			CreateDrugFlowOne(drugflow)
1596
+			errThreeTy := CreateDrugFlowOne(drugflow)
1597
+
1598
+			if errThreeTy != nil {
1599
+				drugError := models.XtDrugError{
1600
+					UserOrgId:             orgID,
1601
+					DrugId:                advice.DrugId,
1602
+					RecordDate:            advice.AdviceDate,
1603
+					PatientId:             advice.PatientId,
1604
+					Remark:                "创建流水失败",
1605
+					Status:                1,
1606
+					Ctime:                 time.Now().Unix(),
1607
+					Mtime:                 0,
1608
+					SumCount:              0,
1609
+					Prescribingnumber:     advice.PrescribingNumber,
1610
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
1611
+				}
1612
+				CreateDrugError(drugError)
1613
+			}
1540 1614
 			//出库数量相加
1541
-			AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
1615
+			errThreeTys := AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
1616
+
1617
+			if errThreeTys != nil {
1618
+				drugError := models.XtDrugError{
1619
+					UserOrgId:             orgID,
1620
+					DrugId:                advice.DrugId,
1621
+					RecordDate:            advice.AdviceDate,
1622
+					PatientId:             advice.PatientId,
1623
+					Remark:                "出库数量相加失败",
1624
+					Status:                1,
1625
+					Ctime:                 time.Now().Unix(),
1626
+					Mtime:                 0,
1627
+					SumCount:              0,
1628
+					Prescribingnumber:     advice.PrescribingNumber,
1629
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
1630
+				}
1631
+				CreateDrugError(drugError)
1632
+			}
1542 1633
 
1543 1634
 		}
1544 1635
 
@@ -1570,7 +1661,23 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1570 1661
 
1571 1662
 			_, errCode := FindDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
1572 1663
 			if errCode == gorm.ErrRecordNotFound {
1573
-				AddSigleDrugCancelStock(&cancelStock)
1664
+				errCode := AddSigleDrugCancelStock(&cancelStock)
1665
+				if errCode != nil {
1666
+					drugError := models.XtDrugError{
1667
+						UserOrgId:             orgID,
1668
+						DrugId:                advice.DrugId,
1669
+						RecordDate:            advice.AdviceDate,
1670
+						PatientId:             advice.PatientId,
1671
+						Remark:                "创建退库单失败",
1672
+						Status:                1,
1673
+						Ctime:                 time.Now().Unix(),
1674
+						Mtime:                 0,
1675
+						SumCount:              0,
1676
+						Prescribingnumber:     advice.PrescribingNumber,
1677
+						PrescribingNumberUnit: advice.PrescribingNumberUnit,
1678
+					}
1679
+					CreateDrugError(drugError)
1680
+				}
1574 1681
 			}
1575 1682
 			lastDrugCancelStock, _ := FindLastDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
1576 1683
 
@@ -1602,7 +1709,23 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1602 1709
 				StorehouseId:     storeConfig.DrugStorehouseOut,
1603 1710
 				IsCheck:          1,
1604 1711
 			}
1605
-			CreatedCancelStock(cancelStockInfo)
1712
+			errCodes := CreatedCancelStock(cancelStockInfo)
1713
+			if errCodes != nil {
1714
+				drugError := models.XtDrugError{
1715
+					UserOrgId:             orgID,
1716
+					DrugId:                advice.DrugId,
1717
+					RecordDate:            advice.AdviceDate,
1718
+					PatientId:             advice.PatientId,
1719
+					Remark:                "创建退库单失败",
1720
+					Status:                1,
1721
+					Ctime:                 time.Now().Unix(),
1722
+					Mtime:                 0,
1723
+					SumCount:              0,
1724
+					Prescribingnumber:     advice.PrescribingNumber,
1725
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
1726
+				}
1727
+				CreateDrugError(drugError)
1728
+			}
1606 1729
 			flow := models.DrugFlow{
1607 1730
 				WarehousingId:           warehouse.ID,
1608 1731
 				DrugId:                  warehouse.DrugId,
@@ -1640,9 +1763,57 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1640 1763
 				LastPrice:               warehouse.Price,
1641 1764
 				OverCount:               sum_count,
1642 1765
 			}
1643
-			CreateDrugFlowOne(flow)
1644
-			AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
1645
-			ReduceDrugCountTwo(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, flow.Count)
1766
+			errCodeflow := CreateDrugFlowOne(flow)
1767
+			if errCodeflow != nil {
1768
+				drugError := models.XtDrugError{
1769
+					UserOrgId:             orgID,
1770
+					DrugId:                advice.DrugId,
1771
+					RecordDate:            advice.AdviceDate,
1772
+					PatientId:             advice.PatientId,
1773
+					Remark:                "退库流水创建失败",
1774
+					Status:                1,
1775
+					Ctime:                 time.Now().Unix(),
1776
+					Mtime:                 0,
1777
+					SumCount:              0,
1778
+					Prescribingnumber:     advice.PrescribingNumber,
1779
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
1780
+				}
1781
+				CreateDrugError(drugError)
1782
+			}
1783
+			errCodesum := AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
1784
+			if errCodesum != nil {
1785
+				drugError := models.XtDrugError{
1786
+					UserOrgId:             orgID,
1787
+					DrugId:                advice.DrugId,
1788
+					RecordDate:            advice.AdviceDate,
1789
+					PatientId:             advice.PatientId,
1790
+					Remark:                "增加退库数量失败",
1791
+					Status:                1,
1792
+					Ctime:                 time.Now().Unix(),
1793
+					Mtime:                 0,
1794
+					SumCount:              0,
1795
+					Prescribingnumber:     advice.PrescribingNumber,
1796
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
1797
+				}
1798
+				CreateDrugError(drugError)
1799
+			}
1800
+			errCodereduce := ReduceDrugCountTwo(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, flow.Count)
1801
+			if errCodereduce != nil {
1802
+				drugError := models.XtDrugError{
1803
+					UserOrgId:             orgID,
1804
+					DrugId:                advice.DrugId,
1805
+					RecordDate:            advice.AdviceDate,
1806
+					PatientId:             advice.PatientId,
1807
+					Remark:                "减少出库数量失败",
1808
+					Status:                1,
1809
+					Ctime:                 time.Now().Unix(),
1810
+					Mtime:                 0,
1811
+					SumCount:              0,
1812
+					Prescribingnumber:     advice.PrescribingNumber,
1813
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
1814
+				}
1815
+				CreateDrugError(drugError)
1816
+			}
1646 1817
 		}
1647 1818
 
1648 1819
 		//查询是否存在数据
@@ -1664,6 +1835,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1664 1835
 		}
1665 1836
 		errTwo := AddSigleDrugAutoReduceRecordInfo(details)
1666 1837
 		if errTwo != nil {
1838
+			drugError := models.XtDrugError{
1839
+				UserOrgId:             orgID,
1840
+				DrugId:                advice.DrugId,
1841
+				RecordDate:            advice.AdviceDate,
1842
+				PatientId:             advice.PatientId,
1843
+				Remark:                "新增自动出库表失败",
1844
+				Status:                1,
1845
+				Ctime:                 time.Now().Unix(),
1846
+				Mtime:                 0,
1847
+				SumCount:              0,
1848
+				Prescribingnumber:     advice.PrescribingNumber,
1849
+				PrescribingNumberUnit: advice.PrescribingNumberUnit,
1850
+			}
1851
+			CreateDrugError(drugError)
1667 1852
 			return errTwo
1668 1853
 		}
1669 1854
 		return nil
@@ -1705,6 +1890,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1705 1890
 		errThree := UpDateDrugWarehouseInfoByStock(&info)
1706 1891
 
1707 1892
 		if errThree != nil {
1893
+			drugError := models.XtDrugError{
1894
+				UserOrgId:             orgID,
1895
+				DrugId:                advice.DrugId,
1896
+				RecordDate:            advice.AdviceDate,
1897
+				PatientId:             advice.PatientId,
1898
+				Remark:                "第二批次扣减库存失败",
1899
+				Status:                1,
1900
+				Ctime:                 time.Now().Unix(),
1901
+				Mtime:                 0,
1902
+				SumCount:              0,
1903
+				Prescribingnumber:     advice.PrescribingNumber,
1904
+				PrescribingNumberUnit: advice.PrescribingNumberUnit,
1905
+			}
1906
+			CreateDrugError(drugError)
1708 1907
 			return errThree
1709 1908
 		}
1710 1909
 		//查询剩余库存
@@ -1749,9 +1948,22 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1749 1948
 		//查询是否存在出库数据
1750 1949
 		_, errCode := GetSigleDrugWarehouseOutInfo(advice.PatientId, advice.AdviceDate, orgID)
1751 1950
 		if errCode == gorm.ErrRecordNotFound {
1752
-			fmt.Println("j你俩3233223323232323233wo")
1753 1951
 			errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1754 1952
 			if errOne != nil {
1953
+				drugError := models.XtDrugError{
1954
+					UserOrgId:             orgID,
1955
+					DrugId:                advice.DrugId,
1956
+					RecordDate:            advice.AdviceDate,
1957
+					PatientId:             advice.PatientId,
1958
+					Remark:                "创建出库表失败",
1959
+					Status:                1,
1960
+					Ctime:                 time.Now().Unix(),
1961
+					Mtime:                 0,
1962
+					SumCount:              0,
1963
+					Prescribingnumber:     advice.PrescribingNumber,
1964
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
1965
+				}
1966
+				CreateDrugError(drugError)
1755 1967
 				return errOne
1756 1968
 			}
1757 1969
 		}
@@ -1768,6 +1980,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1768 1980
 			if deliver_number != his_count {
1769 1981
 				errThree := UpdateSingleDrugWarehouseOutInfoSix(advice.PatientId, advice.AdviceDate, orgID, warehouseOutInfo, advice.ID)
1770 1982
 				if errThree != nil {
1983
+					drugError := models.XtDrugError{
1984
+						UserOrgId:             orgID,
1985
+						DrugId:                advice.DrugId,
1986
+						RecordDate:            advice.AdviceDate,
1987
+						PatientId:             advice.PatientId,
1988
+						Remark:                "更新出库表失败",
1989
+						Status:                1,
1990
+						Ctime:                 time.Now().Unix(),
1991
+						Mtime:                 0,
1992
+						SumCount:              0,
1993
+						Prescribingnumber:     advice.PrescribingNumber,
1994
+						PrescribingNumberUnit: advice.PrescribingNumberUnit,
1995
+					}
1996
+					CreateDrugError(drugError)
1771 1997
 					return errThree
1772 1998
 				}
1773 1999
 			}
@@ -1795,11 +2021,42 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1795 2021
 		if errcodeThree == gorm.ErrRecordNotFound {
1796 2022
 			errTwo := AddSigleDrugAutoReduceRecordInfo(details)
1797 2023
 			if errTwo != nil {
2024
+				drugError := models.XtDrugError{
2025
+					UserOrgId:             orgID,
2026
+					DrugId:                advice.DrugId,
2027
+					RecordDate:            advice.AdviceDate,
2028
+					PatientId:             advice.PatientId,
2029
+					Remark:                "第二批次新增自动出库表失败",
2030
+					Status:                1,
2031
+					Ctime:                 time.Now().Unix(),
2032
+					Mtime:                 0,
2033
+					SumCount:              0,
2034
+					Prescribingnumber:     advice.PrescribingNumber,
2035
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
2036
+				}
2037
+				CreateDrugError(drugError)
1798 2038
 				return errTwo
1799 2039
 			}
1800 2040
 		}
1801 2041
 		if errcodeThree == nil {
1802
-			UpdateDrugAutoReduceRecordInfo(advice.PatientId, advice.RecordDate, advice.DrugId, details)
2042
+			errThreeauto := UpdateDrugAutoReduceRecordInfo(advice.PatientId, advice.RecordDate, advice.DrugId, details)
2043
+			if errThreeauto != nil {
2044
+				drugError := models.XtDrugError{
2045
+					UserOrgId:             orgID,
2046
+					DrugId:                advice.DrugId,
2047
+					RecordDate:            advice.AdviceDate,
2048
+					PatientId:             advice.PatientId,
2049
+					Remark:                "第二批次更新自动出库表失败",
2050
+					Status:                1,
2051
+					Ctime:                 time.Now().Unix(),
2052
+					Mtime:                 0,
2053
+					SumCount:              0,
2054
+					Prescribingnumber:     advice.PrescribingNumber,
2055
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
2056
+				}
2057
+				CreateDrugError(drugError)
2058
+			}
2059
+
1803 2060
 		}
1804 2061
 
1805 2062
 		var out_count int64
@@ -1855,9 +2112,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1855 2112
 			AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
1856 2113
 		}
1857 2114
 
1858
-		fmt.Println("libai", out_count)
1859
-		fmt.Println("cancel", cancel_count)
1860
-		fmt.Println("deliver_number", deliver_number)
1861 2115
 		if deliver_number < (out_count - cancel_count) {
1862 2116
 			operation_time := time.Now().Unix()
1863 2117
 
@@ -1884,7 +2138,23 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1884 2138
 
1885 2139
 			_, errCode := FindDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
1886 2140
 			if errCode == gorm.ErrRecordNotFound {
1887
-				AddSigleDrugCancelStock(&cancelStock)
2141
+				errCodeCancel := AddSigleDrugCancelStock(&cancelStock)
2142
+				if errCodeCancel != nil {
2143
+					drugError := models.XtDrugError{
2144
+						UserOrgId:             orgID,
2145
+						DrugId:                advice.DrugId,
2146
+						RecordDate:            advice.AdviceDate,
2147
+						PatientId:             advice.PatientId,
2148
+						Remark:                "第二批次新增流水表失败",
2149
+						Status:                1,
2150
+						Ctime:                 time.Now().Unix(),
2151
+						Mtime:                 0,
2152
+						SumCount:              0,
2153
+						Prescribingnumber:     advice.PrescribingNumber,
2154
+						PrescribingNumberUnit: advice.PrescribingNumberUnit,
2155
+					}
2156
+					CreateDrugError(drugError)
2157
+				}
1888 2158
 			}
1889 2159
 			lastDrugCancelStock, _ := FindLastDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
1890 2160
 
@@ -1916,7 +2186,23 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1916 2186
 				StorehouseId:     storeConfig.DrugStorehouseOut,
1917 2187
 				IsCheck:          1,
1918 2188
 			}
1919
-			CreatedCancelStock(cancelStockInfo)
2189
+			errCodeCancel := CreatedCancelStock(cancelStockInfo)
2190
+			if errCodeCancel != nil {
2191
+				drugError := models.XtDrugError{
2192
+					UserOrgId:             orgID,
2193
+					DrugId:                advice.DrugId,
2194
+					RecordDate:            advice.AdviceDate,
2195
+					PatientId:             advice.PatientId,
2196
+					Remark:                "第二批次创建自动退库表失败",
2197
+					Status:                1,
2198
+					Ctime:                 time.Now().Unix(),
2199
+					Mtime:                 0,
2200
+					SumCount:              0,
2201
+					Prescribingnumber:     advice.PrescribingNumber,
2202
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
2203
+				}
2204
+				CreateDrugError(drugError)
2205
+			}
1920 2206
 			flow := models.DrugFlow{
1921 2207
 				WarehousingId:           warehouse.ID,
1922 2208
 				DrugId:                  warehouse.DrugId,
@@ -1954,11 +2240,59 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1954 2240
 				LastPrice:               warehouse.Price,
1955 2241
 				OverCount:               sum_count,
1956 2242
 			}
1957
-			CreateDrugFlowOne(flow)
2243
+			errCodeFlows := CreateDrugFlowOne(flow)
2244
+			if errCodeFlows != nil {
2245
+				drugError := models.XtDrugError{
2246
+					UserOrgId:             orgID,
2247
+					DrugId:                advice.DrugId,
2248
+					RecordDate:            advice.AdviceDate,
2249
+					PatientId:             advice.PatientId,
2250
+					Remark:                "第二批次创建自动退库流水表失败",
2251
+					Status:                1,
2252
+					Ctime:                 time.Now().Unix(),
2253
+					Mtime:                 0,
2254
+					SumCount:              0,
2255
+					Prescribingnumber:     advice.PrescribingNumber,
2256
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
2257
+				}
2258
+				CreateDrugError(drugError)
2259
+			}
1958 2260
 
1959 2261
 			//退库数量增加
1960
-			AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
1961
-			ReduceDrugCountTwo(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, flow.Count)
2262
+			errCodeFlows = AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
2263
+			if errCodeFlows != nil {
2264
+				drugError := models.XtDrugError{
2265
+					UserOrgId:             orgID,
2266
+					DrugId:                advice.DrugId,
2267
+					RecordDate:            advice.AdviceDate,
2268
+					PatientId:             advice.PatientId,
2269
+					Remark:                "第二批次创建自动退库流水表失败",
2270
+					Status:                1,
2271
+					Ctime:                 time.Now().Unix(),
2272
+					Mtime:                 0,
2273
+					SumCount:              0,
2274
+					Prescribingnumber:     advice.PrescribingNumber,
2275
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
2276
+				}
2277
+				CreateDrugError(drugError)
2278
+			}
2279
+			errCodereduce := ReduceDrugCountTwo(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, flow.Count)
2280
+			if errCodereduce != nil {
2281
+				drugError := models.XtDrugError{
2282
+					UserOrgId:             orgID,
2283
+					DrugId:                advice.DrugId,
2284
+					RecordDate:            advice.AdviceDate,
2285
+					PatientId:             advice.PatientId,
2286
+					Remark:                "第二批次减少库存表失败",
2287
+					Status:                1,
2288
+					Ctime:                 time.Now().Unix(),
2289
+					Mtime:                 0,
2290
+					SumCount:              0,
2291
+					Prescribingnumber:     advice.PrescribingNumber,
2292
+					PrescribingNumberUnit: advice.PrescribingNumberUnit,
2293
+				}
2294
+				CreateDrugError(drugError)
2295
+			}
1962 2296
 		}
1963 2297
 
1964 2298
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作

+ 17 - 17
service/patient_schedule_template_service.go View File

@@ -444,22 +444,22 @@ func UpdateScheduleTemplate(orgID int64, template_id int64,
444 444
 	//	}
445 445
 	//}
446 446
 
447
-	if orgID != 9671 && orgID != 10340 {
448
-		if shouldUpdateNextWeekSchedules {
449
-			nextWeek := now.AddDate(0, 0, 7)
450
-			if updateErr := _updateWeekSchedules(tx, orgID, nextWeek, addTemplateItems, delTemplateItems, changeTemplateItems, devicesMap); updateErr != nil {
451
-				tx.Rollback()
452
-				return updateErr
453
-			}
454
-		}
455
-		if shouldUpdateNextSecondWeekSchedules {
456
-			nextWeek := now.AddDate(0, 0, 14)
457
-			if updateErr := _updateWeekSchedules(tx, orgID, nextWeek, addTemplateItems, delTemplateItems, changeTemplateItems, devicesMap); updateErr != nil {
458
-				tx.Rollback()
459
-				return updateErr
460
-			}
461
-		}
462
-	}
447
+	//if orgID != 9671 && orgID != 10340 {
448
+	//	if shouldUpdateNextWeekSchedules {
449
+	//		nextWeek := now.AddDate(0, 0, 7)
450
+	//		if updateErr := _updateWeekSchedules(tx, orgID, nextWeek, addTemplateItems, delTemplateItems, changeTemplateItems, devicesMap); updateErr != nil {
451
+	//			tx.Rollback()
452
+	//			return updateErr
453
+	//		}
454
+	//	}
455
+	//	if shouldUpdateNextSecondWeekSchedules {
456
+	//		nextWeek := now.AddDate(0, 0, 14)
457
+	//		if updateErr := _updateWeekSchedules(tx, orgID, nextWeek, addTemplateItems, delTemplateItems, changeTemplateItems, devicesMap); updateErr != nil {
458
+	//			tx.Rollback()
459
+	//			return updateErr
460
+	//		}
461
+	//	}
462
+	//}
463 463
 
464 464
 	tx.Commit()
465 465
 	return nil
@@ -909,7 +909,7 @@ func GetSchTemplatePatientList(orgID int64) ([]*SchTemplatePatient, error) {
909 909
 }
910 910
 
911 911
 func UpdateTemplateItemWeek(orgID int64, id int64, week_time int8) {
912
-	readDb.Model(&models.PatientScheduleTemplateId{}).Where("org_id = ? AND status = 1 AND id = ? ", orgID, id).Updates(map[string]interface{}{"week": week_time})
912
+	writeDb.Model(&models.PatientScheduleTemplateId{}).Where("org_id = ? AND status = 1 AND id = ? ", orgID, id).Updates(map[string]interface{}{"week": week_time})
913 913
 	return
914 914
 }
915 915
 

+ 11 - 0
service/pharmacy_service.go View File

@@ -2021,3 +2021,14 @@ func FindeHisAdviceDocAdvice(orgid int64, patient_id int64, stime int64, etime i
2021 2021
 
2022 2022
 	return advice, err
2023 2023
 }
2024
+
2025
+func GetFlow(drug_id int64, system_time int64, org_id int64, patient_id int64) (flow []*models.DrugFlow, err error) {
2026
+
2027
+	err = XTWriteDB().Where("drug_id = ? and system_time =? and user_org_id = ? and status = 1 and patient_id =?", drug_id, system_time, org_id, patient_id).Find(&flow).Error
2028
+	return flow, err
2029
+}
2030
+
2031
+func UpdateAdviceFlow(id int64) error {
2032
+	err := XTWriteDB().Model(&models.HisDoctorAdviceInfo{}).Where("id = ? and status = 1 and is_medicine =0", id).Update(map[string]interface{}{"is_medicine": 1}).Error
2033
+	return err
2034
+}

+ 23 - 0
service/self_drug_service.go View File

@@ -2599,6 +2599,29 @@ func GetGoodNewPurchaseStockQuery(good_type int64, keyword string, page int64, l
2599 2599
 	return goodinfo, total, err
2600 2600
 }
2601 2601
 
2602
+func GetGoodNewPurchaseStockQueryOne(good_type int64, keyword string, page int64, limit int64, orgid int64, ids []int64, goodIds []int64) (goodinfo []*models.GoodInfoTwenty, total int64, err error) {
2603
+
2604
+	db := XTReadDB().Model(&goodinfo).Where("status = 1")
2605
+	offset := (page - 1) * limit
2606
+	likeKey := "%" + keyword + "%"
2607
+	if good_type > 0 {
2608
+		db = db.Where("good_type_id = ?", good_type)
2609
+	}
2610
+
2611
+	if orgid > 0 {
2612
+		db = db.Where("org_id = ?", orgid)
2613
+	}
2614
+	if len(ids) > 0 {
2615
+		db = db.Where("id in(?)", goodIds)
2616
+	}
2617
+	if len(keyword) > 0 {
2618
+		db = db.Where("good_name like ? or manufacturer in(?)", likeKey, ids)
2619
+	}
2620
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&goodinfo).Error
2621
+
2622
+	return goodinfo, total, err
2623
+}
2624
+
2602 2625
 func GetStartLastFLow(goodid int64, orgid int64, startime int64) (models.VmStockFlowTwenty, error) {
2603 2626
 
2604 2627
 	flwo := models.VmStockFlowTwenty{}

+ 80 - 0
service/stock_service.go View File

@@ -8521,3 +8521,83 @@ func UpdateDeleteAutoGood(good_id int64, record_date int64, patient_id int64) er
8521 8521
 	err = XTWriteDB().Model(&models.DialysisBeforePrepare{}).Where("good_id = ? and record_date = ? and patient_id = ?", good_id, record_date, patient_id).Updates(map[string]interface{}{"status": 1}).Error
8522 8522
 	return err
8523 8523
 }
8524
+
8525
+func UpdateWarehouseInfoMap(list []*models.WarehousingInfo, warehousing_info_id int64, orgId int64) error {
8526
+
8527
+	tx := XTWriteDB().Begin()
8528
+
8529
+	for _, item := range list {
8530
+
8531
+		err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", item.ID).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", item.WarehousingCount)).Error
8532
+		if err != nil {
8533
+			tx.Rollback()
8534
+			return err
8535
+		}
8536
+		err = tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", item.ID).Update(map[string]interface{}{"is_check": 2}).Error
8537
+		if err != nil {
8538
+			tx.Rollback()
8539
+			return err
8540
+		}
8541
+
8542
+		err = tx.Model(models.VmStockFlow{}).Where("warehousing_detail_id =  ?", item.ID).Update(map[string]interface{}{"status": 0, "is_check": 2}).Error
8543
+
8544
+		if err != nil {
8545
+			tx.Rollback()
8546
+			return err
8547
+		}
8548
+
8549
+		var goodList []*models.WarehousingInfo
8550
+		err = tx.Where("org_id = ? and storehouse_id = ? and good_id = ? and status =1  and is_check = 1", orgId, item.StorehouseId, item.GoodId).Find(&goodList).Error
8551
+
8552
+		var flush_count int64
8553
+		for _, it := range goodList {
8554
+			flush_count += it.StockCount
8555
+		}
8556
+
8557
+		err = tx.Model(&models.XtGoodStockCount{}).Where("user_org_id = ? and good_id  = ? and storehouse_id = ? and status = 1", item.OrgId, item.GoodId, item.StorehouseId).UpdateColumn("stock_in_count", gorm.Expr("stock_in_count - ?", item.WarehousingCount)).Error
8558
+		if err != nil {
8559
+			tx.Rollback()
8560
+			return err
8561
+		}
8562
+		err = tx.Model(&models.XtGoodStockCount{}).Where("user_org_id = ? and good_id = ? and storehouse_id = ? and status = 1", item.OrgId, item.GoodId, item.StorehouseId).Update(map[string]interface{}{"flush_count": flush_count}).Error
8563
+		if err != nil {
8564
+			tx.Rollback()
8565
+			return err
8566
+		}
8567
+
8568
+		storeHouseConfig := models.XtStorehouseConfig{}
8569
+		err = tx.Where("user_org_id = ? and status = 1", orgId).First(&storeHouseConfig).Error
8570
+
8571
+		var stockList []*models.WarehousingInfo
8572
+		//查询该耗材剩余多少库存
8573
+		err = tx.Where("good_id = ? and storehouse_id = ? and org_id = ? and status = 1 and is_check = 1", item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId).Find(&stockList).Error
8574
+
8575
+		var sum_count int64
8576
+		var sum_in_count int64
8577
+		for _, it := range stockList {
8578
+			sum_count += it.StockCount
8579
+			sum_in_count += it.WarehousingCount
8580
+		}
8581
+
8582
+		err = tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", item.GoodId, orgId).Update(map[string]interface{}{"sum_count": sum_count}).Error
8583
+		if err != nil {
8584
+			tx.Rollback()
8585
+			return err
8586
+		}
8587
+		err = tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", item.GoodId, orgId).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
8588
+		if err != nil {
8589
+			tx.Rollback()
8590
+			return err
8591
+		}
8592
+
8593
+	}
8594
+	err := tx.Model(&models.Warehousing{}).Where("id = ? and status = 1", warehousing_info_id).Update(map[string]interface{}{"is_check": 2}).Error
8595
+	if err != nil {
8596
+		tx.Rollback()
8597
+		return err
8598
+	}
8599
+	err = tx.Model(&models.WarehousingInfo{}).Where("warehousing_id = ? and status = 1", warehousing_info_id).Update(map[string]interface{}{"is_check": 2}).Error
8600
+	tx.Commit()
8601
+	return err
8602
+
8603
+}

+ 14 - 0
service/warhouse_service.go View File

@@ -483,6 +483,7 @@ func HisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdvice
483 483
 	// 2.判断当天当前机构有没有创建出库单,没有则创建
484 484
 	// 3.创建出库流程
485 485
 	// 3.1 实现先进先出逻辑 由于药品执行后,不可以修改和删除,所以不考虑出库后的退库和修改出库数量等
486
+
486 487
 	isHasWay := false
487 488
 	record_time := int64(0)
488 489
 	isHasWay = true
@@ -491,6 +492,7 @@ func HisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdvice
491 492
 	if isHasWay {
492 493
 		//判断当天当前机构有没有创建出库单,没有则创建
493 494
 		out, err := FindDrugStockOutByIsSys(orgID, 1, record_time)
495
+
494 496
 		houseConfig, _ := GetAllStoreHouseConfig(orgID)
495 497
 		if err == gorm.ErrRecordNotFound {
496 498
 			timeStr := time.Now().Format("2006-01-02")
@@ -7475,3 +7477,15 @@ func UpdateAutomaticReduce(patient_id int64, record_date int64, good_id int64, p
7475 7477
 	err := XTWriteDB().Model(&models.AutomaticReduceDetail{}).Where("patient_id = ? and record_time =? and good_id = ? and project_id = ? and status = 1", patient_id, record_date, good_id, project_id).Update(map[string]interface{}{"status": 0}).Error
7476 7478
 	return err
7477 7479
 }
7480
+
7481
+func GetDrugFLowByAdviceById(drug_id int64, patient_id int64, user_org_id int64, advice_date int64) (outInfo []*models.DrugWarehouseOutInfo, err error) {
7482
+
7483
+	err = XTReadDB().Where("drug_id = ? and patient_id = ? and org_id = ? and sys_record_time = ? and status= 1", drug_id, patient_id, user_org_id, advice_date).Find(&outInfo).Error
7484
+	return outInfo, err
7485
+}
7486
+
7487
+func UpdateHisAdviceById(id int64) error {
7488
+
7489
+	err := XTWriteDB().Model(&models.HisDoctorAdviceInfo{}).Where("id = ?", id).Updates(map[string]interface{}{"execution_time": "", "execution_staff": "", "execution_state": 2}).Error
7490
+	return err
7491
+}