csx il y a 2 ans
Parent
révision
73914377aa

+ 77 - 48
controllers/his_api_controller.go Voir le fichier

@@ -163,22 +163,39 @@ func (c *HisApiController) GetPrivateExpensesOrder() {
163 163
 	//recordDateTime := theTime.Unix()
164 164
 	adminUser := c.GetAdminUserInfo()
165 165
 	order, _ := service.GetHisOrderByID(order_id)
166
+
166 167
 	his, _ := service.GetHisPatientInfoThree(adminUser.CurrentOrgId, order.MdtrtId)
168
+	his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
167 169
 
168 170
 	orderInfos, _ := service.GetHisOrderDetailByNumber(order.Number, adminUser.CurrentOrgId)
169 171
 
170
-	diagnosis_ids := strings.Split(his.Diagnosis, ",")
171
-
172 172
 	//var config []*models.HisXtDiagnoseConfig
173
+
173 174
 	var name string
174
-	for _, item := range diagnosis_ids {
175
-		id, _ := strconv.ParseInt(item, 10, 64)
176
-		diagnosisConfig, _ := service.FindDiagnoseById(id)
177
-		if len(name) == 0 {
178
-			name = diagnosisConfig.ClassName
175
+	if order.PType == 1 {
176
+		diagnosis_ids := strings.Split(his_hospital.Diagnosis, ",")
177
+		for _, item := range diagnosis_ids {
178
+			id, _ := strconv.ParseInt(item, 10, 64)
179
+			diagnosisConfig, _ := service.FindDiagnoseById(id)
180
+			if len(name) == 0 {
181
+				name = diagnosisConfig.ClassName
179 182
 
180
-		} else {
181
-			name = name + "," + diagnosisConfig.ClassName
183
+			} else {
184
+				name = name + "," + diagnosisConfig.ClassName
185
+			}
186
+		}
187
+	} else {
188
+		diagnosis_ids := strings.Split(his.Diagnosis, ",")
189
+
190
+		for _, item := range diagnosis_ids {
191
+			id, _ := strconv.ParseInt(item, 10, 64)
192
+			diagnosisConfig, _ := service.FindDiagnoseById(id)
193
+			if len(name) == 0 {
194
+				name = diagnosisConfig.ClassName
195
+
196
+			} else {
197
+				name = name + "," + diagnosisConfig.ClassName
198
+			}
182 199
 		}
183 200
 	}
184 201
 
@@ -188,45 +205,44 @@ func (c *HisApiController) GetPrivateExpensesOrder() {
188 205
 		item.FulamtOwnpayAmt = item.DetItemFeeSumamt
189 206
 		if item.HisDoctorAdviceInfo.ID > 0 && item.HisPrescriptionProject.ID == 0 { //药品
190 207
 			item.MedChrgitmType = "09"
191
-
192 208
 		}
193 209
 		if item.HisPrescriptionProject.ID > 0 && item.HisDoctorAdviceInfo.ID == 0 {
194 210
 			if item.HisPrescriptionProject.Type == 2 {
195
-				switch item.HisPrescriptionProject.VMHisProject.CostClassify {
196
-
197
-				case 1:
198
-					item.MedChrgitmType = "14"
199
-					break
200
-				case 2:
201
-					item.MedChrgitmType = "05"
202
-
203
-					break
204
-				case 3:
205
-					item.MedChrgitmType = "04"
211
+				if c.GetAdminUserInfo().CurrentOrgId == 10215 {
212
+					switch item.HisPrescriptionProject.VMHisProject.CostClassify {
213
+					case 1:
214
+						item.MedChrgitmType = "14"
215
+						break
216
+					case 2:
217
+						item.MedChrgitmType = "05"
206 218
 
207
-					break
208
-				case 4:
209
-					item.MedChrgitmType = "14"
219
+						break
220
+					case 3:
221
+						item.MedChrgitmType = "04"
210 222
 
211
-					break
212
-				case 5:
213
-					item.MedChrgitmType = "08"
223
+						break
224
+					case 4:
225
+						item.MedChrgitmType = "14"
214 226
 
215
-					break
216
-				case 6:
217
-					item.MedChrgitmType = "14"
227
+						break
228
+					case 5:
229
+						item.MedChrgitmType = "08"
218 230
 
219
-					break
220
-				case 7:
221
-					item.MedChrgitmType = "14"
231
+						break
232
+					case 6:
233
+						item.MedChrgitmType = "14"
234
+						break
235
+					case 7:
236
+						item.MedChrgitmType = "14"
237
+						break
238
+					case 8:
239
+						item.MedChrgitmType = "03"
240
+						break
241
+					case 9:
242
+						item.MedChrgitmType = "14"
243
+						break
222 244
 
223
-					break
224
-				case 8:
225
-					item.MedChrgitmType = "03"
226
-					break
227
-				case 9:
228
-					item.MedChrgitmType = "14"
229
-					break
245
+					}
230 246
 
231 247
 				}
232 248
 
@@ -237,14 +253,6 @@ func (c *HisApiController) GetPrivateExpensesOrder() {
237 253
 	}
238 254
 	order.PsnCashPay = order.MedfeeSumamt
239 255
 
240
-	//var user_name string
241
-	//role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
242
-	//if role.ID == 0 {
243
-	//	user_name = "管理员"
244
-	//} else {
245
-	//	user_name = role.UserName
246
-	//}
247
-
248 256
 	org, _ := service.GetOrgById(adminUser.CurrentOrgId)
249 257
 	printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
250 258
 	charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
@@ -260,6 +268,8 @@ func (c *HisApiController) GetPrivateExpensesOrder() {
260 268
 		"charge_admin":  charge_admin,
261 269
 		"printor_admin": printor_admin,
262 270
 		"info":          order,
271
+		"his_hospital":  his_hospital,
272
+		"his":           his,
263 273
 	})
264 274
 
265 275
 }
@@ -6564,6 +6574,24 @@ func (c *HisApiController) GetHisMonthChargePatientInfo() {
6564 6574
 		monthPrescriptions, _ = service.GetChargeMonthHisPrescriptionFive(admin.CurrentOrgId, patient_id, order.Number, p_type)
6565 6575
 	}
6566 6576
 
6577
+	var settle_total float64
6578
+	for _, item := range monthPrescriptions {
6579
+		if len(item.HisPrescriptionProject) > 0 {
6580
+			for _, subItem := range item.HisPrescriptionProject {
6581
+				count, _ := strconv.ParseFloat(subItem.Count, 64)
6582
+				total, _ := decimal.NewFromFloat(count * subItem.Price).Round(2).Float64()
6583
+				settle_total = settle_total + total
6584
+			}
6585
+		}
6586
+		if len(item.HisDoctorAdviceInfo) > 0 {
6587
+			for _, subItem := range item.HisDoctorAdviceInfo {
6588
+				total, _ := decimal.NewFromFloat(subItem.PrescribingNumber * subItem.Price).Round(2).Float64()
6589
+				settle_total = settle_total + total
6590
+			}
6591
+		}
6592
+
6593
+	}
6594
+
6567 6595
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
6568 6596
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime, p_type, his_patient_id)
6569 6597
 
@@ -6583,6 +6611,7 @@ func (c *HisApiController) GetHisMonthChargePatientInfo() {
6583 6611
 		"order":               order,
6584 6612
 		"doctors":             doctors,
6585 6613
 		"department":          department,
6614
+		"settle_total":        settle_total,
6586 6615
 	})
6587 6616
 	return
6588 6617
 }

+ 77 - 7
controllers/his_hospital_api_controller.go Voir le fichier

@@ -6,6 +6,7 @@ import (
6 6
 	"XT_New/service"
7 7
 	"fmt"
8 8
 	"github.com/astaxie/beego"
9
+	"github.com/shopspring/decimal"
9 10
 	"math/rand"
10 11
 	"strconv"
11 12
 	"strings"
@@ -29,6 +30,7 @@ func HisHospitalManagerApiRegistRouters() {
29 30
 	beego.Router("/api/hospital/outhopitaluncheck/get", &HisHospitalApiController{}, "get:GetZHOutHospitalUnCheck")
30 31
 	beego.Router("/api/hospital/refund", &HisHospitalApiController{}, "get:ZHRefund")
31 32
 	beego.Router("/api/hospital/upload", &HisHospitalApiController{}, "get:GetUploadInfo")
33
+	beego.Router("/api/hospital/refunddetail", &HisHospitalApiController{}, "get:RefundDetail")
32 34
 
33 35
 	beego.Router("/api/hospitaldetail/list", &HisHospitalApiController{}, "get:GetHisHospitalDetailPatientList")
34 36
 	beego.Router("/api/hospitaldetail/info", &HisHospitalApiController{}, "get:GetHisHospitalDetailInfo")
@@ -36,6 +38,55 @@ func HisHospitalManagerApiRegistRouters() {
36 38
 	beego.Router("/api/monthhospitaldetail/get", &HisHospitalApiController{}, "get:GetHisHospitalMonthDetailInfo")
37 39
 
38 40
 }
41
+func (c *HisHospitalApiController) RefundDetail() {
42
+	patient_id, _ := c.GetInt64("patient_id")
43
+	his_patient_id, _ := c.GetInt64("his_patient_id")
44
+	record_time := c.GetString("record_time")
45
+	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
46
+	timeLayout := "2006-01-02"
47
+	loc, _ := time.LoadLocation("Local")
48
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
49
+	if err != nil {
50
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
51
+		return
52
+	}
53
+	recordDateTime := theTime.Unix()
54
+	adminUser := c.GetAdminUserInfo()
55
+	theTimeTwo, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 23:59:59", loc)
56
+	if err != nil {
57
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
58
+		return
59
+	}
60
+	recordDateTimeTwo := theTimeTwo.Unix()
61
+	if settle_accounts_type == 1 { //日结
62
+		err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId, recordDateTimeTwo)
63
+
64
+		if err != nil {
65
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
66
+			return
67
+		}
68
+		err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
69
+		if err1 != nil {
70
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
71
+			return
72
+		}
73
+		c.ServeSuccessJSON(map[string]interface{}{
74
+			"msg": "撤销明细成功",
75
+		})
76
+
77
+	} else {
78
+		record, _ := service.GetInHospitalRecord(his_patient_id)
79
+		err := service.UpdataHospitalOrderStatusTwo(record.Number, adminUser.CurrentOrgId)
80
+		if err == nil {
81
+			c.ServeSuccessJSON(map[string]interface{}{
82
+				"msg": "撤销明细成功",
83
+			})
84
+		} else {
85
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
86
+			return
87
+		}
88
+	}
89
+}
39 90
 
40 91
 func (c *HisHospitalApiController) GetUploadInfo() {
41 92
 	id, _ := c.GetInt64("id")
@@ -457,13 +508,30 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
457 508
 	} else if order_status == 2 {
458 509
 		settle_prescriptions, _ = service.GetSettleHisHospitalPrescriptionTwo(admin.CurrentOrgId, patient_id, his_patient_info.Number)
459 510
 	}
511
+
512
+	var settle_total float64
513
+	for _, item := range settle_prescriptions {
514
+		if len(item.HisPrescriptionProject) > 0 {
515
+			for _, subItem := range item.HisPrescriptionProject {
516
+				count, _ := strconv.ParseFloat(subItem.Count, 64)
517
+				total, _ := decimal.NewFromFloat(count * subItem.Price).Round(2).Float64()
518
+				settle_total = settle_total + total
519
+			}
520
+		}
521
+		if len(item.HisDoctorAdviceInfo) > 0 {
522
+			for _, subItem := range item.HisDoctorAdviceInfo {
523
+				total, _ := decimal.NewFromFloat(subItem.PrescribingNumber * subItem.Price).Round(2).Float64()
524
+				settle_total = settle_total + total
525
+			}
526
+		}
527
+
528
+	}
460 529
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
461 530
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfoTwo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
462 531
 	order, _ := service.GetNewHisOrder(admin.CurrentOrgId, his_patient_info.Number, patient_id)
463 532
 	doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
464 533
 	//获取所有科室信息
465 534
 	department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
466
-
467 535
 	c.ServeSuccessJSON(map[string]interface{}{
468 536
 		"his_info":             his_patient_info,
469 537
 		"xt_info":              xt_patient_info,
@@ -475,6 +543,7 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
475 543
 		"doctors":              doctors,
476 544
 		"department":           department,
477 545
 		"settle_prescriptions": settle_prescriptions,
546
+		"settle_total":         settle_total,
478 547
 	})
479 548
 	return
480 549
 
@@ -622,7 +691,8 @@ func (c *HisHospitalApiController) GetZHInHospitalCheck() {
622 691
 }
623 692
 func (this *HisHospitalApiController) GetZHOutHospitalCheck() {
624 693
 	id, _ := this.GetInt64("id")
625
-	record_date := this.GetString("record_date")
694
+	record_time := this.GetString("record_time")
695
+	out_time := this.GetString("out_time")
626 696
 
627 697
 	record, _ := service.GetInHospitalRecord(id)
628 698
 	if record.ID == 0 {
@@ -632,15 +702,15 @@ func (this *HisHospitalApiController) GetZHOutHospitalCheck() {
632 702
 
633 703
 	timeLayout := "2006-01-02"
634 704
 	loc, _ := time.LoadLocation("Local")
635
-	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
705
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
636 706
 
637 707
 	recordDateTime := theTime.Unix()
638 708
 
639
-	timestamp := time.Now().Unix()
640
-	tempTime := time.Unix(timestamp, 0)
641
-	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
709
+	//timestamp := time.Now().Unix()
710
+	//tempTime := time.Unix(timestamp, 0)
711
+	//timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
642 712
 	record.OutHospitalStatus = 1
643
-	record.OutHosptialTime = timeFormatOne
713
+	record.OutHosptialTime = out_time
644 714
 	record.OutWay = 1
645 715
 	service.CreateHospitalRecord(&record)
646 716
 

+ 25 - 0
service/his_hospital_service.go Voir le fichier

@@ -523,3 +523,28 @@ func GetNewUnChargeHisHospitalPrescriptionFive(org_id int64, patient_id int64, h
523 523
 		Find(&prescription).Error
524 524
 	return
525 525
 }
526
+
527
+func GetZHHisUploadOrderInfo(org_id int64, patient_id int64, record_date int64, record_end_date int64, number string) (infos []*models.HisOrderInfo, err error) {
528
+	err = readDb.Model(&models.HisOrderInfo{}).
529
+		Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ? AND order_number = ? ", org_id, record_end_date, record_date, patient_id, number).
530
+		Find(&infos).Error
531
+	return
532
+}
533
+
534
+func UpDateOrderInfoStatus(patient_id int64, record_date int64, org_id int64, record_two_date int64) (err error) {
535
+	err = writeDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ?", org_id, record_two_date, record_date, patient_id).Updates(map[string]interface{}{"status": 0}).Error
536
+	return
537
+}
538
+
539
+func UpDatePrescriptionOrderStatusTwo(patient_id int64, record_date int64, org_id int64) (err error) {
540
+	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = 1", org_id, record_date, patient_id).Updates(map[string]interface{}{"order_status": 1}).Error
541
+	return
542
+}
543
+
544
+func UpdataHospitalOrderStatusTwo(number string, user_org_id int64) (err error) {
545
+	err = writeDb.Model(&models.HisOrderInfo{}).Where("status = 1 AND order_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
546
+	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
547
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
548
+	return
549
+
550
+}

+ 7 - 1
service/his_service.go Voir le fichier

@@ -884,7 +884,13 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_time
884 884
 			db = db.Where("his_order.setl_time<=?", end_time+" 23:59:59")
885 885
 		}
886 886
 	}
887
-	db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.p_type = ? AND his_order.order_status = 2", user_org_id, p_type)
887
+	if p_type > 0 {
888
+		db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.p_type = ? AND his_order.order_status = 2", user_org_id, p_type)
889
+
890
+	} else {
891
+		db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.order_status = 2", user_org_id)
892
+
893
+	}
888 894
 	db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
889 895
 		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
890 896
 		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).