Sfoglia il codice sorgente

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

28169 1 anno fa
parent
commit
7f17fdca2e

+ 502 - 311
controllers/his_api_controller.go Vedi 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() {
@@ -5569,7 +5881,7 @@ func (c *HisApiController) setAdviceTemplateWithJSON(advice *models.HisPrescript
5569 5881
 		day := int64(json["day"].(float64))
5570 5882
 		advice.Day = day
5571 5883
 	}
5572
-
5884
+	advice.FrequencyType = 1
5573 5885
 	return 0
5574 5886
 }
5575 5887
 
@@ -5624,6 +5936,8 @@ func (c *HisApiController) setProjectTemplateWithJSON(project *models.HisPrescri
5624 5936
 		unit, _ := json["unit"].(string)
5625 5937
 		project.Unit = unit
5626 5938
 	}
5939
+	project.FrequencyType = 1
5940
+
5627 5941
 	return 0
5628 5942
 }
5629 5943
 
@@ -5637,6 +5951,8 @@ func (c *HisApiController) GetHisOrderList() {
5637 5951
 	p_type, _ := c.GetInt64("p_type", 0)
5638 5952
 	sort_type, _ := c.GetInt64("sort_type", 0)
5639 5953
 	charge_type, _ := c.GetInt64("charge_type", 0)
5954
+	sch_type, _ := c.GetInt64("sch_type", 0)
5955
+	zone_type, _ := c.GetInt64("zone_type", 0)
5640 5956
 
5641 5957
 	timeLayout := "2006-01-02"
5642 5958
 	loc, _ := time.LoadLocation("Local")
@@ -5663,7 +5979,7 @@ func (c *HisApiController) GetHisOrderList() {
5663 5979
 
5664 5980
 	adminUser := c.GetAdminUserInfo()
5665 5981
 	org_id := adminUser.CurrentOrgId
5666
-	order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type, start_time, end_time, charge_type)
5982
+	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)
5667 5983
 
5668 5984
 	for _, item := range order {
5669 5985
 		info, _ := service.GetHisPrescriptionByPatientID(item.PatientId, item.UserOrgId)
@@ -6205,12 +6521,6 @@ func (c *HisApiController) GetUploadInfo() {
6205 6521
 	pay_way, _ := c.GetInt64("pay_way")
6206 6522
 	pay_ways := c.GetString("pay_ways")
6207 6523
 
6208
-	cash_pay := c.GetString("cash_pay")
6209
-	band_card_pay := c.GetString("band_card_pay")
6210
-	wechat_pay := c.GetString("wechat_pay")
6211
-	ali_pay := c.GetString("ali_pay")
6212
-	jifen_pay := c.GetString("jifen_pay")
6213
-
6214 6524
 	pay_price, _ := c.GetFloat("pay_price")
6215 6525
 	pay_card_no := c.GetString("pay_card_no")
6216 6526
 	discount_price, _ := c.GetFloat("discount_price")
@@ -6231,6 +6541,12 @@ func (c *HisApiController) GetUploadInfo() {
6231 6541
 	reg_type, _ := c.GetInt64("p_type")
6232 6542
 	order_id, _ := c.GetInt64("order_id")
6233 6543
 
6544
+	cash_pay := c.GetString("cash_pay")
6545
+	wechat_pay := c.GetString("wechat_pay")
6546
+	ali_pay := c.GetString("ali_pay")
6547
+	jifen_pay := c.GetString("jifen_pay")
6548
+	band_card_pay := c.GetString("band_card_pay")
6549
+
6234 6550
 	dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
6235 6551
 	tmp_decimal := c.GetString("tmp_decimal")
6236 6552
 	var decimal float64 //本次使用的押金
@@ -6258,10 +6574,7 @@ func (c *HisApiController) GetUploadInfo() {
6258 6574
 	}
6259 6575
 	tt, errs := strconv.ParseFloat(tmp_decimal, 64)
6260 6576
 	fmt.Println(errs)
6261
-	//if errs != nil {
6262
-	//	c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
6263
-	//	return
6264
-	//}
6577
+
6265 6578
 	decimal = tt
6266 6579
 
6267 6580
 	his, _ := service.GetHisPatientByIdThreeTX(his_patient_id, tx)
@@ -6828,232 +7141,8 @@ func (c *HisApiController) GetUploadInfo() {
6828 7141
 			})
6829 7142
 
6830 7143
 		}
6831
-	} else {
6832
-		if tempOrder.IsPre > 0 {
6833
-			allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
6834
-			totals, _ := strconv.ParseFloat(allTotal, 64)
6835
-			tempOrder.OrderStatus = 2
6836
-			tempOrder.PayWay = pay_way
6837
-			tempOrder.PayPrice = pay_price
6838
-			tempOrder.PayCardNo = pay_card_no
6839
-			tempOrder.DiscountPrice = discount_price
6840
-			tempOrder.PreferentialPrice = preferential_price
6841
-			tempOrder.RealityPrice = reality_price
6842
-			tempOrder.FoundPrice = found_price
6843
-			tempOrder.MedicalInsurancePrice = medical_insurance_price
6844
-			tempOrder.PrivatePrice = private_price
6845
-			tempOrder.FaPiaoCode = fapiao_code
6846
-			tempOrder.FaPiaoNumber = fapiao_number
6847
-			tempOrder.PType = 2
6848
-			tempOrder.MedfeeSumamt = totals
6849
-			tempOrder.Diagnosis = diagnosis_id
6850
-			err = service.SaveHisOrder(&tempOrder)
6851
-			err = service.UpdataOrderStatusTwo(tempOrder.Number, adminUser.CurrentOrgId)
6852
-			if err != nil {
6853
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
6854
-				return
6855
-			}
6856
-			if err == nil {
6857
-				houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
6858
-				var goods []*models.DialysisBeforePrepareGoods
6859
-				var newGoods []*models.NewDialysisBeforePrepareGoods
6860
-				var infos []*models.HisDoctorAdviceInfo
6861
-				var hisAdvice []*models.HisDoctorAdviceInfo
6862
-				var newGoodOne []*models.NewDialysisBeforePrepareGoods
6863
-				var infolist []*models.HisDoctorAdviceInfo
6864
-				var oldGoods []*models.OldDialysisBeforePrepareGoods
6865
-				for _, info := range prescriptions {
6866
-					if info.Type == 1 {
6867
-						infos = append(infos, info.HisDoctorAdviceInfo...)
6868
-					}
6869
-					if info.Type == 2 {
6870
-						for _, sumItem := range info.HisPrescriptionProject {
6871
-							if sumItem.Type == 3 {
6872
-								var good models.DialysisBeforePrepareGoods
6873
-								var newGood models.NewDialysisBeforePrepareGoods
6874
-								good.GoodId = sumItem.GoodInfo.ID
6875
-								good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6876
-								count, _ := strconv.Atoi(sumItem.Count)
6877
-								good.Count = int64(count)
6878
-								good.StorehouseId = houseConfig.StorehouseOutInfo
6879
-								good.ProjectId = sumItem.ID
6880
-								goods = append(goods, &good)
6881
-
6882
-								newGood.GoodId = sumItem.GoodInfo.ID
6883
-								newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6884
-								count2, _ := strconv.Atoi(sumItem.Count)
6885
-								newGood.Count = int64(count2)
6886
-								newGood.StorehouseId = houseConfig.StorehouseOutInfo
6887
-								newGood.ProjectId = sumItem.ID
6888
-								newGoods = append(newGoods, &newGood)
6889
-							}
6890
-
6891
-						}
6892
-
6893
-					}
6894
-				}
6895
-
6896
-				settConfig, _ := service.GetSettleOpenConfigByOrgId(adminUser.CurrentOrgId)
6897
-				if settConfig.IsOpen == 1 {
6898
-
6899
-					//判断库存的地方
6900
-					for _, info := range prescriptions {
6901
-						if info.Type == 1 {
6902
-							infolist = append(infolist, info.HisDoctorAdviceInfo...)
6903
-
6904
-						}
6905
-						if info.Type == 2 {
6906
-							for _, sumItem := range info.HisPrescriptionProject {
6907
-								if sumItem.Type == 3 {
6908
-									var good models.DialysisBeforePrepareGoods
6909
-									var newGood models.NewDialysisBeforePrepareGoods
6910
-									var oldGood models.OldDialysisBeforePrepareGoods
6911
-									good.GoodId = sumItem.GoodInfo.ID
6912
-									good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6913
-									count, _ := strconv.Atoi(sumItem.Count)
6914
-									good.Count = int64(count)
6915
-									good.StorehouseId = houseConfig.StorehouseOutInfo
6916
-									good.ProjectId = sumItem.ID
6917
-									goods = append(goods, &good)
6918
-
6919
-									newGood.GoodId = sumItem.GoodInfo.ID
6920
-									newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6921
-									count2, _ := strconv.Atoi(sumItem.Count)
6922
-									newGood.Count = int64(count2)
6923
-									newGood.StorehouseId = houseConfig.StorehouseOutInfo
6924
-									newGood.ProjectId = sumItem.ID
6925
-									newGoods = append(newGoods, &newGood)
6926
-
6927
-									oldGood.GoodId = sumItem.GoodInfo.ID
6928
-									oldGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6929
-									count3, _ := strconv.Atoi(sumItem.Count)
6930
-									oldGood.Count = int64(count3)
6931
-									oldGood.StorehouseId = houseConfig.StorehouseOutInfo
6932
-									oldGood.ProjectId = sumItem.ID
6933
-									oldGood.RecordDate = sumItem.RecordDate
6934
-
6935
-									oldGoods = append(oldGoods, &oldGood)
6936
-								}
6937
-							}
6938
-						}
6939
-					}
6940
-
6941
-					for _, info := range prescriptionsOne {
6942
-						if info.Type == 1 {
6943
-							hisAdvice = append(hisAdvice, info.HisDoctorAdviceInfo...)
6944
-						}
6945
-
6946
-						if info.Type == 2 {
6947
-							for _, sumItem := range info.HisPrescriptionProject {
6948
-								if sumItem.Type == 3 {
6949
-									var newGood models.NewDialysisBeforePrepareGoods
6950
-
6951
-									newGood.GoodId = sumItem.GoodInfo.ID
6952
-									newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
6953
-									count2, _ := strconv.Atoi(sumItem.Count)
6954
-									newGood.Count = int64(count2)
6955
-									newGood.StorehouseId = houseConfig.StorehouseOutInfo
6956
-									newGood.ProjectId = sumItem.ID
6957
-									newGoodOne = append(newGoodOne, &newGood)
6958
-								}
6959
-							}
6960
-						}
6961
-					}
6962
-
6963
-					//判断
6964
-					for _, itemOne := range infos {
6965
-						for _, itemTwo := range hisAdvice {
6966
-							if itemOne.DrugId == itemTwo.DrugId {
6967
-								itemTwo.Child = append(itemTwo.ChildDoctorAdvice, itemOne)
6968
-							}
6969
-						}
6970
-					}
6971
-
6972
-					for _, itemTwo := range hisAdvice {
6973
-						medical, _ := service.GetBaseDrugMedical(itemTwo.DrugId)
6974
-						var sum_out_count int64
6975
-						for _, itemThree := range itemTwo.Child {
6976
-							var prescribing_number int64
6977
-							stringPrescribingNumber := strconv.FormatFloat(itemThree.PrescribingNumber, 'f', -1, 64)
6978
-							parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
6979
-							if itemThree.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6980
-								prescribing_number = parseIntPrescribingNumber * medical.MinNumber
6981
-							}
6982
-							if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
6983
-								prescribing_number = parseIntPrescribingNumber
6984
-							}
6985
-							if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
6986
-								prescribing_number = parseIntPrescribingNumber
6987
-							}
6988
-							sum_out_count += prescribing_number
6989
-						}
6990
-						houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
6991
-						drugStockOut, _ := service.GetDrugSumOutCountByDrugId(itemTwo.DrugId, adminUser.CurrentOrgId, houseConfig.DrugStorehouseOut)
6992
-
6993
-						if sum_out_count > drugStockOut.FlushCount {
6994
-							c.ServeSuccessJSON(map[string]interface{}{
6995
-								"msg":  "2",
6996
-								"drug": medical,
6997
-							})
6998
-							return
6999
-						}
7000
-					}
7001
-
7002
-					for _, itemOne := range newGoods {
7003
-						for _, item := range newGoodOne {
7004
-							if itemOne.ProjectId == item.ProjectId {
7005
-								item.ChildNewDialysisBeforePrepareGoods = append(item.ChildNewDialysisBeforePrepareGoods, item)
7006
-							}
7007
-						}
7008
-					}
7009
-
7010
-					for _, item := range newGoodOne {
7011
-						var sum_out_count_one int64
7012
-						good, _ := service.GetGoodInformationByGoodIdOne(item.GoodId)
7013
-
7014
-						for _, itemOne := range item.ChildNewDialysisBeforePrepareGoods {
7015
-							sum_out_count_one += itemOne.Count
7016
-						}
7017
-						list, _ := service.GetStockGoodList(item.GoodId, adminUser.CurrentOrgId, houseConfig.StorehouseOutInfo)
7018
-						fmt.Println("sum_out_count_one", sum_out_count_one)
7019
-						fmt.Println("list.FlushCount", list.FlushCount)
7020
-						if sum_out_count_one > list.FlushCount {
7021
-							c.ServeSuccessJSON(map[string]interface{}{
7022
-								"msg":  "3",
7023
-								"good": good,
7024
-							})
7025
-							return
7026
-						}
7027
-					}
7028
-					for _, item := range infolist {
7029
-						service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
7030
-					}
7031
-					for _, item := range oldGoods {
7032
-						dialyPrepareOne := models.DialysisBeforePrepare{
7033
-							GoodTypeId:   item.GoodTypeId,
7034
-							GoodId:       item.GoodId,
7035
-							PatientId:    item.PatientId,
7036
-							RecordDate:   item.RecordDate,
7037
-							UserOrgId:    item.UserOrgId,
7038
-							Count:        item.Count,
7039
-							Ctime:        time.Now().Unix(),
7040
-							Creater:      adminUser.AdminUser.Id,
7041
-							CommdityCode: item.CommdityCode,
7042
-							Status:       1,
7043
-							StorehouseId: houseConfig.StorehouseOutInfo,
7044
-						}
7045
-						err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
7046
-					}
7047
-
7048
-					service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
7049
-				}
7050
-
7051
-				c.ServeSuccessJSON(map[string]interface{}{
7052
-					"msg": "结算成功",
7053
-				})
7054
-			}
7055
-		}
7056 7144
 	}
7145
+
7057 7146
 }
7058 7147
 
7059 7148
 // 退款
@@ -9188,96 +9277,198 @@ func (c *HisApiController) CreateHisPrescriptionTemplate() {
9188 9277
 		return
9189 9278
 	}
9190 9279
 
9191
-	err = service.CreateHisPrescriptionTemplate(template)
9192
-	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
9193
-		prescriptions, _ := dataBody["prescriptions"].([]interface{})
9194
-		if len(prescriptions) > 0 {
9195
-			for _, item := range prescriptions {
9196
-				items := item.(map[string]interface{})
9197
-				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
9198
-					utils.ErrorLog("type")
9199
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9200
-					return
9201
-				}
9202
-				types := int64(items["type"].(float64))
9280
+	template_one, _ := service.GetHisPrescriptionTemplateByModeId(mode_id, patient_id, c.GetAdminUserInfo().CurrentOrgId)
9203 9281
 
9204
-				if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
9205
-					utils.ErrorLog("med_type")
9206
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9207
-					return
9208
-				}
9209
-				med_type := strconv.Itoa(int(items["med_type"].(float64)))
9282
+	//如果已经存在记录则删除处方
9283
+	if template_one.ID > 0 {
9284
+		ps, _ := service.GetHisPrescriptionInfoTemplates(template_one.ID, template_one.UserOrgId)
9285
+		for _, item := range ps {
9286
+			service.DelelteHisPrescriptionInfoTemplate(item.ID, item.UserOrgId)
9287
+		}
9288
+		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
9289
+			prescriptions, _ := dataBody["prescriptions"].([]interface{})
9290
+			if len(prescriptions) > 0 {
9291
+				for _, item := range prescriptions {
9292
+					items := item.(map[string]interface{})
9293
+					if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
9294
+						utils.ErrorLog("type")
9295
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9296
+						return
9297
+					}
9298
+					types := int64(items["type"].(float64))
9210 9299
 
9211
-				ctime := time.Now().Unix()
9212
-				prescription := &models.HisPrescriptionInfoTemplate{
9213
-					PatientId:   patient_id,
9214
-					UserOrgId:   adminInfo.CurrentOrgId,
9215
-					Ctime:       ctime,
9216
-					Mtime:       ctime,
9217
-					Type:        types,
9218
-					Modifier:    adminInfo.AdminUser.Id,
9219
-					Creator:     adminInfo.AdminUser.Id,
9220
-					Status:      1,
9221
-					PTemplateId: template.ID,
9222
-					MedType:     med_type,
9223
-				}
9224
-				service.CreateHisPrescriptionInfoTemplate(prescription)
9300
+					if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
9301
+						utils.ErrorLog("med_type")
9302
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9303
+						return
9304
+					}
9305
+					med_type := strconv.Itoa(int(items["med_type"].(float64)))
9225 9306
 
9226
-				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
9227
-					advices := items["advices"].([]interface{})
9228
-					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
9229 9307
 					ctime := time.Now().Unix()
9230
-					mtime := ctime
9231
-					if len(advices) > 0 {
9232
-						for _, advice := range advices {
9233
-							var s models.HisPrescriptionAdviceTemplate
9234
-							s.PrescriptionId = prescription.ID
9235
-							s.AdviceType = 2
9236
-							s.StopState = 2
9237
-							s.ExecutionState = 2
9238
-							s.Status = 1
9239
-							s.UserOrgId = adminInfo.CurrentOrgId
9240
-							s.CreatedTime = ctime
9241
-							s.UpdatedTime = mtime
9242
-							s.PatientId = patient_id
9243
-							errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
9244
-							if errcode > 0 {
9245
-								c.ServeFailJSONWithSGJErrorCode(errcode)
9246
-								return
9247
-							}
9308
+					prescription := &models.HisPrescriptionInfoTemplate{
9309
+						PatientId:   patient_id,
9310
+						UserOrgId:   adminInfo.CurrentOrgId,
9311
+						Ctime:       ctime,
9312
+						Mtime:       ctime,
9313
+						Type:        types,
9314
+						Modifier:    adminInfo.AdminUser.Id,
9315
+						Creator:     adminInfo.AdminUser.Id,
9316
+						Status:      1,
9317
+						PTemplateId: template_one.ID,
9318
+						MedType:     med_type,
9319
+					}
9320
+					service.CreateHisPrescriptionInfoTemplate(prescription)
9248 9321
 
9249
-							service.CreateHisPrescriptionAdviceTemplate(&s)
9322
+					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
9323
+						advices := items["advices"].([]interface{})
9324
+						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
9325
+						ctime := time.Now().Unix()
9326
+						mtime := ctime
9327
+						if len(advices) > 0 {
9328
+							for _, advice := range advices {
9329
+								var s models.HisPrescriptionAdviceTemplate
9330
+								s.PrescriptionId = prescription.ID
9331
+								s.AdviceType = 2
9332
+								s.StopState = 2
9333
+								s.ExecutionState = 2
9334
+								s.Status = 1
9335
+								s.UserOrgId = adminInfo.CurrentOrgId
9336
+								s.CreatedTime = ctime
9337
+								s.UpdatedTime = mtime
9338
+								s.PatientId = patient_id
9339
+								errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
9340
+								if errcode > 0 {
9341
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9342
+									return
9343
+								}
9344
+
9345
+								service.CreateHisPrescriptionAdviceTemplate(&s)
9250 9346
 
9347
+							}
9251 9348
 						}
9252 9349
 					}
9350
+					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
9351
+						projects := items["project"].([]interface{})
9352
+						if len(projects) > 0 {
9353
+							for _, project := range projects {
9354
+								var p models.HisPrescriptionProjectTemplate
9355
+								p.PrescriptionId = prescription.ID
9356
+								p.Ctime = time.Now().Unix()
9357
+								p.Mtime = time.Now().Unix()
9358
+								p.PatientId = patient_id
9359
+								p.UserOrgId = adminInfo.CurrentOrgId
9360
+								p.Status = 1
9361
+								errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
9362
+								if errcode > 0 {
9363
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9364
+									return
9365
+								}
9366
+								service.CreateHisPrescriptionProjectTemplate(&p)
9367
+
9368
+							}
9369
+						}
9370
+					}
9371
+
9253 9372
 				}
9254
-				if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
9255
-					projects := items["project"].([]interface{})
9256
-					if len(projects) > 0 {
9257
-						for _, project := range projects {
9258
-							var p models.HisPrescriptionProjectTemplate
9259
-							p.PrescriptionId = prescription.ID
9260
-							p.Ctime = time.Now().Unix()
9261
-							p.Mtime = time.Now().Unix()
9262
-							p.PatientId = patient_id
9263
-							p.UserOrgId = adminInfo.CurrentOrgId
9264
-							p.Status = 1
9265
-							errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
9266
-							if errcode > 0 {
9267
-								c.ServeFailJSONWithSGJErrorCode(errcode)
9268
-								return
9373
+
9374
+				c.ServeSuccessJSON(map[string]interface{}{
9375
+					"msg": "创建成功",
9376
+				})
9377
+			}
9378
+		}
9379
+
9380
+	} else {
9381
+		err = service.CreateHisPrescriptionTemplate(template)
9382
+		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
9383
+			prescriptions, _ := dataBody["prescriptions"].([]interface{})
9384
+			if len(prescriptions) > 0 {
9385
+				for _, item := range prescriptions {
9386
+					items := item.(map[string]interface{})
9387
+					if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
9388
+						utils.ErrorLog("type")
9389
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9390
+						return
9391
+					}
9392
+					types := int64(items["type"].(float64))
9393
+
9394
+					if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
9395
+						utils.ErrorLog("med_type")
9396
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9397
+						return
9398
+					}
9399
+					med_type := strconv.Itoa(int(items["med_type"].(float64)))
9400
+
9401
+					ctime := time.Now().Unix()
9402
+					prescription := &models.HisPrescriptionInfoTemplate{
9403
+						PatientId:   patient_id,
9404
+						UserOrgId:   adminInfo.CurrentOrgId,
9405
+						Ctime:       ctime,
9406
+						Mtime:       ctime,
9407
+						Type:        types,
9408
+						Modifier:    adminInfo.AdminUser.Id,
9409
+						Creator:     adminInfo.AdminUser.Id,
9410
+						Status:      1,
9411
+						PTemplateId: template.ID,
9412
+						MedType:     med_type,
9413
+					}
9414
+					service.CreateHisPrescriptionInfoTemplate(prescription)
9415
+
9416
+					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
9417
+						advices := items["advices"].([]interface{})
9418
+						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
9419
+						ctime := time.Now().Unix()
9420
+						mtime := ctime
9421
+						if len(advices) > 0 {
9422
+							for _, advice := range advices {
9423
+								var s models.HisPrescriptionAdviceTemplate
9424
+								s.PrescriptionId = prescription.ID
9425
+								s.AdviceType = 2
9426
+								s.StopState = 2
9427
+								s.ExecutionState = 2
9428
+								s.Status = 1
9429
+								s.UserOrgId = adminInfo.CurrentOrgId
9430
+								s.CreatedTime = ctime
9431
+								s.UpdatedTime = mtime
9432
+								s.PatientId = patient_id
9433
+								errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
9434
+								if errcode > 0 {
9435
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9436
+									return
9437
+								}
9438
+
9439
+								service.CreateHisPrescriptionAdviceTemplate(&s)
9440
+
9269 9441
 							}
9270
-							service.CreateHisPrescriptionProjectTemplate(&p)
9442
+						}
9443
+					}
9444
+					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
9445
+						projects := items["project"].([]interface{})
9446
+						if len(projects) > 0 {
9447
+							for _, project := range projects {
9448
+								var p models.HisPrescriptionProjectTemplate
9449
+								p.PrescriptionId = prescription.ID
9450
+								p.Ctime = time.Now().Unix()
9451
+								p.Mtime = time.Now().Unix()
9452
+								p.PatientId = patient_id
9453
+								p.UserOrgId = adminInfo.CurrentOrgId
9454
+								p.Status = 1
9455
+								errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
9456
+								if errcode > 0 {
9457
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9458
+									return
9459
+								}
9460
+								service.CreateHisPrescriptionProjectTemplate(&p)
9271 9461
 
9462
+							}
9272 9463
 						}
9273 9464
 					}
9465
+
9274 9466
 				}
9275 9467
 
9468
+				c.ServeSuccessJSON(map[string]interface{}{
9469
+					"msg": "创建成功",
9470
+				})
9276 9471
 			}
9277
-
9278
-			c.ServeSuccessJSON(map[string]interface{}{
9279
-				"msg": "创建成功",
9280
-			})
9281 9472
 		}
9282 9473
 	}
9283 9474
 

+ 16 - 1
controllers/his_charge_api_controller.go Vedi 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{}{

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Vedi 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"

+ 35 - 2
controllers/mobile_api_controllers/patient_api_controller.go Vedi File

@@ -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)
@@ -1132,6 +1132,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1132 1132
 						}
1133 1133
 					}
1134 1134
 					if total_count == drug_count {
1135
+
1135 1136
 						advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
1136 1137
 						c.ServeSuccessJSON(map[string]interface{}{
1137 1138
 							"msg":    "1",
@@ -1170,7 +1171,17 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1170 1171
 						}
1171 1172
 
1172 1173
 						if medical.IsUse == 1 {
1173
-
1174
+							drugError := models.XtDrugError{
1175
+								UserOrgId:  adminInfo.Org.Id,
1176
+								DrugId:     item.DrugId,
1177
+								RecordDate: item.AdviceDate,
1178
+								PatientId:  item.PatientId,
1179
+								Remark:     "零用药品",
1180
+								Status:     1,
1181
+								Ctime:      time.Now().Unix(),
1182
+								Mtime:      0,
1183
+							}
1184
+							service.CreateDrugError(drugError)
1174 1185
 							if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1175 1186
 								c.ServeSuccessJSON(map[string]interface{}{
1176 1187
 									"msg":    "1",
@@ -1181,6 +1192,17 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1181 1192
 							}
1182 1193
 						}
1183 1194
 						if medical.IsUse != 1 {
1195
+							drugError := models.XtDrugError{
1196
+								UserOrgId:  adminInfo.Org.Id,
1197
+								DrugId:     item.DrugId,
1198
+								RecordDate: item.AdviceDate,
1199
+								PatientId:  item.PatientId,
1200
+								Remark:     "药品库存不足",
1201
+								Status:     1,
1202
+								Ctime:      time.Now().Unix(),
1203
+								Mtime:      0,
1204
+							}
1205
+							service.CreateDrugError(drugError)
1184 1206
 							if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1185 1207
 								c.ServeSuccessJSON(map[string]interface{}{
1186 1208
 									"msg":    "3",
@@ -1190,6 +1212,17 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1190 1212
 								return
1191 1213
 							}
1192 1214
 							if prescribing_number_total > total {
1215
+								drugError := models.XtDrugError{
1216
+									UserOrgId:  adminInfo.Org.Id,
1217
+									DrugId:     item.DrugId,
1218
+									RecordDate: item.AdviceDate,
1219
+									PatientId:  item.PatientId,
1220
+									Remark:     "出库数量大于库存",
1221
+									Status:     1,
1222
+									Ctime:      time.Now().Unix(),
1223
+									Mtime:      0,
1224
+								}
1225
+								service.CreateDrugError(drugError)
1193 1226
 								c.ServeSuccessJSON(map[string]interface{}{
1194 1227
 									"msg":    "2",
1195 1228
 									"advice": advice,

+ 25 - 9
controllers/pharmacy_controller.go Vedi 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 Vedi 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
+//}

+ 16 - 0
models/drug_stock.go Vedi File

@@ -709,3 +709,19 @@ 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
+}
724
+
725
+func (XtDrugError) TableName() string {
726
+	return "xt_drug_error"
727
+}

+ 82 - 2
models/his_models.go Vedi File

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

+ 321 - 80
service/app_version.go Vedi File

@@ -353,7 +353,6 @@ type HisPrescriptionInfoTemplateTwo struct {
353 353
 func (HisPrescriptionInfoTemplateTwo) TableName() string {
354 354
 	return "his_prescription_info_template"
355 355
 }
356
-
357 356
 func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
358 357
 	err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
359 358
 		Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
@@ -363,11 +362,9 @@ func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplat
363 362
 		Find(&prescription).Error
364 363
 	return
365 364
 }
366
-
367 365
 func SaveAdviceTemplate(advice HisPrescriptionAdviceTemplate) {
368 366
 	writeDb.Save(&advice)
369 367
 }
370
-
371 368
 func GetAllPT(org_id int64) (his []*models.HisPrescriptionTemplate, err error) {
372 369
 	err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
373 370
 	return
@@ -425,7 +422,6 @@ type HisPrescriptionInfoTemplateTHree struct {
425 422
 func (HisPrescriptionInfoTemplateTHree) TableName() string {
426 423
 	return "his_prescription_info_template"
427 424
 }
428
-
429 425
 func GetAllPTInfo(org_id int64, p_template_id int64) (his []*HisPrescriptionInfoTemplateTHree, err error) {
430 426
 	err = readDb.Model(&HisPrescriptionInfoTemplateTHree{}).Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
431 427
 		return db.Where("status = 1")
@@ -434,7 +430,6 @@ func GetAllPTInfo(org_id int64, p_template_id int64) (his []*HisPrescriptionInfo
434 430
 	}).Where("user_org_id = ? AND status = 1 AND p_template_id = ?", org_id, p_template_id).Find(&his).Error
435 431
 	return
436 432
 }
437
-
438 433
 func GetAllInfo(org_id int64, project_id int64) (his []*HisPrescriptionProjectTemplate, err error) {
439 434
 	err = readDb.Model(&HisPrescriptionProjectTemplate{}).Where("user_org_id = ? AND status = 1 AND project_id = ? ", org_id, project_id).Find(&his).Error
440 435
 	return
@@ -443,26 +438,21 @@ func UpdateStatus(project_id int64, p_id int64) {
443 438
 	writeDb.Model(&HisPrescriptionProjectTemplate{}).Where("id = ?", project_id).Updates(map[string]interface{}{"status": 0})
444 439
 	writeDb.Model(&HisPrescriptionInfoTemplateTwo{}).Where("id = ?", p_id).Updates(map[string]interface{}{"status": 0})
445 440
 }
446
-
447 441
 func SaveOrder(order *models.HisOrder) {
448 442
 	writeDb.Save(&order)
449 443
 }
450
-
451 444
 func GetAllPrivateHis(org_id int64) (his []*models.HisPatient) {
452 445
 	readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND balance_accounts_type = 2 AND status = 1", org_id).Find(&his)
453 446
 	return
454 447
 }
455
-
456 448
 func SaveHis(his *models.HisPatient) {
457 449
 	writeDb.Save(his)
458 450
 	return
459 451
 }
460
-
461 452
 func GetAllProjectPrescription() (pre []*models.HisPrescription) {
462 453
 	readDb.Model(&models.HisPrescription{}).Where("user_org_id = 10215 AND status = 1 AND type = 2 AND order_status = 1 AND record_date >= 1659283200").Find(&pre)
463 454
 	return
464 455
 }
465
-
466 456
 func GetAllProject(id int64) (pre []*models.HisPrescriptionProject) {
467 457
 	readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = 10215 AND status = 1 AND project_id = 1735  AND prescription_id = ?", id).Find(&pre)
468 458
 	return
@@ -478,7 +468,6 @@ func GetAllProject(id int64) (pre []*models.HisPrescriptionProject) {
478 468
 //	}).Find(&order).Error
479 469
 //	return
480 470
 //}
481
-
482 471
 type HisOrderTen struct {
483 472
 	ID                    int64                 `gorm:"column:id" json:"id" form:"id"`
484 473
 	UserOrgId             int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -554,13 +543,46 @@ type HisOrderTen struct {
554 543
 	PType                 int64                 `gorm:"column:p_type" json:"p_type" form:"p_type"`
555 544
 	Decimal               float64               `gorm:"column:decimal" json:"decimal" form:"decimal"`
556 545
 	HisPrescriptionTen    []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
557
-	Patients              Patients              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
546
+	//VmHisOrderInfo9504    []*VmHisOrderInfo9504 `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"order_info"`
547
+	VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"order_info"`
548
+	OthDesc            string                `gorm:"oth_desc" json:"oth_desc" form:"oth_desc"`
549
+	PayWays            string                `gorm:"pay_ways" json:"pay_ways" form:"pay_ways"`
550
+
551
+	Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
558 552
 }
559 553
 
560 554
 func (HisOrderTen) TableName() string {
561 555
 	return "his_order"
562 556
 }
563 557
 
558
+type HisPrescriptionInfoOne struct {
559
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
560
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
561
+	RecordDate         int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
562
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
563
+	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
564
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
565
+	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
566
+	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
567
+	Creator            int64  `gorm:"column:creator" json:"creator" form:"creator"`
568
+	Modifier           int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
569
+	Diagnosis          string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
570
+	RegisterType       int64  `gorm:"column:register_type" json:"register_type" form:"register_type"`
571
+	Doctor             string `gorm:"column:doctor" json:"doctor" form:"doctor"`
572
+	Departments        int64  `gorm:"column:departments" json:"departments" form:"departments"`
573
+	SickHistory        string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
574
+	PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
575
+	PrescriptionStatus int64  `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
576
+	BatchNumber        string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
577
+	DoctorId           int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
578
+	SickType           int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
579
+	PType              int64  `gorm:"column:p_type" json:"p_type" form:"p_type"`
580
+}
581
+
582
+func (HisPrescriptionInfoOne) TableName() string {
583
+	return "his_prescription_info"
584
+}
585
+
564 586
 type HisPrescriptionTen struct {
565 587
 	ID                        int64                        `gorm:"column:id" json:"id" form:"id"`
566 588
 	UserOrgId                 int64                        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -582,6 +604,7 @@ type HisPrescriptionTen struct {
582 604
 	Patients                  Patients                     `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
583 605
 	HisDoctorAdviceInfoTen    []*HisDoctorAdviceInfoTen    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
584 606
 	HisPrescriptionProjectTen []*HisPrescriptionProjectTen `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
607
+	HisPrescriptionInfoOne    HisPrescriptionInfoOne       `gorm:"ForeignKey:PrescriptionNumber;AssociationForeignKey:PrescriptionNumber" json:"p_info"`
585 608
 	Total                     string                       `gorm:"-" json:"total" form:"total"`
586 609
 	PType                     int64                        `gorm:"column:p_type" json:"p_type" form:"p_type"`
587 610
 	MedType                   string                       `gorm:"column:med_type" json:"med_type" form:"med_type"`
@@ -591,43 +614,83 @@ type HisPrescriptionTen struct {
591 614
 func (HisPrescriptionTen) TableName() string {
592 615
 	return "his_prescription"
593 616
 }
594
-
595 617
 func GetHisOrderDetailThree() (order []*HisOrderTen, err error) {
596
-	err = readDb.Model(&HisOrderTen{}).Preload("Patients", "status = 1").Preload("HisPrescriptionTen", func(db *gorm.DB) *gorm.DB {
618
+	err = readDb.Model(&HisOrderTen{}).Preload("VmHisOrderInfo9504", "status = 1").Preload("Patients", "status = 1").Preload("HisPrescriptionTen", func(db *gorm.DB) *gorm.DB {
597 619
 		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
598 620
 			return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
599 621
 		}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
600 622
 			return db.Where("status = 1").Preload("Drug", "status = 1")
601 623
 		})
602
-	}).Where("settle_accounts_date >= 1659283200 AND settle_accounts_date <= 1661788800 AND status = 1 AND order_status =2 and p_type = 1 AND user_org_id = 10215").Find(&order).Order("patient_id").Error
624
+	}).Where("settle_accounts_date >= 1675180800 AND settle_accounts_date <= 1677513600 AND status = 1 AND order_status =2 and p_type = 1 AND user_org_id = 10215").Find(&order).Order("patient_id").Error
603 625
 	return
604 626
 }
605 627
 
606
-type HisDoctorAdviceInfoTen struct {
607
-	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
608
-	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
609
-	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
610
-	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
611
-	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
612
-	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
613
-	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
614
-	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
615
-	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
616
-	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
617
-	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
618
-	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
619
-	Status                int64   `gorm:"column:status" json:"status" form:"status"`
620
-	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
621
-	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
622
-	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
623
-	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
624
-	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
628
+type VmHisOrderInfo9504Two struct {
629
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
630
+	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
631
+	UploadDate       int64   `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
632
+	AdviceId         int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
633
+	DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
634
+	Cnt              float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
635
+	Pric             float64 `gorm:"column:pric" json:"pric" form:"pric"`
636
+	PatientId        int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
637
+	PricUplmtAmt     float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
638
+	SelfpayProp      float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
639
+	FulamtOwnpayAmt  float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
640
+	OverlmtAmt       float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
641
+	PreselfpayAmt    float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
642
+	BasMednFlag      string  `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
643
+	MedChrgitmType   string  `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
644
+	HiNegoDrugFlag   string  `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
645
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
646
+	Memo             string  `gorm:"column:memo" json:"memo" form:"memo"`
647
+	FeedetlSn        string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
648
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
649
+	InscpScpAmt      float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
650
+	DrtReimFlag      string  `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
651
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
652
+	ListSpItemFlag   string  `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
653
+	ChldMedcFlag     string  `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
654
+	LmtUsedFlag      string  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
655
+	ChrgitmLv        string  `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
656
+	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
657
+	HisPatientId     int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
658
+	OrderId          int64   `gorm:"column:order_id" json:"order_id" form:"order_id"`
659
+	ProjectId        int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
660
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
661
+	ItemId           int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
662
+	SettleType       int64   `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
663
+}
625 664
 
626
-	Price                float64 `gorm:"column:price" json:"price" form:"price"`
627
-	DrugId               int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
628
-	Drug                 Drug    `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
629
-	IsMedicine           int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
630
-	ExecutionFrequencyId int64   `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
665
+func (VmHisOrderInfo9504Two) TableName() string {
666
+	return "his_order_info"
667
+}
668
+
669
+type HisDoctorAdviceInfoTen struct {
670
+	ID                    int64                 `gorm:"column:id" json:"id" form:"id"`
671
+	UserOrgId             int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
672
+	PatientId             int64                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
673
+	AdviceDate            int64                 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
674
+	AdviceName            string                `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
675
+	AdviceDesc            string                `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
676
+	SingleDose            float64               `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
677
+	SingleDoseUnit        string                `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
678
+	PrescribingNumber     float64               `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
679
+	PrescribingNumberUnit string                `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
680
+	DeliveryWay           string                `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
681
+	ExecutionFrequency    string                `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
682
+	Status                int64                 `gorm:"column:status" json:"status" form:"status"`
683
+	CreatedTime           int64                 `gorm:"column:created_time" json:"created_time" form:"created_time"`
684
+	RecordDate            int64                 `gorm:"column:record_date" json:"record_date" form:"record_date"`
685
+	DrugSpec              float64               `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
686
+	DrugSpecUnit          string                `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
687
+	PrescriptionId        int64                 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
688
+	VmHisOrderInfo9504Two VmHisOrderInfo9504Two `gorm:"ForeignKey:AdviceId;AssociationForeignKey:ID" json:"order_info"`
689
+	Price                 float64               `gorm:"column:price" json:"price" form:"price"`
690
+	DrugId                int64                 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
691
+	Drug                  Drug                  `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
692
+	IsMedicine            int64                 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
693
+	ExecutionFrequencyId  int64                 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
631 694
 }
632 695
 
633 696
 func (HisDoctorAdviceInfoTen) TableName() string {
@@ -635,38 +698,39 @@ func (HisDoctorAdviceInfoTen) TableName() string {
635 698
 }
636 699
 
637 700
 type HisPrescriptionProjectTen struct {
638
-	ID                 int64        `gorm:"column:id" json:"id" form:"id"`
639
-	ProjectId          int64        `gorm:"column:project_id" json:"project_id" form:"project_id"`
640
-	Price              float64      `gorm:"column:price" json:"price" form:"price"`
641
-	UserOrgId          int64        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
642
-	Status             int64        `gorm:"column:status" json:"status" form:"status"`
643
-	Ctime              int64        `gorm:"column:ctime" json:"ctime" form:"ctime"`
644
-	Mtime              int64        `gorm:"column:mtime" json:"mtime" form:"mtime"`
645
-	PatientId          int64        `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
646
-	HisPatientId       int64        `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
647
-	RecordDate         int64        `gorm:"column:record_date" json:"record_date" form:"record_date"`
648
-	PrescriptionId     int64        `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
649
-	Count              string       `gorm:"column:count" json:"count" form:"count"`
650
-	FeedetlSn          string       `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
651
-	MedListCodg        string       `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
652
-	SingleDose         string       `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
653
-	DeliveryWay        string       `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
654
-	ExecutionFrequency string       `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
655
-	Day                string       `gorm:"column:day" json:"day" form:"day"`
656
-	VMHisProject       VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
657
-	VMGoodInfo         VMGoodInfo   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
658
-	Remark             string       `gorm:"column:remark" json:"remark" form:"remark"`
659
-	Unit               string       `gorm:"column:unit" json:"unit" form:"unit"`
660
-	Type               int64        `gorm:"column:type" json:"type" form:"type"`
661
-	Doctor             int64        `gorm:"column:doctor" json:"doctor" form:"doctor"`
662
-	ExecutionTime      int64        `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
663
-	ExecutionStaff     int64        `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
664
-	ExecutionState     int64        `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
665
-	CheckTime          int64        `gorm:"column:check_time" json:"check_time" form:"check_time"`
666
-	CheckState         int64        `gorm:"column:check_state" json:"check_state" form:"check_state"`
667
-	Checker            int64        `gorm:"column:checker" json:"checker" form:"checker"`
668
-	StartTime          int64        `gorm:"column:start_time" json:"start_time" form:"start_time"`
669
-	TeamId             int64        `gorm:"column:team_id" json:"team_id" form:"team_id"`
701
+	ID                    int64                 `gorm:"column:id" json:"id" form:"id"`
702
+	ProjectId             int64                 `gorm:"column:project_id" json:"project_id" form:"project_id"`
703
+	Price                 float64               `gorm:"column:price" json:"price" form:"price"`
704
+	UserOrgId             int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
705
+	Status                int64                 `gorm:"column:status" json:"status" form:"status"`
706
+	Ctime                 int64                 `gorm:"column:ctime" json:"ctime" form:"ctime"`
707
+	Mtime                 int64                 `gorm:"column:mtime" json:"mtime" form:"mtime"`
708
+	PatientId             int64                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
709
+	HisPatientId          int64                 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
710
+	RecordDate            int64                 `gorm:"column:record_date" json:"record_date" form:"record_date"`
711
+	PrescriptionId        int64                 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
712
+	Count                 string                `gorm:"column:count" json:"count" form:"count"`
713
+	FeedetlSn             string                `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
714
+	MedListCodg           string                `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
715
+	SingleDose            string                `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
716
+	DeliveryWay           string                `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
717
+	ExecutionFrequency    string                `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
718
+	Day                   string                `gorm:"column:day" json:"day" form:"day"`
719
+	VMHisProject          VMHisProject          `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
720
+	VMGoodInfo            VMGoodInfo            `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
721
+	Remark                string                `gorm:"column:remark" json:"remark" form:"remark"`
722
+	Unit                  string                `gorm:"column:unit" json:"unit" form:"unit"`
723
+	Type                  int64                 `gorm:"column:type" json:"type" form:"type"`
724
+	Doctor                int64                 `gorm:"column:doctor" json:"doctor" form:"doctor"`
725
+	ExecutionTime         int64                 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
726
+	ExecutionStaff        int64                 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
727
+	ExecutionState        int64                 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
728
+	CheckTime             int64                 `gorm:"column:check_time" json:"check_time" form:"check_time"`
729
+	CheckState            int64                 `gorm:"column:check_state" json:"check_state" form:"check_state"`
730
+	Checker               int64                 `gorm:"column:checker" json:"checker" form:"checker"`
731
+	StartTime             int64                 `gorm:"column:start_time" json:"start_time" form:"start_time"`
732
+	TeamId                int64                 `gorm:"column:team_id" json:"team_id" form:"team_id"`
733
+	VmHisOrderInfo9504Two VmHisOrderInfo9504Two `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
670 734
 
671 735
 	FrequencyType        int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
672 736
 	DayCount             int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
@@ -677,14 +741,19 @@ type HisPrescriptionProjectTen struct {
677 741
 func (HisPrescriptionProjectTen) TableName() string {
678 742
 	return "his_prescription_project"
679 743
 }
680
-
681 744
 func GetHisPatient11111(orgid int64) (paitent []*models.HisHospitalCheckRecord, err error) {
682
-	err = XTReadDB().Model(&paitent).Where("user_org_id = ?  and status = 1 AND in_hosptial_time >= '2022-12-01 00:00:00' AND in_hosptial_time <= '2022-12-31 23:59:59'", orgid).Find(&paitent).Error
745
+	err = XTReadDB().Model(&paitent).Where("user_org_id = ?  and status = 1 AND in_hosptial_time >= '2023-02-01 00:00:00' AND in_hosptial_time <= '2023-02-28 23:59:59'", orgid).Find(&paitent).Error
746
+	return paitent, err
747
+}
748
+func GetHisPatient2222(orgid int64) (paitent []*models.HisPatient, err error) {
749
+	err = XTReadDB().Model(&models.HisPatient{}).Where("user_org_id = ?  and status = 1 AND record_date >= 1654012800 AND record_date <= 1659196800 ", orgid).Find(&paitent).Error
683 750
 	return paitent, err
684 751
 }
685
-
686 752
 func SaveHP(paitent *models.HisHospitalCheckRecord) {
687 753
 	writeDb.Save(&paitent)
754
+}
755
+func SaveHPtWO(paitent *models.HisPatient) {
756
+	writeDb.Save(&paitent)
688 757
 
689 758
 }
690 759
 
@@ -760,6 +829,8 @@ type HisOrder9504 struct {
760 829
 	DepartmentName        string    `gorm:"-" json:"department_name" form:"department_name"`
761 830
 	DoctorName            string    `gorm:"-" json:"doctor_name" form:"doctor_name"`
762 831
 	SettleStartTime       int64     `gorm:"settle_start_time" json:"settle_start_time" form:"settle_start_time"`
832
+	OthDesc               string    `gorm:"oth_desc" json:"oth_desc" form:"oth_desc"`
833
+	PayWays               string    `gorm:"pay_ways" json:"pay_ways" form:"pay_ways"`
763 834
 
764 835
 	Creator            int64                 `gorm:"column:creator" json:"creator" form:"creator"`
765 836
 	PType              int64                 `gorm:"column:p_type" json:"p_type" form:"p_type"`
@@ -855,7 +926,6 @@ type VmHisOrderInfo95042 struct {
855 926
 func (VmHisOrderInfo95042) TableName() string {
856 927
 	return "his_order_info"
857 928
 }
858
-
859 929
 func GetHisOrderDetail9504() (order []*HisOrder9504, err error) {
860 930
 	err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
861 931
 		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
@@ -866,7 +936,6 @@ func GetHisOrderDetail9504() (order []*HisOrder9504, err error) {
866 936
 	}).Where("settle_accounts_date >= 1640966400 AND settle_accounts_date <= 1661875200 AND status = 1 AND order_status =2  AND user_org_id = 9504").Find(&order).Order("setl_time").Error
867 937
 	return
868 938
 }
869
-
870 939
 func GetHisOrderDetail10188() (order []*HisOrder9504, err error) {
871 940
 	err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
872 941
 		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
@@ -890,7 +959,7 @@ func GetHisOrderDetail10138() (order []*HisOrderTen, err error) {
890 959
 		return db.Where("status = 1 AND order_status = 2").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
891 960
 			return db.Where("status = 1").Preload("VMHisProject")
892 961
 		})
893
-	}).Where("settle_accounts_date >= 1664553600 AND settle_accounts_date <= 1672416000 AND status = 1 AND order_status =2  AND user_org_id = 10278").Find(&order).Error
962
+	}).Where("settle_accounts_date >= 1672502400 AND settle_accounts_date <= 1676822400 AND status = 1 AND order_status =2  AND user_org_id = 10278").Find(&order).Error
894 963
 	return
895 964
 }
896 965
 
@@ -1035,9 +1104,181 @@ func SaveSch(sch models.Schedule) (err error) {
1035 1104
 }
1036 1105
 
1037 1106
 func SaveSchTwo(sch models.Schedule, sch_two models.Schedule) (err error) {
1038
-	//err = writeDb.Save(&sch).Error
1039
-	err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"status": 0}).Error
1040
-	err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch_two.ID).Updates(map[string]interface{}{"status": 0}).Error
1107
+	utx := writeDb.Begin()
1108
+	if err = utx.Model(&Schedule{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"status": 0}).Error; err != nil {
1109
+		utx.Rollback()
1110
+		return err
1111
+	}
1112
+	if err = utx.Model(&Schedule{}).Where("status=1 AND id = ?", sch_two.ID).Updates(map[string]interface{}{"status": 0}).Error; err != nil {
1113
+		utx.Rollback()
1114
+		return err
1115
+	}
1116
+	utx.Commit()
1117
+	return err
1118
+}
1119
+
1120
+func GetHisOrderInfoDetail() (order []*VmHisOrderInfo9504, err error) {
1121
+	err = readDb.Model(&VmHisOrderInfo9504{}).Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
1122
+		return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
1123
+	}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
1124
+		return db.Where("status = 1").Preload("Drug")
1125
+	}).Where("status = 1 AND order_number = '202302201702258124538'").Find(&order).Error
1126
+	return
1127
+}
1128
+
1129
+func GetHisPrescriptionInfoDetail() (order []*HisPrescriptionProjectTen, err error) {
1130
+	err = readDb.Model(&HisPrescriptionProjectTen{}).Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
1131
+		return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
1132
+	}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
1133
+		return db.Where("status = 1").Preload("Drug")
1134
+	}).Where("status = 1 AND order_number = '202302201702258124538'").Find(&order).Error
1135
+	return
1136
+}
1137
+
1138
+type HisOrder10138 struct {
1139
+	ID                 int64                 `gorm:"column:id" json:"id" form:"id"`
1140
+	UserOrgId          int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1141
+	Status             int64                 `gorm:"column:status" json:"status" form:"status"`
1142
+	Number             string                `gorm:"column:number" json:"number" form:"number"`
1143
+	PatientId          int64                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1144
+	OrderStatus        int64                 `gorm:"column:order_status" json:"order_status" form:"order_status"`
1145
+	MdtrtId            string                `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
1146
+	Ctime              int64                 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1147
+	SettleAccountsDate int64                 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
1148
+	VmHisOrderInfo9504 []*VmHisOrderInfo9504 `json:"infos" form:"infos"`
1149
+}
1150
+
1151
+func (HisOrder10138) TableName() string {
1152
+	return "his_order"
1153
+}
1154
+
1155
+type PatientVM10138 struct {
1156
+	ID            int64            `gorm:"column:id" json:"id" form:"id"`
1157
+	UserOrgId     int64            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1158
+	Name          string           `gorm:"column:name" json:"name" form:"name"`
1159
+	HisOrder10138 []*HisOrder10138 `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"order"`
1160
+}
1161
+
1162
+func (PatientVM10138) TableName() string {
1163
+	return "xt_patients"
1164
+}
1165
+
1166
+func GetHisAllPatientOrder(start_time int64, end_time int64) (order []*PatientVM10138, err error) {
1167
+	err = readDb.Model(&PatientVM10138{}).Preload("HisOrder10138", " ctime >= ? AND ctime <= ? AND status = 1 AND order_status = 2", start_time, end_time).Where("user_org_id = 10138 AND status = 1").Find(&order).Error
1168
+	return
1169
+}
1041 1170
 
1171
+func GetHisOrderInfoDetail10138(order_number string) (order []*VmHisOrderInfo9504, err error) {
1172
+	err = readDb.Model(&VmHisOrderInfo9504{}).Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
1173
+		return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
1174
+	}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
1175
+		return db.Where("status = 1").Preload("Drug")
1176
+	}).Where("status = 1 AND order_number = ?", order_number).Find(&order).Error
1177
+	return
1178
+}
1179
+
1180
+//func GetHisOrderDetailOne(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
1181
+//	err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
1182
+//		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
1183
+//			return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
1184
+//		}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
1185
+//			return db.Where("status = 1").Preload("Drug")
1186
+//		})
1187
+//	}).Where("settle_accounts_date >= ? AND settle_accounts_date <= ? AND status = 1 AND order_status =2  AND user_org_id = 9919", start_time, end_time).Find(&order).Order("setl_time").Error
1188
+//	return
1189
+//}
1190
+//
1191
+
1192
+type HisOrderTenOne struct {
1193
+	ID                    int64                 `gorm:"column:id" json:"id" form:"id"`
1194
+	UserOrgId             int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1195
+	HisPatientId          int64                 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1196
+	SettleAccountsDate    int64                 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
1197
+	Ctime                 int64                 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1198
+	Mtime                 int64                 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1199
+	Status                int64                 `gorm:"column:status" json:"status" form:"status"`
1200
+	Number                string                `gorm:"column:number" json:"number" form:"number"`
1201
+	PatientId             int64                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1202
+	Infcode               int64                 `gorm:"column:infcode" json:"infcode" form:"infcode"`
1203
+	WarnMsg               string                `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
1204
+	Cainfo                string                `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
1205
+	ErrMsg                string                `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
1206
+	RespondTime           string                `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
1207
+	InfRefmsgid           string                `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
1208
+	OrderStatus           int64                 `gorm:"column:order_status" json:"order_status" form:"order_status"`
1209
+	MdtrtId               string                `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
1210
+	SetlId                string                `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
1211
+	PsnNo                 string                `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
1212
+	PsnName               string                `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
1213
+	PsnCertType           string                `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
1214
+	Certno                string                `gorm:"column:certno" json:"certno" form:"certno"`
1215
+	Gend                  string                `gorm:"column:gend" json:"gend" form:"gend"`
1216
+	Naty                  string                `gorm:"column:naty" json:"naty" form:"naty"`
1217
+	Brdy                  time.Time             `gorm:"column:brdy" json:"brdy" form:"brdy"`
1218
+	Age                   float64               `gorm:"column:age" json:"age" form:"age"`
1219
+	Insutype              string                `gorm:"column:insutype" json:"insutype" form:"insutype"`
1220
+	PsnType               string                `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
1221
+	CvlservFlag           string                `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
1222
+	SetlTime              string                `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
1223
+	MdtrtCertType         string                `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
1224
+	MedType               string                `gorm:"column:med_type" json:"med_type" form:"med_type"`
1225
+	MedfeeSumamt          float64               `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
1226
+	FulamtOwnpayAmt       float64               `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1227
+	OverlmtSelfPay        float64               `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
1228
+	PreselfpayAmt         float64               `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
1229
+	InscpScpAmt           float64               `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
1230
+	ActPayDedc            float64               `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
1231
+	HifpPay               float64               `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
1232
+	CvlservPay            float64               `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
1233
+	PoolPropSelfpay       float64               `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
1234
+	HifesPay              float64               `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
1235
+	HifmiPay              float64               `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
1236
+	HifobPay              float64               `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
1237
+	MafPay                float64               `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
1238
+	OthPay                float64               `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
1239
+	FundPaySumamt         float64               `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
1240
+	PsnPartAmt            float64               `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
1241
+	AcctPay               float64               `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
1242
+	PsnCashPay            float64               `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
1243
+	HospPartAmt           float64               `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
1244
+	Balc                  float64               `gorm:"column:balc" json:"balc" form:"balc"`
1245
+	AcctMulaidPay         float64               `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
1246
+	MedinsSetlId          string                `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
1247
+	ClrOptins             string                `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
1248
+	ClrWay                string                `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
1249
+	ClrType               string                `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
1250
+	SetlDetail            string                `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
1251
+	IsMedicineInsurance   int64                 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
1252
+	PayWay                int64                 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
1253
+	PayPrice              float64               `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
1254
+	PayCardNo             string                `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
1255
+	DiscountPrice         float64               `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
1256
+	PreferentialPrice     float64               `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
1257
+	RealityPrice          float64               `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
1258
+	FoundPrice            float64               `gorm:"column:found_price" json:"found_price" form:"found_price"`
1259
+	MedicalInsurancePrice float64               `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
1260
+	PrivatePrice          float64               `gorm:"column:private_price" json:"private_price" form:"private_price"`
1261
+	DepartmentName        string                `gorm:"-" json:"department_name" form:"department_name"`
1262
+	DoctorName            string                `gorm:"-" json:"doctor_name" form:"doctor_name"`
1263
+	Creator               int64                 `gorm:"column:creator" json:"creator" form:"creator"`
1264
+	PType                 int64                 `gorm:"column:p_type" json:"p_type" form:"p_type"`
1265
+	Decimal               float64               `gorm:"column:decimal" json:"decimal" form:"decimal"`
1266
+	HisPrescriptionTen    []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
1267
+	OthDesc               string                `gorm:"oth_desc" json:"oth_desc" form:"oth_desc"`
1268
+	PayWays               string                `gorm:"pay_ways" json:"pay_ways" form:"pay_ways"`
1269
+}
1270
+
1271
+func (HisOrderTenOne) TableName() string {
1272
+	return "his_order"
1273
+}
1274
+
1275
+func GetHisOrderDetailOne(start_time int64, end_time int64) (order []*HisOrderTen, err error) {
1276
+	err = readDb.Model(&HisOrderTen{}).Preload("HisPrescriptionTen", func(db *gorm.DB) *gorm.DB {
1277
+		return db.Where("status = 1").Preload("HisPrescriptionInfoOne", "status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
1278
+			return db.Where("status = 1").Preload("VmHisOrderInfo9504Two", "status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
1279
+		}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
1280
+			return db.Where("status = 1").Preload("VmHisOrderInfo9504Two", "status = 1").Preload("Drug", "status = 1")
1281
+		})
1282
+	}).Where("settle_accounts_date >= ? AND settle_accounts_date <= ? AND status = 1 AND order_status =2 AND user_org_id = 9919 AND setl_id <> ''", start_time, end_time).Find(&order).Error
1042 1283
 	return
1043 1284
 }

+ 7 - 0
service/drug_pharmacy_management_service.go Vedi 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 Vedi 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 Vedi 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

+ 23 - 3
service/his_service.go Vedi 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
 
@@ -982,6 +982,13 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_time
982 982
 
983 983
 	}
984 984
 
985
+	if sch_type > 0 {
986
+		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 <= ?", sch_type, start_time_timestamp, end_time_timestamp)
987
+	}
988
+	if zone_type > 0 {
989
+		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.partition_id = ?", zone_type)
990
+	}
991
+
985 992
 	if sort_type == 1 {
986 993
 		if start_time_timestamp != 0 {
987 994
 			db = db.Where("his_order.settle_accounts_date>=?", start_time_timestamp)
@@ -990,7 +997,6 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_time
990 997
 			db = db.Where("his_order.settle_accounts_date<=?", end_time_timestamp)
991 998
 		}
992 999
 	} else {
993
-
994 1000
 		if len(start_time) != 0 {
995 1001
 			db = db.Where("his_order.setl_time>=?", start_time+" 00:00:00")
996 1002
 		}
@@ -1534,7 +1540,10 @@ func GetMobileCallHisPrescriptions(start_time int64, end_time int64, org_id int6
1534 1540
 
1535 1541
 	return
1536 1542
 }
1537
-
1543
+func GetHisPatientByNumber(number string) (his models.HisPatient, err error) {
1544
+	err = readDb.Model(&models.HisPatient{}).Where("number = ? AND status = 1", number).First(&his).Error
1545
+	return
1546
+}
1538 1547
 func GetHisOrderByID(order_id int64) (order models.HisOrder, err error) {
1539 1548
 	err = readDb.Model(&models.HisOrder{}).Where("id = ? AND status = 1", order_id).First(&order).Error
1540 1549
 	return
@@ -1607,6 +1616,12 @@ func GetPatientByIDTwo(orgID int64, patientID int64) (Patients, error) {
1607 1616
 	return patient, err
1608 1617
 }
1609 1618
 
1619
+func GetPatientByIDTenTwo(orgID int64, patientID int64) (models.PatientTwos, error) {
1620
+	var patient models.PatientTwos
1621
+	err := readDb.Model(&models.PatientTwos{}).Where("id = ? and user_org_id=? and status=1", patientID, orgID).First(&patient).Error
1622
+	return patient, err
1623
+}
1624
+
1610 1625
 func GetHisPrescriptionByPatientID(patientID int64, orgID int64) (info models.HisPrescriptionInfo, err error) {
1611 1626
 	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 1627
 	return
@@ -2726,3 +2741,8 @@ func UpdatePatientDialysisOrder(patient_id int64, url string) error {
2726 2741
 	err := XTWriteDB().Model(&models.XtPatients{}).Where("id =? and status=1", patient_id).Updates(map[string]interface{}{"url": url}).Error
2727 2742
 	return err
2728 2743
 }
2744
+
2745
+func GetHisOrderByIDTenOne(order_id string) (order models.HisOrder, err error) {
2746
+	err = readDb.Model(&models.HisOrder{}).Where("id = ? AND status = 1", order_id).First(&order).Error
2747
+	return
2748
+}

+ 17 - 17
service/patient_schedule_template_service.go Vedi 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 Vedi 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
+}