Browse Source

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

XMLWAN 2 years ago
parent
commit
d54d329f48

+ 33 - 0
controllers/his_charge_api_controller.go View File

@@ -33,6 +33,39 @@ func HisChargeApiRegistRouters() {
33 33
 
34 34
 	beego.Router("/api/his/getyidiclear", &HisChargeApiController{}, "get:GetHisYidiClearRecord")
35 35
 
36
+	beego.Router("/api/his/getexportdata", &HisChargeApiController{}, "get:GetExportData")
37
+
38
+}
39
+
40
+func (c *HisChargeApiController) GetExportData() {
41
+	start_time := c.GetString("start_time")
42
+	end_time := c.GetString("end_time")
43
+	adminUser := c.GetAdminUserInfo()
44
+	timeLayout := "2006-01-02"
45
+	loc, _ := time.LoadLocation("Local")
46
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
47
+	if err != nil {
48
+
49
+	}
50
+	startRecordDateTime := startTime.Unix()
51
+
52
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
53
+	if err != nil {
54
+
55
+	}
56
+	endRecordDateTime := endTime.Unix()
57
+	chargePatient, err := service.GetAllChargeDetailsTwo(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
58
+	if err == nil {
59
+		c.ServeSuccessJSON(map[string]interface{}{
60
+			"patients": chargePatient,
61
+		})
62
+		return
63
+	} else {
64
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
65
+		return
66
+
67
+	}
68
+
36 69
 }
37 70
 
38 71
 func (c *HisChargeApiController) UpdateFaPiaoRecordIsUse() {

+ 1 - 0
models/his_charge_models.go View File

@@ -104,6 +104,7 @@ type HisChargeOrder struct {
104 104
 	PsnCashPay          float64               `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
105 105
 	IsMedicineInsurance int64                 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
106 106
 	HisChargeOrderInfo  []*HisChargeOrderInfo `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"order_info"`
107
+	Patients            Patients              `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patient"`
107 108
 }
108 109
 
109 110
 func (HisChargeOrder) TableName() string {

+ 8 - 1
service/gobal_config_service.go View File

@@ -260,7 +260,14 @@ func GetExportHisOrderList(user_org_id int64, start_time int64, end_time int64,
260 260
 		db = db.Where("his_order.settle_accounts_date<=?", end_time)
261 261
 	}
262 262
 
263
-	db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.order_status = 2 AND p_type = ? ", user_org_id, p_type)
263
+	if p_type > 0 {
264
+		db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.order_status = 2 AND p_type = ? ", user_org_id, p_type)
265
+
266
+	} else {
267
+
268
+		db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.order_status = 2", user_org_id)
269
+
270
+	}
264 271
 
265 272
 	db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
266 273
 		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).

+ 20 - 0
service/his_charge_service.go View File

@@ -536,3 +536,23 @@ func GetPatientGather(patient_id int64, org_id int64, start_time int64, end_time
536 536
 	}
537 537
 	return
538 538
 }
539
+
540
+func GetAllChargeDetailsTwo(org_id int64, start_time int64, end_time int64) (patients []*models.HisChargeOrder, err error) {
541
+	err = readDb2.Model(&models.HisChargeOrder{}).Preload("Patients", "status = 1").Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
542
+		return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
543
+			Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
544
+				return db.Preload("Drug", "status = 1").Where("status = 1")
545
+			}).
546
+			Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
547
+				return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").
548
+					Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
549
+						return db.Select("id,project_name,unit").Where("status = 1 ")
550
+					}).
551
+					Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
552
+						return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
553
+					}).Where("status = 1 ")
554
+			}).Where("status = 1")
555
+	}).Where("status = 1  AND user_org_id = ? AND settle_accounts_date >= ? AND settle_accounts_date <= ? AND order_status = 2", org_id, start_time, end_time).Group("id").Find(&patients).Error
556
+
557
+	return
558
+}