csx před 2 roky
rodič
revize
3df2db0179

+ 33 - 0
controllers/his_charge_api_controller.go Zobrazit soubor

33
 
33
 
34
 	beego.Router("/api/his/getyidiclear", &HisChargeApiController{}, "get:GetHisYidiClearRecord")
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
 func (c *HisChargeApiController) UpdateFaPiaoRecordIsUse() {
71
 func (c *HisChargeApiController) UpdateFaPiaoRecordIsUse() {

+ 1 - 0
models/his_charge_models.go Zobrazit soubor

104
 	PsnCashPay          float64               `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
104
 	PsnCashPay          float64               `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
105
 	IsMedicineInsurance int64                 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
105
 	IsMedicineInsurance int64                 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
106
 	HisChargeOrderInfo  []*HisChargeOrderInfo `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"order_info"`
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
 func (HisChargeOrder) TableName() string {
110
 func (HisChargeOrder) TableName() string {

+ 8 - 1
service/gobal_config_service.go Zobrazit soubor

260
 		db = db.Where("his_order.settle_accounts_date<=?", end_time)
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
 	db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
272
 	db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
266
 		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
273
 		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).

+ 20 - 0
service/his_charge_service.go Zobrazit soubor

536
 	}
536
 	}
537
 	return
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
+}

+ 1 - 1
service/his_hospital_service.go Zobrazit soubor

342
 	db = db.Joins("join xt_schedule as sch ON sch.patient_id = his_hospital_check_record.patient_id AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_date = ?", org_id, record_date)
342
 	db = db.Joins("join xt_schedule as sch ON sch.patient_id = his_hospital_check_record.patient_id AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_date = ?", org_id, record_date)
343
 
343
 
344
 	if sch_type > 0 {
344
 	if sch_type > 0 {
345
-		db = db.Joins("join xt_schedule as sch ON sch.patient_id = his_hospital_check_record.patient_id AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_date = ? AND sch.schedule_type = ? ", org_id, record_date, sch_type)
345
+		db = db.Joins("join xt_schedule as schs ON schs.patient_id = his_hospital_check_record.patient_id AND schs.status = 1 AND schs.user_org_id = ? AND schs.schedule_date = ? AND schs.schedule_type = ? ", org_id, record_date, sch_type)
346
 	}
346
 	}
347
 	db = db.Where("his_hospital_check_record.user_org_id = ? AND his_hospital_check_record.status = 1 AND his_hospital_check_record.in_hospital_status = 1 AND his_hospital_check_record.out_hospital_status = 0", org_id)
347
 	db = db.Where("his_hospital_check_record.user_org_id = ? AND his_hospital_check_record.status = 1 AND his_hospital_check_record.in_hospital_status = 1 AND his_hospital_check_record.out_hospital_status = 0", org_id)
348
 	err = db.Group("number").Find(&patients).Error
348
 	err = db.Group("number").Find(&patients).Error