test_user 1 year ago
parent
commit
4b31c0408f

+ 494 - 76
controllers/his_api_controller.go View File

@@ -98,6 +98,318 @@ func HisManagerApiRegistRouters() {
98 98
 
99 99
 	beego.Router("/api/test/get", &HisApiController{}, "get:GetTestOrder")
100 100
 
101
+	beego.Router("/api/batch/settleaccount", &HisApiController{}, "get:GetBatchSettleAccounts")
102
+
103
+}
104
+
105
+func (c *HisApiController) GetBatchSettleAccounts() {
106
+	order_ids := c.GetString("order_ids")
107
+	admin_user_id, _ := c.GetInt64("admin_user_id")
108
+	adminUser := c.GetAdminUserInfo()
109
+	orders := strings.Split(order_ids, ",")
110
+	var newOrders []models.Orders
111
+	for _, item := range orders {
112
+		order, _ := service.GetHisOrderByIDTenOne(item)
113
+		his, _ := service.GetHisPatientByNumber(order.MdtrtId)
114
+		orderInfos, _ := service.GetHisOrderInfoByNumberOne(order.Number)
115
+		orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
116
+		orderInfos = append(orderInfos, orderInfos_two...)
117
+		his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
118
+		//diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
119
+		var diagnosis_ids []string
120
+		if his.ID > 0 {
121
+			diagnosis_ids = strings.Split(his.Diagnosis, ",")
122
+
123
+		} else {
124
+			diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
125
+
126
+		}
127
+		patient, _ := service.GetPatientByIDTenTwo(adminUser.CurrentOrgId, order.PatientId)
128
+		var dia_config []*models.HisXtDiagnoseConfig
129
+		var name string
130
+		for _, item := range diagnosis_ids {
131
+			id, _ := strconv.ParseInt(item, 10, 64)
132
+			diagnosisConfig, _ := service.FindDiagnoseById(id)
133
+			dia_config = append(dia_config, diagnosisConfig)
134
+			if len(name) == 0 {
135
+				name = diagnosisConfig.ClassName
136
+
137
+			} else {
138
+				name = name + "," + diagnosisConfig.ClassName
139
+			}
140
+		}
141
+
142
+		var bedCostTotal float64 = 0         //床位总费
143
+		var bedCostSelfTotal float64 = 0     //床位自费
144
+		var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
145
+		var bedSelfTotal float64 = 0         //床位部分项目自费
146
+		var bedInscpTotal float64 = 0        //床位部分项目自费
147
+
148
+		var operationCostTotal float64 = 0         //手术费
149
+		var operationCostSelfTotal float64 = 0     //手术费
150
+		var operationCostPartSelfTotal float64 = 0 //手术费
151
+		var operationSelfTotal float64 = 0         //床位部分项目自费
152
+		var operationInscpTotal float64 = 0        //床位部分项目自费
153
+
154
+		var otherCostTotal float64 = 0         //其他费用
155
+		var otherCostSelfTotal float64 = 0     //其他费用
156
+		var otherCostPartSelfTotal float64 = 0 //其他费用
157
+		var otherSelfTotal float64 = 0         //床位部分项目自费
158
+		var otherInscpTotal float64 = 0        //床位部分项目自费
159
+
160
+		var materialCostTotal float64 = 0         //材料费
161
+		var materialCostSelfTotal float64 = 0     //材料费
162
+		var materialCostPartSelfTotal float64 = 0 //材料费
163
+		var materialSelfTotal float64 = 0         //床位部分项目自费
164
+		var materialInscpTotal float64 = 0        //床位部分项目自费
165
+
166
+		var westernMedicineCostTotal float64 = 0         //西药费
167
+		var westernMedicineCostSelfTotal float64 = 0     //西药费
168
+		var westernMedicineCostPartSelfTotal float64 = 0 //西药费
169
+		var westernMedicineSelfTotal float64 = 0         //床位部分项目自费
170
+		var westernMedicineInscpTotal float64 = 0        //床位部分项目自费
171
+
172
+		var chineseTraditionalMedicineCostTotal float64 = 0         //中成药
173
+		var chineseTraditionalMedicineCostSelfTotal float64 = 0     //中成药
174
+		var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
175
+		var chineseTraditionalSelfTotal float64 = 0                 //床位部分项目自费
176
+		var chineseTraditionalInscpTotal float64 = 0                //床位部分项目自费
177
+
178
+		var checkCostTotal float64 = 0         //检查费
179
+		var checkCostSelfTotal float64 = 0     //检查费
180
+		var checkCostPartSelfTotal float64 = 0 //检查费
181
+		var checkSelfTotal float64 = 0         //床位部分项目自费
182
+		var checkInscpTotal float64 = 0        //床位部分项目自费
183
+
184
+		var laboratoryCostTotal float64 = 0         //化验费
185
+		var laboratoryCostSelfTotal float64 = 0     //化验费
186
+		var laboratoryCostPartSelfTotal float64 = 0 //化验费
187
+		var laboratorySelfTotal float64 = 0         //床位部分项目自费
188
+		var laboratoryInscpTotal float64 = 0        //床位部分项目自费
189
+
190
+		var treatCostTotal float64 = 0         //治疗费用
191
+		var treatCostSelfTotal float64 = 0     //治疗费用
192
+		var treatCostPartSelfTotal float64 = 0 //治疗费用
193
+		var treatSelfTotal float64 = 0         //床位部分项目自费
194
+		var treatInscpTotal float64 = 0        //床位部分项目自费
195
+
196
+		decimal.DivisionPrecision = 2
197
+
198
+		for _, item := range orderInfos {
199
+			if item.MedChrgitmType == "01" { //床位费
200
+				bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
201
+				bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
202
+				bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
203
+				bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
204
+				bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
205
+
206
+			}
207
+
208
+			if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
209
+				if item.MedChrgitmType == "03" { //检查费
210
+					laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
211
+					laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
212
+					laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
213
+					laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
214
+					laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
215
+
216
+				}
217
+			} else {
218
+
219
+				if item.MedChrgitmType == "03" { //检查费
220
+					checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
221
+					checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
222
+					checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
223
+					checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
224
+					checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
225
+
226
+				}
227
+
228
+			}
229
+
230
+			if item.MedChrgitmType == "04" { //化验费
231
+				laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
232
+				laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
233
+				laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
234
+				laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
235
+				laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
236
+
237
+			}
238
+
239
+			if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
240
+
241
+				treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
242
+				treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
243
+				treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
244
+				treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
245
+				treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
246
+
247
+			}
248
+
249
+			if item.MedChrgitmType == "06" { //手术费
250
+				operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
251
+				operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
252
+				operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
253
+				operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
254
+				operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
255
+
256
+			}
257
+
258
+			if item.MedChrgitmType == "08" { //材料费
259
+				materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
260
+				materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
261
+				materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
262
+				materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
263
+				materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
264
+
265
+			}
266
+
267
+			if item.MedChrgitmType == "09" { //西药费
268
+				westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
269
+				westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
270
+				westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
271
+				westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
272
+				westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
273
+
274
+			}
275
+
276
+			if item.MedChrgitmType == "11" { //中成费
277
+				chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
278
+				chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
279
+				chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
280
+				chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
281
+				chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
282
+
283
+			}
284
+
285
+			if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
286
+				otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
287
+				otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
288
+				otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
289
+				otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
290
+				otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
291
+
292
+			}
293
+		}
294
+
295
+		miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
296
+
297
+		printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
298
+		charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
299
+
300
+		doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
301
+
302
+		roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
303
+
304
+		var doctor_name string
305
+		if roles.ID == 0 {
306
+			doctor_name = "管理员"
307
+		} else {
308
+			doctor_name = roles.UserName
309
+		}
310
+
311
+		yiliao_leibie := ""
312
+
313
+		switch order.MedType {
314
+		case "11":
315
+			yiliao_leibie = "普通门诊"
316
+			break
317
+		case "12":
318
+			yiliao_leibie = "门诊挂号"
319
+			break
320
+		case "13":
321
+			yiliao_leibie = "急诊"
322
+			break
323
+		case "14":
324
+			yiliao_leibie = "门诊特殊病"
325
+			break
326
+		case "15":
327
+			yiliao_leibie = "门诊统筹"
328
+			break
329
+		case "16":
330
+			yiliao_leibie = "门诊慢性病"
331
+			break
332
+		case "21":
333
+			yiliao_leibie = "普通住院"
334
+			break
335
+		}
336
+		var newOrder models.Orders
337
+
338
+		newOrder.Diagnosis = name
339
+		newOrder.OrderInfos = orderInfos
340
+		newOrder.Number = order.MdtrtId
341
+		newOrder.Date = order.SettleAccountsDate
342
+		newOrder.ChargeAdmin = charge_admin
343
+		newOrder.PrintorAdmin = printor_admin
344
+		newOrder.Order = order
345
+		newOrder.BedCostTotal = bedCostTotal
346
+		newOrder.BedCostSelfTotal = bedCostSelfTotal
347
+		newOrder.BedCostPartSelfTotal = bedCostPartSelfTotal
348
+		newOrder.BedSelfTotal = bedSelfTotal
349
+		newOrder.BedInscpTotal = bedInscpTotal
350
+		newOrder.OperationCostTotal = operationCostTotal
351
+		newOrder.OperationCostSelfTotal = operationCostSelfTotal
352
+		newOrder.OperationCostPartSelfTotal = operationCostPartSelfTotal
353
+		newOrder.OperationSelfTotal = operationSelfTotal
354
+		newOrder.OperationInscpTotal = operationInscpTotal
355
+		newOrder.OtherCostTotal = otherCostTotal
356
+		newOrder.OtherCostSelfTotal = otherCostSelfTotal
357
+		newOrder.OtherCostPartSelfTotal = otherCostPartSelfTotal
358
+		newOrder.OtherSelfTotal = otherSelfTotal
359
+		newOrder.OtherInscpTotal = otherInscpTotal
360
+
361
+		newOrder.MaterialCostTotal = materialCostTotal
362
+		newOrder.MaterialCostSelfTotal = materialCostSelfTotal
363
+		newOrder.MaterialCostPartSelfTotal = materialCostPartSelfTotal
364
+		newOrder.MaterialSelfTotal = materialSelfTotal
365
+		newOrder.MaterialInscpTotal = materialInscpTotal
366
+
367
+		newOrder.WesternMedicineCostTotal = westernMedicineCostTotal
368
+		newOrder.WesternMedicineCostSelfTotal = westernMedicineCostSelfTotal
369
+		newOrder.WesternMedicineCostPartSelfTotal = westernMedicineCostPartSelfTotal
370
+		newOrder.WesternMedicineSelfTotal = westernMedicineSelfTotal
371
+		newOrder.WesternMedicineInscpTotal = westernMedicineInscpTotal
372
+
373
+		newOrder.ChineseTraditionalMedicineCostTotal = chineseTraditionalMedicineCostTotal
374
+		newOrder.ChineseTraditionalMedicineCostSelfTotal = chineseTraditionalMedicineCostSelfTotal
375
+		newOrder.ChineseTraditionalMedicineCostPartSelfTotal = chineseTraditionalMedicineCostPartSelfTotal
376
+		newOrder.ChineseTraditionalSelfTotal = chineseTraditionalSelfTotal
377
+		newOrder.ChineseTraditionalInscpTotal = chineseTraditionalInscpTotal
378
+
379
+		newOrder.CheckCostTotal = checkCostTotal
380
+		newOrder.CheckCostSelfTotal = checkCostSelfTotal
381
+		newOrder.CheckCostPartSelfTotal = checkCostPartSelfTotal
382
+		newOrder.CheckSelfTotal = checkSelfTotal
383
+		newOrder.CheckInscpTotal = checkInscpTotal
384
+
385
+		newOrder.LaboratoryCostTotal = laboratoryCostTotal
386
+		newOrder.LaboratoryCostSelfTotal = laboratoryCostSelfTotal
387
+		newOrder.LaboratoryCostPartSelfTotal = laboratoryCostPartSelfTotal
388
+		newOrder.LaboratorySelfTotal = laboratorySelfTotal
389
+		newOrder.LaboratoryInscpTotal = laboratoryInscpTotal
390
+
391
+		newOrder.TreatCostTotal = treatCostTotal
392
+		newOrder.TreatCostSelfTotal = treatCostSelfTotal
393
+		newOrder.TreatCostPartSelfTotal = treatCostPartSelfTotal
394
+		newOrder.TreatSelfTotal = treatSelfTotal
395
+		newOrder.TreatInscpTotal = treatInscpTotal
396
+
397
+		newOrder.DoctorInfo = doctor_info
398
+		newOrder.DoctorName = doctor_name
399
+		newOrder.HealthCardNo = order.PsnNo
400
+		newOrder.YiliaoLeibie = yiliao_leibie
401
+		newOrder.Patient = patient
402
+		newOrder.OrgName = miConfig.OrgName
403
+		newOrder.OrgCode = miConfig.Code
404
+		newOrder.OrderNumber = order.Number
405
+		newOrder.HisPatient = his
406
+		newOrder.DiaConfig = dia_config
407
+
408
+		newOrders = append(newOrders, newOrder)
409
+	}
410
+	c.ServeSuccessJSON(map[string]interface{}{
411
+		"orders": newOrders,
412
+	})
101 413
 }
102 414
 
103 415
 func (c *HisApiController) GetTestOrder() {
@@ -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)
@@ -9177,96 +9493,198 @@ func (c *HisApiController) CreateHisPrescriptionTemplate() {
9177 9493
 		return
9178 9494
 	}
9179 9495
 
9180
-	err = service.CreateHisPrescriptionTemplate(template)
9181
-	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
9182
-		prescriptions, _ := dataBody["prescriptions"].([]interface{})
9183
-		if len(prescriptions) > 0 {
9184
-			for _, item := range prescriptions {
9185
-				items := item.(map[string]interface{})
9186
-				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
9187
-					utils.ErrorLog("type")
9188
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9189
-					return
9190
-				}
9191
-				types := int64(items["type"].(float64))
9496
+	template_one, _ := service.GetHisPrescriptionTemplateByModeId(mode_id, patient_id, c.GetAdminUserInfo().CurrentOrgId)
9192 9497
 
9193
-				if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
9194
-					utils.ErrorLog("med_type")
9195
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9196
-					return
9197
-				}
9198
-				med_type := strconv.Itoa(int(items["med_type"].(float64)))
9498
+	//如果已经存在记录则删除处方
9499
+	if template_one.ID > 0 {
9500
+		ps, _ := service.GetHisPrescriptionInfoTemplates(template_one.ID, template_one.UserOrgId)
9501
+		for _, item := range ps {
9502
+			service.DelelteHisPrescriptionInfoTemplate(item.ID, item.UserOrgId)
9503
+		}
9504
+		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
9505
+			prescriptions, _ := dataBody["prescriptions"].([]interface{})
9506
+			if len(prescriptions) > 0 {
9507
+				for _, item := range prescriptions {
9508
+					items := item.(map[string]interface{})
9509
+					if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
9510
+						utils.ErrorLog("type")
9511
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9512
+						return
9513
+					}
9514
+					types := int64(items["type"].(float64))
9199 9515
 
9200
-				ctime := time.Now().Unix()
9201
-				prescription := &models.HisPrescriptionInfoTemplate{
9202
-					PatientId:   patient_id,
9203
-					UserOrgId:   adminInfo.CurrentOrgId,
9204
-					Ctime:       ctime,
9205
-					Mtime:       ctime,
9206
-					Type:        types,
9207
-					Modifier:    adminInfo.AdminUser.Id,
9208
-					Creator:     adminInfo.AdminUser.Id,
9209
-					Status:      1,
9210
-					PTemplateId: template.ID,
9211
-					MedType:     med_type,
9212
-				}
9213
-				service.CreateHisPrescriptionInfoTemplate(prescription)
9516
+					if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
9517
+						utils.ErrorLog("med_type")
9518
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9519
+						return
9520
+					}
9521
+					med_type := strconv.Itoa(int(items["med_type"].(float64)))
9214 9522
 
9215
-				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
9216
-					advices := items["advices"].([]interface{})
9217
-					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
9218 9523
 					ctime := time.Now().Unix()
9219
-					mtime := ctime
9220
-					if len(advices) > 0 {
9221
-						for _, advice := range advices {
9222
-							var s models.HisPrescriptionAdviceTemplate
9223
-							s.PrescriptionId = prescription.ID
9224
-							s.AdviceType = 2
9225
-							s.StopState = 2
9226
-							s.ExecutionState = 2
9227
-							s.Status = 1
9228
-							s.UserOrgId = adminInfo.CurrentOrgId
9229
-							s.CreatedTime = ctime
9230
-							s.UpdatedTime = mtime
9231
-							s.PatientId = patient_id
9232
-							errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
9233
-							if errcode > 0 {
9234
-								c.ServeFailJSONWithSGJErrorCode(errcode)
9235
-								return
9236
-							}
9524
+					prescription := &models.HisPrescriptionInfoTemplate{
9525
+						PatientId:   patient_id,
9526
+						UserOrgId:   adminInfo.CurrentOrgId,
9527
+						Ctime:       ctime,
9528
+						Mtime:       ctime,
9529
+						Type:        types,
9530
+						Modifier:    adminInfo.AdminUser.Id,
9531
+						Creator:     adminInfo.AdminUser.Id,
9532
+						Status:      1,
9533
+						PTemplateId: template_one.ID,
9534
+						MedType:     med_type,
9535
+					}
9536
+					service.CreateHisPrescriptionInfoTemplate(prescription)
9537
+
9538
+					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
9539
+						advices := items["advices"].([]interface{})
9540
+						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
9541
+						ctime := time.Now().Unix()
9542
+						mtime := ctime
9543
+						if len(advices) > 0 {
9544
+							for _, advice := range advices {
9545
+								var s models.HisPrescriptionAdviceTemplate
9546
+								s.PrescriptionId = prescription.ID
9547
+								s.AdviceType = 2
9548
+								s.StopState = 2
9549
+								s.ExecutionState = 2
9550
+								s.Status = 1
9551
+								s.UserOrgId = adminInfo.CurrentOrgId
9552
+								s.CreatedTime = ctime
9553
+								s.UpdatedTime = mtime
9554
+								s.PatientId = patient_id
9555
+								errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
9556
+								if errcode > 0 {
9557
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9558
+									return
9559
+								}
9237 9560
 
9238
-							service.CreateHisPrescriptionAdviceTemplate(&s)
9561
+								service.CreateHisPrescriptionAdviceTemplate(&s)
9562
+
9563
+							}
9564
+						}
9565
+					}
9566
+					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
9567
+						projects := items["project"].([]interface{})
9568
+						if len(projects) > 0 {
9569
+							for _, project := range projects {
9570
+								var p models.HisPrescriptionProjectTemplate
9571
+								p.PrescriptionId = prescription.ID
9572
+								p.Ctime = time.Now().Unix()
9573
+								p.Mtime = time.Now().Unix()
9574
+								p.PatientId = patient_id
9575
+								p.UserOrgId = adminInfo.CurrentOrgId
9576
+								p.Status = 1
9577
+								errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
9578
+								if errcode > 0 {
9579
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9580
+									return
9581
+								}
9582
+								service.CreateHisPrescriptionProjectTemplate(&p)
9239 9583
 
9584
+							}
9240 9585
 						}
9241 9586
 					}
9587
+
9242 9588
 				}
9243
-				if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
9244
-					projects := items["project"].([]interface{})
9245
-					if len(projects) > 0 {
9246
-						for _, project := range projects {
9247
-							var p models.HisPrescriptionProjectTemplate
9248
-							p.PrescriptionId = prescription.ID
9249
-							p.Ctime = time.Now().Unix()
9250
-							p.Mtime = time.Now().Unix()
9251
-							p.PatientId = patient_id
9252
-							p.UserOrgId = adminInfo.CurrentOrgId
9253
-							p.Status = 1
9254
-							errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
9255
-							if errcode > 0 {
9256
-								c.ServeFailJSONWithSGJErrorCode(errcode)
9257
-								return
9589
+
9590
+				c.ServeSuccessJSON(map[string]interface{}{
9591
+					"msg": "创建成功",
9592
+				})
9593
+			}
9594
+		}
9595
+
9596
+	} else {
9597
+		err = service.CreateHisPrescriptionTemplate(template)
9598
+		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
9599
+			prescriptions, _ := dataBody["prescriptions"].([]interface{})
9600
+			if len(prescriptions) > 0 {
9601
+				for _, item := range prescriptions {
9602
+					items := item.(map[string]interface{})
9603
+					if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
9604
+						utils.ErrorLog("type")
9605
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9606
+						return
9607
+					}
9608
+					types := int64(items["type"].(float64))
9609
+
9610
+					if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
9611
+						utils.ErrorLog("med_type")
9612
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9613
+						return
9614
+					}
9615
+					med_type := strconv.Itoa(int(items["med_type"].(float64)))
9616
+
9617
+					ctime := time.Now().Unix()
9618
+					prescription := &models.HisPrescriptionInfoTemplate{
9619
+						PatientId:   patient_id,
9620
+						UserOrgId:   adminInfo.CurrentOrgId,
9621
+						Ctime:       ctime,
9622
+						Mtime:       ctime,
9623
+						Type:        types,
9624
+						Modifier:    adminInfo.AdminUser.Id,
9625
+						Creator:     adminInfo.AdminUser.Id,
9626
+						Status:      1,
9627
+						PTemplateId: template.ID,
9628
+						MedType:     med_type,
9629
+					}
9630
+					service.CreateHisPrescriptionInfoTemplate(prescription)
9631
+
9632
+					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
9633
+						advices := items["advices"].([]interface{})
9634
+						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
9635
+						ctime := time.Now().Unix()
9636
+						mtime := ctime
9637
+						if len(advices) > 0 {
9638
+							for _, advice := range advices {
9639
+								var s models.HisPrescriptionAdviceTemplate
9640
+								s.PrescriptionId = prescription.ID
9641
+								s.AdviceType = 2
9642
+								s.StopState = 2
9643
+								s.ExecutionState = 2
9644
+								s.Status = 1
9645
+								s.UserOrgId = adminInfo.CurrentOrgId
9646
+								s.CreatedTime = ctime
9647
+								s.UpdatedTime = mtime
9648
+								s.PatientId = patient_id
9649
+								errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
9650
+								if errcode > 0 {
9651
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9652
+									return
9653
+								}
9654
+
9655
+								service.CreateHisPrescriptionAdviceTemplate(&s)
9656
+
9258 9657
 							}
9259
-							service.CreateHisPrescriptionProjectTemplate(&p)
9658
+						}
9659
+					}
9660
+					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
9661
+						projects := items["project"].([]interface{})
9662
+						if len(projects) > 0 {
9663
+							for _, project := range projects {
9664
+								var p models.HisPrescriptionProjectTemplate
9665
+								p.PrescriptionId = prescription.ID
9666
+								p.Ctime = time.Now().Unix()
9667
+								p.Mtime = time.Now().Unix()
9668
+								p.PatientId = patient_id
9669
+								p.UserOrgId = adminInfo.CurrentOrgId
9670
+								p.Status = 1
9671
+								errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
9672
+								if errcode > 0 {
9673
+									c.ServeFailJSONWithSGJErrorCode(errcode)
9674
+									return
9675
+								}
9676
+								service.CreateHisPrescriptionProjectTemplate(&p)
9260 9677
 
9678
+							}
9261 9679
 						}
9262 9680
 					}
9681
+
9263 9682
 				}
9264 9683
 
9684
+				c.ServeSuccessJSON(map[string]interface{}{
9685
+					"msg": "创建成功",
9686
+				})
9265 9687
 			}
9266
-
9267
-			c.ServeSuccessJSON(map[string]interface{}{
9268
-				"msg": "创建成功",
9269
-			})
9270 9688
 		}
9271 9689
 	}
9272 9690
 

+ 2 - 1
controllers/his_charge_api_controller.go View File

@@ -299,6 +299,7 @@ func (c *HisChargeApiController) GetHisInspectionList() {
299 299
 	is_print, _ := c.GetInt64("is_print")
300 300
 	page, _ := c.GetInt64("page")
301 301
 	limit, _ := c.GetInt64("limit")
302
+	//tube_color, _ := c.GetInt64("tube_color")
302 303
 
303 304
 	adminUser := c.GetAdminUserInfo()
304 305
 
@@ -309,7 +310,7 @@ 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
+	labels, total, err := service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, 0)
313 314
 	if err == nil {
314 315
 
315 316
 		c.ServeSuccessJSON(map[string]interface{}{

+ 82 - 2
models/his_models.go View File

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

+ 1 - 1
service/his_charge_service.go View File

@@ -240,7 +240,7 @@ func GetAllPatientChargeSettle(org_id int64, start_time int64, end_time int64, k
240 240
 	return
241 241
 }
242 242
 
243
-func GetLabelPrintList(page int64, limit int64, user_org_id int64, record_time int64, is_print int64, keywors string) (labels []*models.HisLabelPrintInfo, total int64, err error) {
243
+func GetLabelPrintList(page int64, limit int64, user_org_id int64, record_time int64, is_print int64, keywors string, tube_color int64) (labels []*models.HisLabelPrintInfo, total int64, err error) {
244 244
 	offset := (page - 1) * limit
245 245
 	db := readDb.Model(&models.HisLabelPrintInfo{})
246 246
 	if is_print > 0 {

+ 4 - 0
service/his_config_service.go View File

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

+ 23 - 3
service/his_service.go View File

@@ -968,7 +968,7 @@ func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
968 968
 	return
969 969
 }
970 970
 
971
-func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64, doctor_id int64, keywords string, p_type int64, sort_type int64, start_time string, end_time string, charge_type int64) (order []*models.HisOrder, err error, total int64) {
971
+func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64, doctor_id int64, keywords string, p_type int64, sort_type int64, start_time string, end_time string, charge_type int64, sch_type int64, zone_type int64) (order []*models.HisOrder, err error, total int64) {
972 972
 	offset := (page - 1) * limit
973 973
 	db := readDb.Model(&models.HisOrder{})
974 974
 
@@ -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
+}